Basic movement finished

This commit is contained in:
Aaron Fischer 2017-09-12 22:40:34 +02:00
parent 786bc0bed8
commit c18d9221f9
16 changed files with 94 additions and 44 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 130 B

View file

@ -40,7 +40,7 @@
} }
bubble.skip('talk'); bubble.skip('talk');
var text = texts.shift(); var text = texts.shift();
return show(text, position || [5, 52]) return show(text, position || [5, 46])
.then(function(what) { .then(function(what) {
if (what === 'talk') { if (what === 'talk') {
return Promise.resolve(what); return Promise.resolve(what);

View file

@ -64,6 +64,36 @@ var muri = (function() {
muri.get = fetchObject('modules'); muri.get = fetchObject('modules');
muri.room = fetchObject('rooms'); 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() { muri.setup = function() {
kontra.assets.load( kontra.assets.load(
'room_stasis_dark.png', 'room_stasis_dark.png',
@ -71,7 +101,7 @@ var muri = (function() {
'room_engine.png', 'room_engine.png',
'room_bridge.png', 'room_bridge.png',
'room_hydro.png', 'room_hydro.png',
'stasis_doorSheet.png', 'door_sheet.png',
'stasis_lightSwitch.png', 'stasis_lightSwitch.png',
'room_lift.png', 'room_lift.png',
'lift_button.png' 'lift_button.png'

View file

@ -3,16 +3,24 @@
var bridge = {}; var bridge = {};
var background, door = null;
var roomState = { var roomState = {
}; };
bridge.init = function() { bridge.init = function() {
background = muri.bg('bridge');
door = muri.door('bridge', [83, 4]);
};
bridge.onEnter = function() {
door.sprite.playAnimation('close');
}; };
bridge.update = function() { bridge.update = function() {
}; };
bridge.render = function() { bridge.render = function() {
background.render();
}; };
bridge.name = 'bridge'; bridge.name = 'bridge';

View file

@ -3,16 +3,24 @@
var engine = {}; var engine = {};
var background, door = null;
var roomState = { var roomState = {
}; };
engine.init = function() { engine.init = function() {
background = muri.bg('engine');
door = muri.door('engine', [8, 10]);
};
engine.onEnter = function() {
door.sprite.playAnimation('close');
}; };
engine.update = function() { engine.update = function() {
}; };
engine.render = function() { engine.render = function() {
background.render();
}; };
engine.name = 'engine'; engine.name = 'engine';

View file

@ -3,16 +3,24 @@
var hydro = {}; var hydro = {};
var background, door = null;
var roomState = { var roomState = {
}; };
hydro.init = function() { hydro.init = function() {
background = muri.bg('hydro');
door = muri.door('hydro', [38, 9]);
};
hydro.onEnter = function() {
door.sprite.playAnimation('close');
}; };
hydro.update = function() { hydro.update = function() {
}; };
hydro.render = function() { hydro.render = function() {
background.render();
}; };
hydro.name = 'hydro'; hydro.name = 'hydro';

View file

@ -9,6 +9,10 @@
position: 1 position: 1
}; };
var r = function(a) {
return a[Math.floor(Math.random()*a.length)];
};
var createButtonEntity = function(i, room) { var createButtonEntity = function(i, room) {
var e = muri.get('entity') var e = muri.get('entity')
.create('lift.button'+i, .create('lift.button'+i,
@ -17,8 +21,17 @@
.addCallback(function() { .addCallback(function() {
buttons.forEach(function(b) { b.sprite.playAnimation('off'); }); buttons.forEach(function(b) { b.sprite.playAnimation('off'); });
muri.get('entity').get('lift.button'+i).sprite.playAnimation('on'); muri.get('entity').get('lift.button'+i).sprite.playAnimation('on');
muri.get('bubble').talk([room], [65, i*4+8]); var goMessage = r([
setTimeout(function() { muri.currentRoom = room; }, 1000); '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'); e.sprite.playAnimation('off');
return e; return e;
@ -34,18 +47,26 @@
} }
}); });
background = kontra.sprite({ background = muri.bg('lift');
x: 0, y: 0,
image: kontra.assets.images.room_lift});
buttons = [ buttons = [
createButtonEntity(0, 'engine'), // Engine room createButtonEntity(0, 'bridge'), // Bridge
createButtonEntity(1, 'stasis'), // Stasis createButtonEntity(1, 'hydro'), // Hydro Deck
createButtonEntity(2, 'hydro'), // Hydro Deck createButtonEntity(2, 'stasis'), // Stasis
createButtonEntity(3, 'bridge') // Bridge createButtonEntity(3, 'engine') // Engine room
]; ];
buttons[1].sprite.playAnimation('on'); 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.update = function() {};
lift.render = function() { lift.render = function() {

View file

@ -4,8 +4,7 @@
var stasis = {}; var stasis = {};
var background, backgroundDark = null; var background, backgroundDark = null;
var doorAnimationSheet = null; var door = null;
var doorSprite = null;
var roomState = { var roomState = {
isDoorOpen: false, isDoorOpen: false,
isLightOn: false, isLightOn: false,
@ -13,27 +12,12 @@
}; };
stasis.init = function() { 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'); background = muri.bg('stasis');
backgroundDark = muri.bg('stasis_dark'); backgroundDark = muri.bg('stasis_dark');
muri.get('entity') muri.get('entity')
.create('stasis.lightSwitch', .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})) image: kontra.assets.images.stasis_lightSwitch}))
.addCallback(function() { .addCallback(function() {
if (roomState.isIntroRunning) return; if (roomState.isIntroRunning) return;
@ -63,22 +47,13 @@
} }
}; };
stasis.onEnter = function(prevRoom) {
door.sprite.playAnimation('close');
};
stasis.update = function() { stasis.update = function() {
if (roomState.isLightOn && if (roomState.isLightOn && !door)
!muri.get('entity').get('stasis.door')) { door = muri.door('stasis', [76, 11]);
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;
}
});
}
}; };
stasis.render = function() { stasis.render = function() {