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');
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);

View file

@ -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'

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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() {

View file

@ -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() {