Add rooms
This commit is contained in:
parent
97788b9c39
commit
e71d8b0466
5 changed files with 18 additions and 18 deletions
BIN
src/assets/images/room_stasis.png
Normal file
BIN
src/assets/images/room_stasis.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 615 B |
BIN
src/assets/images/room_stasis_dark.png
Normal file
BIN
src/assets/images/room_stasis_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 B |
Binary file not shown.
Before Width: | Height: | Size: 223 B |
|
@ -4,6 +4,7 @@
|
||||||
<p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p>
|
<p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p>
|
||||||
|
|
||||||
<canvas width="100" height="50" id="js13k-2017"></canvas>
|
<canvas width="100" height="50" id="js13k-2017"></canvas>
|
||||||
|
<p id="loading">loading game ...</p>
|
||||||
|
|
||||||
<script src="vendor/kontra.js"></script>
|
<script src="vendor/kontra.js"></script>
|
||||||
<script src="main.js"></script>
|
<script src="main.js"></script>
|
||||||
|
|
35
src/main.js
35
src/main.js
|
@ -46,31 +46,30 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
kontra.init('js13k-2017');
|
kontra.init('js13k-2017');
|
||||||
|
kontra.assets.imagePath = 'assets/images';
|
||||||
|
|
||||||
kontra.assets.load(
|
kontra.assets.load(
|
||||||
'assets/images/test.png'
|
'room_stasis_dark.png',
|
||||||
|
'room_stasis.png'
|
||||||
).then(function() {
|
).then(function() {
|
||||||
var image = new Image();
|
document.getElementById('loading').style.display = 'none';
|
||||||
image.src = 'assets/images/test.png';
|
|
||||||
|
if (kontra.store.get('current-room') === null)
|
||||||
var sprite = kontra.sprite({
|
kontra.store.set('current-room', 'stasis_dark');
|
||||||
x: 10,
|
|
||||||
y: 20,
|
var rooms = {
|
||||||
width: 16,
|
stasis_dark: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis_dark}),
|
||||||
height: 16,
|
stasis: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis})
|
||||||
dx: 0,
|
};
|
||||||
image: image
|
|
||||||
});
|
|
||||||
|
|
||||||
var loop = kontra.gameLoop({
|
var loop = kontra.gameLoop({
|
||||||
update: function() {
|
update: function() {
|
||||||
sprite.update();
|
var currentRoom = kontra.store.get('current-room');
|
||||||
|
rooms[currentRoom].update();
|
||||||
if (sprite.x > kontra.canvas.width) {
|
|
||||||
sprite.x = -sprite.width;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
sprite.render();
|
var currentRoom = kontra.store.get('current-room');
|
||||||
|
rooms[currentRoom].render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue