Advertisement

Is learning JavaScript a right way of beginning 2D-game programming?

Started by August 07, 2018 08:01 AM
14 comments, last by mr_tawan 6 years, 6 months ago
40 minutes ago, mr_tawan said:

My first game is in Java

Just to avoid any potential confusion, it's worth noting that there is no relation between Java and JavaScript. :)

Either is fine as a first language.

- Jason Astle-Adams

2 hours ago, jbadams said:

Just to avoid any potential confusion, it's worth noting that there is no relation between Java and JavaScript. :)

Either is fine as a first language.

lol yes indeed. They are completely different languages.

http://9tawan.net/en/

Advertisement

I would actually recommend Python as a better alternative. JavaScript is more generally used for Web programming and HTML5 games and applications for internet browsers. Python is more general and there are a ton of game development libraries for it already. Pygame comes to mind.

Also a lot of software have built in Python scripting, such as Blender for example. Learning Python lets you kill two birds with one stone.

View my game dev blog here!

I would recommend JS for starters, just because it's very fast to distribute and share the game on the web, and let others test the game.

If you went for more serious languages it would be much harder to share your work as people wouldn't want to download content into their PC if you're not on Steam or other stable platform.

It's perfectly fine to start with web development and progress to standalone cross platform later when you have more experience and idea how everything interacts in game flow

Here is my another thought.

I think, as many of us here already mentioned, that you can start in any language (JavaScript included). However, I think it's important to use some kind of framework or library -- they are not the same thing, I'll explain later. This is to make sure you're focusing on the game code itself, not the low-level stuff (which can be pretty scary for beginners).

There are different framework and library for different language and platform. For example, SDL(C), SFML(C++) and Cocos2d-X(C++), LOVE(Lua), LibGDX(Java), MonoGame(C#) etc. 

Framework or library are not game engine, they are something game engine is created on top of that. A game library is a library which simplified a lot of low-level process like  initialization, texture loading, for instance. You will still have to write quite a lot of code to do these process, but it is abstracted away so it will be much easier than say in DirectX. In a framework, most of the low-level process like initialization will be handled by the framework itself. You just create an entry point so the framework can call your function. Your code will end up like.


@Init
void doInit(){
  textureA = loadTexture("a.texture");
  hitSound = loadAudio("hit.wav");
}

@Update
void doUpdate(Input input){
  //... update all game object.
}

@Render
void doRender(RenderDevice device){
  //...draw all objects
}

@CleanUp
void doCleanUp(){
  release(textureA);
  release(hitSound);
}

The main different between framework and library comparing to game engine is, they does not provide any game logic-related code. In game engine, you are provided with game object and components. Using framework means you have to write your own game objects. 

The reason that I think, you could start with either a framework or a library is, you'll end up writing a framework yourself if you go with a library (it's not that difficult, and it's a basic everyone should know too). So if you want to learn how framework works, go for a library. Otherwise use a framework. 

http://9tawan.net/en/

This topic is closed to new replies.

Advertisement