Fix firefox issues, remove new game button and make current room more intuitive

This commit is contained in:
Aaron Fischer 2017-08-24 15:33:46 +02:00
parent f8bf7dfb51
commit 9a0a8c94a3
4 changed files with 11 additions and 24 deletions

View file

@ -4,7 +4,7 @@
var controlPanelSprite = kontra.sprite({x: 16, y: 13, width: 3, height: 2}); var controlPanelSprite = kontra.sprite({x: 16, y: 13, width: 3, height: 2});
act1.init = function() { act1.init = function() {
if (kontra.store.get('current-room') === 'stasis_dark') { if (muri.currentRoom === 'stasis_dark') {
muri.get('bubble') muri.get('bubble')
.story([ .story([
[['Beep', 'Bip, Bip'], [20, 15]], [['Beep', 'Bip, Bip'], [20, 15]],
@ -18,8 +18,8 @@
if (muri.get('mouse').clickedOn(controlPanelSprite)) { if (muri.get('mouse').clickedOn(controlPanelSprite)) {
muri.get('mouse').releaseClick(); muri.get('mouse').releaseClick();
if (kontra.store.get('current-room') === 'stasis_dark') { if (muri.currentRoom === 'stasis_dark') {
kontra.store.set('current-room', 'stasis'); muri.currentRoom = 'stasis';
muri.get('bubble') muri.get('bubble')
.talk([ .talk([
'Ah, much better.', 'Ah, much better.',

View file

@ -10,7 +10,6 @@
</div> </div>
</div> </div>
<p id="loading">loading game ...</p> <p id="loading">loading game ...</p>
<button id="newGame">New Game</button>
<script src="vendor/kontra.js"></script> <script src="vendor/kontra.js"></script>
<script src="muri.js"></script> <script src="muri.js"></script>

View file

@ -36,7 +36,7 @@
mouse.enable = function() { mouse.enable = function() {
isEnabled = true; isEnabled = true;
canvas.style.cursor = 'hand'; canvas.style.cursor = 'pointer';
}; };
mouse.name = 'mouse'; mouse.name = 'mouse';

View file

@ -51,6 +51,7 @@ var muri = (function() {
image: kontra.assets.images['room_'+room] image: kontra.assets.images['room_'+room]
}); });
}; };
muri.currentRoom = 'stasis_dark';
muri.modules = []; muri.modules = [];
muri.get = function(moduleName) { muri.get = function(moduleName) {
for (var i in muri.modules) for (var i in muri.modules)
@ -58,22 +59,12 @@ var muri = (function() {
return muri.modules[i]; return muri.modules[i];
}; };
muri.newGame = function() {
kontra.store.set('current-room', 'stasis_dark');
muri.modules.forEach(function(m) {
if (m.init !== undefined) m.init();
});
};
muri.setup = function() { muri.setup = function() {
kontra.assets.load( kontra.assets.load(
'player.png',
'room_stasis_dark.gif', 'room_stasis_dark.gif',
'room_stasis.gif' 'room_stasis.gif'
).then(function() { ).then(function() {
document.getElementById('loading').style.display = 'none'; document.getElementById('loading').style.display = 'none';
if (kontra.store.get('current-room') === null)
kontra.store.set('current-room', 'stasis');
var rooms = { var rooms = {
stasis_dark: bg('stasis_dark'), stasis_dark: bg('stasis_dark'),
stasis: bg('stasis') stasis: bg('stasis')
@ -81,29 +72,26 @@ var muri = (function() {
kontra.gameLoop({ kontra.gameLoop({
update: function() { update: function() {
var currentRoom = kontra.store.get('current-room'); rooms[muri.currentRoom].update();
rooms[currentRoom].update();
muri.modules.forEach(function(m) { muri.modules.forEach(function(m) {
if (m.update !== undefined) m.update(); if (m.update !== undefined) m.update();
}); });
}, },
render: function() { render: function() {
var currentRoom = kontra.store.get('current-room'); rooms[muri.currentRoom].render();
rooms[currentRoom].render();
muri.modules.forEach(function(m) { muri.modules.forEach(function(m) {
if (m.render !== undefined) m.render(); if (m.render !== undefined) m.render();
}); });
} }
}).start(); }).start();
});
muri.newGame(); muri.modules.forEach(function(m) {
if (m.init !== undefined) m.init();
});
});
}; };
return muri; return muri;
}()); }());
document
.getElementById('newGame')
.addEventListener('click', muri.newGame);
window.onload = muri.setup; window.onload = muri.setup;