Try to add a avatar .... not sure if this is possible

This commit is contained in:
Aaron Fischer 2017-08-15 17:04:39 +02:00
parent ec51e904d5
commit 1412d7dc78
3 changed files with 39 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

View file

@ -50,14 +50,15 @@
kontra.assets.load( kontra.assets.load(
'room_stasis_dark.png', 'room_stasis_dark.png',
'room_stasis.png' 'room_stasis.png',
'player.png'
).then(function() { ).then(function() {
document.getElementById('loading').style.display = 'none'; document.getElementById('loading').style.display = 'none';
if (kontra.store.get('current-room') === null) if (kontra.store.get('current-room') === null)
kontra.store.set('current-room', 'stasis_dark'); kontra.store.set('current-room', 'stasis_dark');
muri.talk([ muri.bubble.talk([
'Uh ...', 'Uh ...',
'Where I am? ...', 'Where I am? ...',
'It is so dark in here, I can\'t even see my bare hands. I can\'t remember a thing and my brain hurts so bad. What happened here?' 'It is so dark in here, I can\'t even see my bare hands. I can\'t remember a thing and my brain hurts so bad. What happened here?'
@ -76,9 +77,11 @@
render: function() { render: function() {
var currentRoom = kontra.store.get('current-room'); var currentRoom = kontra.store.get('current-room');
rooms[currentRoom].render(); rooms[currentRoom].render();
muri.bubble.render();
} }
}); });
muri.init();
loop.start(); loop.start();
}); });
})(); })();

View file

@ -1,22 +1,39 @@
var muri = { var muri = {
bubble: function(text, position=[2, 7], delay=3, callback=false) { init: function() {
var bubble = document.getElementById('bubble'); muri.bubble.playerSprite = kontra.sprite({x: 0, y: 0, image: kontra.assets.images.player })
bubble.style.display = '';
bubble.style.left = position[0]*8;
bubble.style.top = position[1]*8;
bubble.innerHTML = text;
setTimeout(function() {
bubble.style.display = 'none';
if (callback !== false) callback.call();
}, delay*1000);
}, },
talk: function(texts, position) { bubble: {
if (texts.length === 0) return; isActive: false,
var text = texts.shift(); playerSprite: false,
var delay = Math.ceil(text.length/13);
this.bubble(text, position, delay, function() { show: function(text, position=[2, 7], delay=3, callback=false) {
muri.talk(texts, position); muri.bubble.isActive = true;
}); var bubble = document.getElementById('bubble');
bubble.style.display = '';
bubble.style.left = position[0]*8;
bubble.style.top = position[1]*8;
bubble.innerHTML = text;
setTimeout(function() {
muri.bubble.isActive = false;
bubble.style.display = 'none';
if (callback !== false) callback.call();
}, delay*1000);
},
talk: function(texts, position) {
if (texts.length === 0) return;
var text = texts.shift();
var delay = Math.ceil(text.length/13);
muri.bubble.show(text, position, delay, function() {
muri.bubble.talk(texts, position);
});
},
render: function() {
if (muri.bubble.isActive) {
muri.bubble.playerSprite.render();
}
}
} }
}; };