| 1 | $(init); |
| 2 | |
| 3 | //load in images |
| 4 | var s_timer = new image("images/timerPlaceholder.png", 10, 10); //10 subimages, with 10 per row. (So just one row in this example.) |
| 5 | |
| 6 | var soundsFolder = "sounds"; |
| 7 | var sounds = |
| 8 | [ |
| 9 | "shoot" |
| 10 | ]; //List of all sound files as strings (do not include file extension) |
| 11 | |
| 12 | function init() |
| 13 | { |
| 14 | Game.initialize(20, 20, 500, 500, 60, gameStart); //Start game engine. Create a window at 20,20, width 500 and height 500, 60 frames per second. As soon as loading is done, it'll call gameStart(). |
| 15 | } |
| 16 | |
| 17 | function gameStart() |
| 18 | { |
| 19 | GameWindow.backgroundColor = {r:0, g:0, b:0}; |
| 20 | |
| 21 | Game.setUpdateFunction(update); //Let the game engine know we want to link our 'update()' to the game's update step. |
| 22 | |
| 23 | GameAudio.init(sounds, soundsFolder); |
| 24 | |
| 25 | GameObject.create(block, 300, 300); //create an empty block which does nothing |
| 26 | } |
| 27 | |
| 28 | function update() |
| 29 | { |
| 30 | //You can add code here which will be executed every frame. (recommended to do this in individual objects whenever possible) |
| 31 | } |
| 32 | |
| 33 | var block = |
| 34 | { |
| 35 | start: function() |
| 36 | { |
| 37 | this.renderer.image = s_timer; |
| 38 | this.renderer.image.subImages = 10; |
| 39 | this.renderer.image.subImagesPerRow = 10; |
| 40 | }, |
| 41 | |
| 42 | update: function(deltaTime) |
| 43 | { |
| 44 | this.renderer.subImage += deltaTime; |
| 45 | } |
| 46 | } |