Try to add a avatar .... not sure if this is possible
This commit is contained in:
parent
ec51e904d5
commit
1412d7dc78
3 changed files with 39 additions and 19 deletions
BIN
src/assets/images/player.png
Normal file
BIN
src/assets/images/player.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
|
@ -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();
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
23
src/muri.js
23
src/muri.js
|
@ -1,11 +1,21 @@
|
||||||
var muri = {
|
var muri = {
|
||||||
bubble: function(text, position=[2, 7], delay=3, callback=false) {
|
init: function() {
|
||||||
|
muri.bubble.playerSprite = kontra.sprite({x: 0, y: 0, image: kontra.assets.images.player })
|
||||||
|
},
|
||||||
|
|
||||||
|
bubble: {
|
||||||
|
isActive: false,
|
||||||
|
playerSprite: false,
|
||||||
|
|
||||||
|
show: function(text, position=[2, 7], delay=3, callback=false) {
|
||||||
|
muri.bubble.isActive = true;
|
||||||
var bubble = document.getElementById('bubble');
|
var bubble = document.getElementById('bubble');
|
||||||
bubble.style.display = '';
|
bubble.style.display = '';
|
||||||
bubble.style.left = position[0]*8;
|
bubble.style.left = position[0]*8;
|
||||||
bubble.style.top = position[1]*8;
|
bubble.style.top = position[1]*8;
|
||||||
bubble.innerHTML = text;
|
bubble.innerHTML = text;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
muri.bubble.isActive = false;
|
||||||
bubble.style.display = 'none';
|
bubble.style.display = 'none';
|
||||||
if (callback !== false) callback.call();
|
if (callback !== false) callback.call();
|
||||||
}, delay*1000);
|
}, delay*1000);
|
||||||
|
@ -15,8 +25,15 @@ var muri = {
|
||||||
if (texts.length === 0) return;
|
if (texts.length === 0) return;
|
||||||
var text = texts.shift();
|
var text = texts.shift();
|
||||||
var delay = Math.ceil(text.length/13);
|
var delay = Math.ceil(text.length/13);
|
||||||
this.bubble(text, position, delay, function() {
|
muri.bubble.show(text, position, delay, function() {
|
||||||
muri.talk(texts, position);
|
muri.bubble.talk(texts, position);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
if (muri.bubble.isActive) {
|
||||||
|
muri.bubble.playerSprite.render();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue