Week 07

View the lecture

Homework

Assignment

Tiny Game Starter Code

Download the and unzip the gist, and open index.html in your browser, and game.js in your code editor.

I've written a function that renders a game board (board.js). I've also written some starter code for a game (game.js) that doesn't do much, but generates data for the board component.

data is an array of objects used by Board, and generated by Game and called with render_data(data)

These objects should have these properties:

And any other properties you'd like to add.

You can add and remove objects from the array, as well as changing the properties of existing objects. For instance, you could move an object to the right by increasing it's col value.

The code in index.html will call two of your Game class's functions. Keypressed and every second. I've provided example implementations in game.js, but you should improve them.

keypressed(keyname) will be called whenever a key is pressed

do_every_second() will be called every second.

Finally, don't forget to call update_data(data) to update the board.

I recommend you work in game.js. You don't need to edit the other files.

Possible games:

Or whatever you want! It's up to you. The only requirements are 1) that you use the Board class 2) that your game objects interact in some way (collision, etc)

Send a link to a gist or repo containing all the files necessary to run your game to zachary.schwartz@qc.cuny.edu by Thursday March 22st at 9am.