Basic movement finished
BIN
src/assets/images/door_sheet.png
Normal file
After Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 557 B |
Before Width: | Height: | Size: 401 B After Width: | Height: | Size: 566 B |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 130 B |
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
bubble.skip('talk');
|
||||
var text = texts.shift();
|
||||
return show(text, position || [5, 52])
|
||||
return show(text, position || [5, 46])
|
||||
.then(function(what) {
|
||||
if (what === 'talk') {
|
||||
return Promise.resolve(what);
|
||||
|
|
32
src/muri.js
|
@ -64,6 +64,36 @@ var muri = (function() {
|
|||
muri.get = fetchObject('modules');
|
||||
muri.room = fetchObject('rooms');
|
||||
|
||||
muri.changeRoom = function(room) {
|
||||
var fromRoom = muri.currentRoom;
|
||||
muri.currentRoom = room;
|
||||
if (muri.room(room).onEnter !== undefined)
|
||||
muri.room(room).onEnter(fromRoom);
|
||||
};
|
||||
|
||||
muri.door = function(room, position) {
|
||||
var doorAnimationSheet = kontra.spriteSheet({
|
||||
image: kontra.assets.images.door_sheet,
|
||||
frameWidth: 13, frameHeight: 22,
|
||||
animations: {
|
||||
closed: {frames: 0},
|
||||
opened: {frames: 5},
|
||||
open: {frames: '0..5', frameRate: 6},
|
||||
close: {frames: '5..0', frameRate: 6}
|
||||
}
|
||||
});
|
||||
var doorSprite = kontra.sprite({
|
||||
x: position[0], y: position[1],
|
||||
animations: doorAnimationSheet.animations
|
||||
});
|
||||
return muri.get('entity')
|
||||
.create(room+'.door', doorSprite)
|
||||
.addCallback(function() {
|
||||
doorSprite.playAnimation('open');
|
||||
setTimeout(function() { muri.changeRoom('lift'); }, 1000);
|
||||
});
|
||||
};
|
||||
|
||||
muri.setup = function() {
|
||||
kontra.assets.load(
|
||||
'room_stasis_dark.png',
|
||||
|
@ -71,7 +101,7 @@ var muri = (function() {
|
|||
'room_engine.png',
|
||||
'room_bridge.png',
|
||||
'room_hydro.png',
|
||||
'stasis_doorSheet.png',
|
||||
'door_sheet.png',
|
||||
'stasis_lightSwitch.png',
|
||||
'room_lift.png',
|
||||
'lift_button.png'
|
||||
|
|
|
@ -3,16 +3,24 @@
|
|||
|
||||
var bridge = {};
|
||||
|
||||
var background, door = null;
|
||||
var roomState = {
|
||||
};
|
||||
|
||||
bridge.init = function() {
|
||||
background = muri.bg('bridge');
|
||||
door = muri.door('bridge', [83, 4]);
|
||||
};
|
||||
|
||||
bridge.onEnter = function() {
|
||||
door.sprite.playAnimation('close');
|
||||
};
|
||||
|
||||
bridge.update = function() {
|
||||
};
|
||||
|
||||
bridge.render = function() {
|
||||
background.render();
|
||||
};
|
||||
|
||||
bridge.name = 'bridge';
|
||||
|
|
|
@ -3,16 +3,24 @@
|
|||
|
||||
var engine = {};
|
||||
|
||||
var background, door = null;
|
||||
var roomState = {
|
||||
};
|
||||
|
||||
engine.init = function() {
|
||||
background = muri.bg('engine');
|
||||
door = muri.door('engine', [8, 10]);
|
||||
};
|
||||
|
||||
engine.onEnter = function() {
|
||||
door.sprite.playAnimation('close');
|
||||
};
|
||||
|
||||
engine.update = function() {
|
||||
};
|
||||
|
||||
engine.render = function() {
|
||||
background.render();
|
||||
};
|
||||
|
||||
engine.name = 'engine';
|
||||
|
|
|
@ -3,16 +3,24 @@
|
|||
|
||||
var hydro = {};
|
||||
|
||||
var background, door = null;
|
||||
var roomState = {
|
||||
};
|
||||
|
||||
hydro.init = function() {
|
||||
background = muri.bg('hydro');
|
||||
door = muri.door('hydro', [38, 9]);
|
||||
};
|
||||
|
||||
hydro.onEnter = function() {
|
||||
door.sprite.playAnimation('close');
|
||||
};
|
||||
|
||||
hydro.update = function() {
|
||||
};
|
||||
|
||||
hydro.render = function() {
|
||||
background.render();
|
||||
};
|
||||
|
||||
hydro.name = 'hydro';
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
position: 1
|
||||
};
|
||||
|
||||
var r = function(a) {
|
||||
return a[Math.floor(Math.random()*a.length)];
|
||||
};
|
||||
|
||||
var createButtonEntity = function(i, room) {
|
||||
var e = muri.get('entity')
|
||||
.create('lift.button'+i,
|
||||
|
@ -17,8 +21,17 @@
|
|||
.addCallback(function() {
|
||||
buttons.forEach(function(b) { b.sprite.playAnimation('off'); });
|
||||
muri.get('entity').get('lift.button'+i).sprite.playAnimation('on');
|
||||
muri.get('bubble').talk([room], [65, i*4+8]);
|
||||
setTimeout(function() { muri.currentRoom = room; }, 1000);
|
||||
var goMessage = r([
|
||||
'Sure, ' + room,
|
||||
'Okay, straight to ' + room,
|
||||
'Set ' + room + ' for destination',
|
||||
room + ', okay'
|
||||
]);
|
||||
muri.get('bubble')
|
||||
.talk([goMessage])
|
||||
.then(function() {
|
||||
muri.changeRoom(room);
|
||||
});
|
||||
});
|
||||
e.sprite.playAnimation('off');
|
||||
return e;
|
||||
|
@ -34,18 +47,26 @@
|
|||
}
|
||||
});
|
||||
|
||||
background = kontra.sprite({
|
||||
x: 0, y: 0,
|
||||
image: kontra.assets.images.room_lift});
|
||||
background = muri.bg('lift');
|
||||
buttons = [
|
||||
createButtonEntity(0, 'engine'), // Engine room
|
||||
createButtonEntity(1, 'stasis'), // Stasis
|
||||
createButtonEntity(2, 'hydro'), // Hydro Deck
|
||||
createButtonEntity(3, 'bridge') // Bridge
|
||||
createButtonEntity(0, 'bridge'), // Bridge
|
||||
createButtonEntity(1, 'hydro'), // Hydro Deck
|
||||
createButtonEntity(2, 'stasis'), // Stasis
|
||||
createButtonEntity(3, 'engine') // Engine room
|
||||
];
|
||||
buttons[1].sprite.playAnimation('on');
|
||||
};
|
||||
|
||||
lift.onEnter = function(fromRoom) {
|
||||
var welcomeMessage = r([
|
||||
'Welcome on board, where do you want?',
|
||||
'Please specify your destination.',
|
||||
'Insert desired deck on console.',
|
||||
'What level please?'
|
||||
]);
|
||||
muri.get('bubble').talk([welcomeMessage]);
|
||||
};
|
||||
|
||||
lift.update = function() {};
|
||||
|
||||
lift.render = function() {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
var stasis = {};
|
||||
|
||||
var background, backgroundDark = null;
|
||||
var doorAnimationSheet = null;
|
||||
var doorSprite = null;
|
||||
var door = null;
|
||||
var roomState = {
|
||||
isDoorOpen: false,
|
||||
isLightOn: false,
|
||||
|
@ -13,27 +12,12 @@
|
|||
};
|
||||
|
||||
stasis.init = function() {
|
||||
doorAnimationSheet = kontra.spriteSheet({
|
||||
image: kontra.assets.images.stasis_doorSheet,
|
||||
frameWidth: 24, frameHeight: 21,
|
||||
animations: {
|
||||
closed: {frames: 0},
|
||||
opened: {frames: 2},
|
||||
open: {frames: '0..3', frameRate: 6},
|
||||
close: {frames: '3..0', frameRate: 6}
|
||||
}
|
||||
});
|
||||
doorSprite = kontra.sprite({
|
||||
x: 72, y: 8,
|
||||
animations: doorAnimationSheet.animations
|
||||
});
|
||||
|
||||
background = muri.bg('stasis');
|
||||
backgroundDark = muri.bg('stasis_dark');
|
||||
|
||||
muri.get('entity')
|
||||
.create('stasis.lightSwitch',
|
||||
kontra.sprite({x: 15, y: 12, width: 3, height: 2,
|
||||
kontra.sprite({x: 9, y: 11, width: 3, height: 2,
|
||||
image: kontra.assets.images.stasis_lightSwitch}))
|
||||
.addCallback(function() {
|
||||
if (roomState.isIntroRunning) return;
|
||||
|
@ -63,22 +47,13 @@
|
|||
}
|
||||
};
|
||||
|
||||
stasis.onEnter = function(prevRoom) {
|
||||
door.sprite.playAnimation('close');
|
||||
};
|
||||
|
||||
stasis.update = function() {
|
||||
if (roomState.isLightOn &&
|
||||
!muri.get('entity').get('stasis.door')) {
|
||||
muri.get('entity')
|
||||
.create('stasis.door', doorSprite)
|
||||
.addCallback(function() {
|
||||
if (!roomState.isDoorOpen) {
|
||||
doorSprite.playAnimation('open');
|
||||
roomState.isDoorOpen = true;
|
||||
setTimeout(function() { muri.currentRoom = 'lift'; }, 800);
|
||||
} else {
|
||||
doorSprite.playAnimation('close');
|
||||
roomState.isDoorOpen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (roomState.isLightOn && !door)
|
||||
door = muri.door('stasis', [76, 11]);
|
||||
};
|
||||
|
||||
stasis.render = function() {
|
||||
|
|