12/28/14 Weekly Update

I spent last week learning about a combination of game development in HTML and Javascript. I would like to get the basics down and eventually port an example to Go.

Here's what I ended up creating, it's just a blue box that moves from left to right and loops. Nothing crazy but to me there's a lot of work that went into it. I've created a repository to consolidate files and learning here. I will supplement my learning with tutorial style posts.


Notes

Brain dump of some of the things I've worked with.

Javascript

  • "use strict" is something that's new to me since I had last learned Javascript. Placing the statement "use strict"; on the first line of a javascript file will enforce a couple of rules which w3schools does a great job of explaining here.

My take on this is that I believe javascript shouldn't never have been given such "leeway" in the first place but I can understand why given its history. I'm glad that an effort to standardize javascript is in process, and without a very good reason everyone should write js "strictly".

  • It's possible to assign functions to variables. I keep forgettting this.

  • If a variable is used without first being declared, it is a global variable.

Game Programming

  • In my own words (forgive the crappy explanation), a game consists of a few core parts:

    • Game 'objects' that exist and interact with each other + other sources such as user input.
    • Game logic and Game logic Calculation
    • A draw function to update the visual aspects of the game
    • A loop to tie everything together and run continuously.

So, Game objects will be created and interact with each other + other sources. There is game logic that will be calculated based on the state and behavior of the game objects and their relation to other sources of input. Based on those calculations, the next visual frame is drawn. A loop repeats this.

To be more clear, we can think about how Pacman works. When the user presses the key to move up, the game engine takes note of that and draws Pacman in a position higher than he was in the previous frame. If he makes contact with a dot, the game engine takes note of it and removes the dot, updating points as necessary. When Pacman dies by making contact with a ghost, the game notices that and proceeds to show a game over message. Additionally, the game may start when you press/initiate start. In the case of an arcade machine, the game engine will not start the game unless there are credits that are generated by the player inserting tokens. As you can see, there's a good amount of logic that goes into the game. The engine's job is to keep track of all game logic + display the next appropriate frame.


Remarks/Comments

  • Side-side projects: Rails refresher, Ghost theme editing, Nginx rerouting, adding disqus + analytics as a commenting platform to this blog.

  • Amazon Web Services is rewarding people who complete one out of two courses on enterpreneurship $1000 in credit. Whoohoo! Source.