Arcade Village Blog

Programming a game in javascript

Objective of this course

At the end of this course, you will be able to create a javascript game from scratch. I will not use open-source or paid libraries. I am not claiming that your games will perform the best, but you will have understood all the mechanics of making your own game.


You must know the basics of programming (types of variables, functions, etc) and above all of object programming. Even though javascript is not an object language per se, I will use it as such so that the code is reusable in other languages.
You must also be patient. I am French and English is not my first langage. I will remove traduction errors from time to time.

Why javascript?

I believe the answer can be found quite simply in my story. I have always programmed my games on my own and for fun. So I have to use a free programming language that can be ported to all platforms. Previously, I used java to program my games. I like the idea of ​​not being dependent on outside libraries or linked to an operating system. But the danger that Oracle and its lawyers pose to this language bothers me. If this last point interests you, do not hesitate to dig for yourself on the Internet. I was also touched by the disappearance of applets, even though I was able to recover all my games in the Arcade Village jukebox. I love my programs and knowing that they are no longer in use pains me. I had the misfortune to see the movie Tron when I was starting programming and it marked my life vision of what a program is.
I stop my alcoholic talk about the war at a bar counter and now move on to the list of pros and cons of Javascript.

What are the disadvantages of javascript

- Javascript is a very permissive language. It allows you to declare variables anywhere, not to type them and does not growl if you forget a semicolon. This leads to errors that take a long time to correct and an unnecessary waste of time.
- Javascript is not an object language but a prototype language. That is to say that you do not declare your classes but objects whose behavior you can modify during the course of a program. This clause is annoying if you modify someone else's code, but we'll see how to get closest to object language.
- Javascript uses a garbage collector. However, I remind you, this language is not typed and each object can be modified at any time. Memory management is therefore very complex and no browser can manage to cope with it. Use gmail or facebook on any browser and you will see it crumble after a while. In the case of a game, this is obviously not acceptable. Facebook and google are also dispensing with more and more javascript for their websites.

What are THE advantage of javascript

- Javascript runs on all browsers and therefore on all existing systems. It is even possible to simulate a mobile phone application with it. In addition, this language being directly interpreted, we can instantly see the result of our modifications (once the bugs are removed) and it is very pleasant.

To be continued...