Fix firefox issues, remove new game button and make current room more intuitive
This commit is contained in:
parent
f8bf7dfb51
commit
9a0a8c94a3
4 changed files with 11 additions and 24 deletions
|
@ -4,7 +4,7 @@
|
|||
var controlPanelSprite = kontra.sprite({x: 16, y: 13, width: 3, height: 2});
|
||||
|
||||
act1.init = function() {
|
||||
if (kontra.store.get('current-room') === 'stasis_dark') {
|
||||
if (muri.currentRoom === 'stasis_dark') {
|
||||
muri.get('bubble')
|
||||
.story([
|
||||
[['Beep', 'Bip, Bip'], [20, 15]],
|
||||
|
@ -18,8 +18,8 @@
|
|||
if (muri.get('mouse').clickedOn(controlPanelSprite)) {
|
||||
muri.get('mouse').releaseClick();
|
||||
|
||||
if (kontra.store.get('current-room') === 'stasis_dark') {
|
||||
kontra.store.set('current-room', 'stasis');
|
||||
if (muri.currentRoom === 'stasis_dark') {
|
||||
muri.currentRoom = 'stasis';
|
||||
muri.get('bubble')
|
||||
.talk([
|
||||
'Ah, much better.',
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<p id="loading">loading game ...</p>
|
||||
<button id="newGame">New Game</button>
|
||||
|
||||
<script src="vendor/kontra.js"></script>
|
||||
<script src="muri.js"></script>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
mouse.enable = function() {
|
||||
isEnabled = true;
|
||||
canvas.style.cursor = 'hand';
|
||||
canvas.style.cursor = 'pointer';
|
||||
};
|
||||
|
||||
mouse.name = 'mouse';
|
||||
|
|
26
src/muri.js
26
src/muri.js
|
@ -51,6 +51,7 @@ var muri = (function() {
|
|||
image: kontra.assets.images['room_'+room]
|
||||
});
|
||||
};
|
||||
muri.currentRoom = 'stasis_dark';
|
||||
muri.modules = [];
|
||||
muri.get = function(moduleName) {
|
||||
for (var i in muri.modules)
|
||||
|
@ -58,22 +59,12 @@ var muri = (function() {
|
|||
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() {
|
||||
kontra.assets.load(
|
||||
'player.png',
|
||||
'room_stasis_dark.gif',
|
||||
'room_stasis.gif'
|
||||
).then(function() {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
if (kontra.store.get('current-room') === null)
|
||||
kontra.store.set('current-room', 'stasis');
|
||||
var rooms = {
|
||||
stasis_dark: bg('stasis_dark'),
|
||||
stasis: bg('stasis')
|
||||
|
@ -81,29 +72,26 @@ var muri = (function() {
|
|||
|
||||
kontra.gameLoop({
|
||||
update: function() {
|
||||
var currentRoom = kontra.store.get('current-room');
|
||||
rooms[currentRoom].update();
|
||||
rooms[muri.currentRoom].update();
|
||||
muri.modules.forEach(function(m) {
|
||||
if (m.update !== undefined) m.update();
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
var currentRoom = kontra.store.get('current-room');
|
||||
rooms[currentRoom].render();
|
||||
rooms[muri.currentRoom].render();
|
||||
muri.modules.forEach(function(m) {
|
||||
if (m.render !== undefined) m.render();
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
|
||||
muri.newGame();
|
||||
muri.modules.forEach(function(m) {
|
||||
if (m.init !== undefined) m.init();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return muri;
|
||||
}());
|
||||
|
||||
document
|
||||
.getElementById('newGame')
|
||||
.addEventListener('click', muri.newGame);
|
||||
window.onload = muri.setup;
|
||||
|
|
Loading…
Reference in a new issue