diff --git a/src/assets/images/room_stasis.png b/src/assets/images/room_stasis.png new file mode 100644 index 0000000..f7776c6 Binary files /dev/null and b/src/assets/images/room_stasis.png differ diff --git a/src/assets/images/room_stasis_dark.png b/src/assets/images/room_stasis_dark.png new file mode 100644 index 0000000..90b5e33 Binary files /dev/null and b/src/assets/images/room_stasis_dark.png differ diff --git a/src/assets/images/test.png b/src/assets/images/test.png deleted file mode 100644 index e80d5f9..0000000 Binary files a/src/assets/images/test.png and /dev/null differ diff --git a/src/index.html b/src/index.html index 9a3563f..4b1470d 100644 --- a/src/index.html +++ b/src/index.html @@ -4,6 +4,7 @@
a js13kgame by Aaron Fischer (2017)
+loading game ...
diff --git a/src/main.js b/src/main.js index 1d0f421..4c8e221 100644 --- a/src/main.js +++ b/src/main.js @@ -46,31 +46,30 @@ (function() { kontra.init('js13k-2017'); + kontra.assets.imagePath = 'assets/images'; + kontra.assets.load( - 'assets/images/test.png' + 'room_stasis_dark.png', + 'room_stasis.png' ).then(function() { - var image = new Image(); - image.src = 'assets/images/test.png'; - - var sprite = kontra.sprite({ - x: 10, - y: 20, - width: 16, - height: 16, - dx: 0, - image: image - }); + document.getElementById('loading').style.display = 'none'; + + if (kontra.store.get('current-room') === null) + kontra.store.set('current-room', 'stasis_dark'); + + var rooms = { + stasis_dark: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis_dark}), + stasis: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis}) + }; var loop = kontra.gameLoop({ update: function() { - sprite.update(); - - if (sprite.x > kontra.canvas.width) { - sprite.x = -sprite.width; - } + var currentRoom = kontra.store.get('current-room'); + rooms[currentRoom].update(); }, render: function() { - sprite.render(); + var currentRoom = kontra.store.get('current-room'); + rooms[currentRoom].render(); } });