Move things a little bit
This commit is contained in:
parent
ff2cfc3d60
commit
22d4f6bcee
3 changed files with 31 additions and 20 deletions
|
@ -15,4 +15,4 @@
|
||||||
<script src="muri.js"></script>
|
<script src="muri.js"></script>
|
||||||
<script src="bubble.js"></script>
|
<script src="bubble.js"></script>
|
||||||
<script src="mouse.js"></script>
|
<script src="mouse.js"></script>
|
||||||
<script src="act1.js"></script>
|
<script src="stasis.js"></script>
|
||||||
|
|
16
src/muri.js
16
src/muri.js
|
@ -45,7 +45,7 @@ var muri = (function() {
|
||||||
|
|
||||||
var muri = {};
|
var muri = {};
|
||||||
|
|
||||||
var bg = function(room) {
|
muri.bg = function(room) {
|
||||||
return kontra.sprite({
|
return kontra.sprite({
|
||||||
x: 0, y: 0,
|
x: 0, y: 0,
|
||||||
image: kontra.assets.images['room_'+room]
|
image: kontra.assets.images['room_'+room]
|
||||||
|
@ -53,6 +53,7 @@ var muri = (function() {
|
||||||
};
|
};
|
||||||
muri.currentRoom = 'stasis';
|
muri.currentRoom = 'stasis';
|
||||||
muri.modules = [];
|
muri.modules = [];
|
||||||
|
muri.rooms = {};
|
||||||
muri.get = function(moduleName) {
|
muri.get = function(moduleName) {
|
||||||
for (var i in muri.modules)
|
for (var i in muri.modules)
|
||||||
if (muri.modules[i].name === moduleName)
|
if (muri.modules[i].name === moduleName)
|
||||||
|
@ -66,20 +67,15 @@ var muri = (function() {
|
||||||
'stasis_door-sheet.png'
|
'stasis_door-sheet.png'
|
||||||
).then(function() {
|
).then(function() {
|
||||||
document.getElementById('loading').style.display = 'none';
|
document.getElementById('loading').style.display = 'none';
|
||||||
var rooms = {
|
|
||||||
stasis_dark: bg('stasis_dark'),
|
|
||||||
stasis: bg('stasis')
|
|
||||||
};
|
|
||||||
|
|
||||||
kontra.gameLoop({
|
kontra.gameLoop({
|
||||||
update: function() {
|
update: function() {
|
||||||
rooms[muri.currentRoom].update();
|
muri.rooms[muri.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() {
|
||||||
rooms[muri.currentRoom].render();
|
muri.rooms[muri.currentRoom].render();
|
||||||
muri.modules.forEach(function(m) {
|
muri.modules.forEach(function(m) {
|
||||||
if (m.render !== undefined) m.render();
|
if (m.render !== undefined) m.render();
|
||||||
});
|
});
|
||||||
|
@ -89,6 +85,10 @@ var muri = (function() {
|
||||||
muri.modules.forEach(function(m) {
|
muri.modules.forEach(function(m) {
|
||||||
if (m.init !== undefined) m.init();
|
if (m.init !== undefined) m.init();
|
||||||
});
|
});
|
||||||
|
muri.rooms.forEach(function(r) {
|
||||||
|
....
|
||||||
|
if (r.init !== undefined) r.init();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
(function() {
|
(function() {
|
||||||
var act1 = {};
|
var stasis = {};
|
||||||
|
|
||||||
var controlPanelSprite = kontra.sprite({x: 16, y: 13, width: 3, height: 2});
|
var controlPanelSprite = kontra.sprite({x: 16, y: 13, width: 3, height: 2});
|
||||||
|
var background, backgroundDark = null;
|
||||||
var doorAnimationSheet = null;
|
var doorAnimationSheet = null;
|
||||||
var doorSprite = null;
|
var doorSprite = null;
|
||||||
var roomState = {
|
var roomState = {
|
||||||
isDoorOpen: false
|
isDoorOpen: false,
|
||||||
|
isLightOn: false
|
||||||
};
|
};
|
||||||
|
|
||||||
act1.init = function() {
|
stasis.init = function() {
|
||||||
doorAnimationSheet = kontra.spriteSheet({
|
doorAnimationSheet = kontra.spriteSheet({
|
||||||
image: kontra.assets.images['stasis_door-sheet'],
|
image: kontra.assets.images['stasis_door-sheet'],
|
||||||
frameWidth: 24,
|
frameWidth: 24,
|
||||||
|
@ -35,7 +37,10 @@
|
||||||
animations: doorAnimationSheet.animations
|
animations: doorAnimationSheet.animations
|
||||||
});
|
});
|
||||||
|
|
||||||
if (muri.currentRoom === 'stasis_dark') {
|
background = muri.bg('stasis');
|
||||||
|
backgroundDark = muri.bg('stasis_dark');
|
||||||
|
|
||||||
|
if (!roomState.isLightOn) {
|
||||||
muri.get('bubble')
|
muri.get('bubble')
|
||||||
.story([
|
.story([
|
||||||
[['Beep', 'Bip, Bip'], [20, 15]],
|
[['Beep', 'Bip, Bip'], [20, 15]],
|
||||||
|
@ -45,9 +50,9 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
act1.update = function() {
|
stasis.update = function() {
|
||||||
doorSprite.update();
|
doorSprite.update();
|
||||||
if (muri.currentRoom === 'stasis') {
|
if (roomState.isLightOn) {
|
||||||
if (muri.get('mouse').clickedOn(doorSprite)) {
|
if (muri.get('mouse').clickedOn(doorSprite)) {
|
||||||
muri.get('mouse').releaseClick();
|
muri.get('mouse').releaseClick();
|
||||||
if (!roomState.isDoorOpen) {
|
if (!roomState.isDoorOpen) {
|
||||||
|
@ -63,8 +68,8 @@
|
||||||
if (muri.get('mouse').clickedOn(controlPanelSprite)) {
|
if (muri.get('mouse').clickedOn(controlPanelSprite)) {
|
||||||
muri.get('mouse').releaseClick();
|
muri.get('mouse').releaseClick();
|
||||||
|
|
||||||
if (muri.currentRoom === 'stasis_dark') {
|
if (!roomState.isLightOn) {
|
||||||
muri.currentRoom = 'stasis';
|
roomState.isLightOn = true;
|
||||||
muri.get('bubble')
|
muri.get('bubble')
|
||||||
.talk([
|
.talk([
|
||||||
'Ah, much better.',
|
'Ah, much better.',
|
||||||
|
@ -77,11 +82,17 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
act1.render = function() {
|
stasis.render = function() {
|
||||||
if (muri.currentRoom === 'stasis') {
|
if (roomState.isLightOn) {
|
||||||
|
background.render();
|
||||||
|
} else {
|
||||||
|
backgroundDark.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roomState.isLightOn) {
|
||||||
doorSprite.render();
|
doorSprite.render();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
muri.modules.push(act1);
|
muri.rooms['stasis'] = stasis;
|
||||||
}());
|
}());
|
Loading…
Reference in a new issue