diff options
author | Indrajith K L | 2018-08-12 02:37:22 +0530 |
---|---|---|
committer | Indrajith K L | 2018-08-12 02:37:22 +0530 |
commit | ddbf11efa3667f6db0f04e93e6ce8ddc17b73a52 (patch) | |
tree | 441d2ca965aefadd45181c25afb8b3d1426cf7e7 /src/js/main.js | |
download | js13kgames-template-ddbf11efa3667f6db0f04e93e6ce8ddc17b73a52.tar.gz js13kgames-template-ddbf11efa3667f6db0f04e93e6ce8ddc17b73a52.tar.bz2 js13kgames-template-ddbf11efa3667f6db0f04e93e6ce8ddc17b73a52.zip |
Initial Commmit:
Gulp Tasks for
* Copy libs to public folder
* Source Uglyfy + Copy
* Zip
Diffstat (limited to 'src/js/main.js')
-rw-r--r-- | src/js/main.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/js/main.js b/src/js/main.js new file mode 100644 index 0000000..ded3502 --- /dev/null +++ b/src/js/main.js @@ -0,0 +1,30 @@ +function Game(){ + kontra.init(); + var sprite = kontra.sprite({ + x: 100, // starting x,y position of the sprite + y: 80, + color: 'blue', // fill color of the sprite rectangle + width: 20, // width and height of the sprite rectangle + height: 40, + dx: 2 // move the sprite 2px to the right every frame + }); + + var loop = kontra.gameLoop({ // create the main game loop + update: function() { // update the game state + sprite.update(); + + // wrap the sprites position when it reaches + // the edge of the screen + if (sprite.x > kontra.canvas.width) { + sprite.x = -sprite.width; + } + }, + render: function() { // render the game state + sprite.render(); + } + }); + + loop.start(); // start the game +} + +window.Game = Game;
\ No newline at end of file |