From e71d8b04665951dfa8e51363f924044197419e57 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Tue, 15 Aug 2017 15:57:32 +0200 Subject: [PATCH] Add rooms --- src/assets/images/room_stasis.png | Bin 0 -> 615 bytes src/assets/images/room_stasis_dark.png | Bin 0 -> 361 bytes src/assets/images/test.png | Bin 223 -> 0 bytes src/index.html | 1 + src/main.js | 35 ++++++++++++------------- 5 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/assets/images/room_stasis.png create mode 100644 src/assets/images/room_stasis_dark.png delete mode 100644 src/assets/images/test.png diff --git a/src/assets/images/room_stasis.png b/src/assets/images/room_stasis.png new file mode 100644 index 0000000000000000000000000000000000000000..f7776c6e244cb23e942f9f670d26c21542d7f71d GIT binary patch literal 615 zcmV-t0+{`YP)I)#fF;_8$_NZ`uyZy^_5Bix1X66@cjr4N$7;9R{U|gWtuX;W5I_KeB!P5Y zhh>P6H2qhn(Xjn0ew-Ticp4$E4E$~nbR!x>&0&g@E|6woRj)b82s`IvI1l9+Xm_ zeg9y$R0mmfg!s9gjQRV*7}XUX>+5{J8`EEpLJqvniIBNfID2c~5}mhKDLW;Xy)`S2 zSBnbor8OPJJL_0fq}oZRR2Zep%akNJlvr!eO?q3`DT|)dxnwSLkjf5Cx;+_00aR9AP67;K>z^=0tgxs&$5IywO0%v1z^Pb z#Kr&tL=Z-3?3|~)%NfQ6G;-sFD zKSET zWe1Ai_jGX#skrs_)StyI`7Av$CDQosIfJ^%gs z$|*03?$rt{kNEj|$?2VyBEpvv(*2HY@3j22X`hv1(e$syGX;c|6dYK9hH-ERFft;u z7rpgenp4-G{z~nM)zvlP%$F3-B(1*Pw$J{L@!z&N5od2@OkX2w8-A#MRa)*A&cf+m k|AX*OUy;o_gg{~7>FVdQ&MBb@0M@2~w*UYD literal 0 HcmV?d00001 diff --git a/src/assets/images/test.png b/src/assets/images/test.png deleted file mode 100644 index e80d5f984b076c94590e792b6791611884e28096..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#AqPLNIMS|xv6<2KrRD=b5UwyNotBhd1gt5g1e`0K#E=} zJ5W5-)5S4F<9u>Ruy(QolX*U?!2?zw9+jp*ULGEvS6R{-In7H|vz`8g*+@zJ|NsB| zfddmJ1T?E{Oju~{Cv6aFY+&$U6Z?F5p-0=3vXT{Fc$?U6>9=5byGCgKmS<`2KsI~2 L`njxgN@xNA^Z-F1 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(); } });