js13kgames2017-muri/src/room_engine.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-09-12 17:06:21 +02:00
(function() {
'use strict';
var engine = {};
2017-09-12 22:40:34 +02:00
var background, door = null;
2017-09-12 17:06:21 +02:00
var roomState = {
2017-09-12 23:52:00 +02:00
firstVisit: true,
engineBroken: true
};
var randomSounds = function() {
var sound = muri.ra(['Brrz ...', 'EeeeKK!', 'Rrrrrm deng', 'Ponk, Ponk, Deng.', 'Uffz', 'Pok, Pok, Pok, ...']);
var position = [
30+Math.floor(Math.random()*50),
12+Math.floor(Math.random()*20)
];
muri.get('bubble')
.talk([sound], position)
.then(function() {
if (roomState.engineBroken &&
muri.currentRoom === 'engine')
randomSounds();
});
2017-09-12 17:06:21 +02:00
};
engine.init = function() {
2017-09-12 22:40:34 +02:00
background = muri.bg('engine');
door = muri.door('engine', [8, 10]);
};
engine.onEnter = function() {
door.sprite.playAnimation('close');
2017-09-12 23:52:00 +02:00
if (roomState.firstVisit) {
roomState.firstVisit = false;
muri.get('bubble')
.talk([
'It smells like molted plastic and burned metal in here.',
'Something is broken here for sure.',
'I\'m afraid that I need to fix this mess somehow ...'
]);
}
if (roomState.engineBroken)
randomSounds();
2017-09-12 17:06:21 +02:00
};
engine.update = function() {
};
engine.render = function() {
2017-09-12 22:40:34 +02:00
background.render();
2017-09-12 17:06:21 +02:00
};
engine.name = 'engine';
muri.rooms.push(engine);
}());