Rearrange everything

This commit is contained in:
Aaron Fischer 2017-08-18 16:02:53 +02:00
parent 93ee76d622
commit 4ef0441c7d
4 changed files with 86 additions and 97 deletions

View file

@ -1 +1,38 @@
var muri
// 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');
// 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();
// }
// }
// }
//};

View file

@ -13,4 +13,3 @@
<script src="vendor/kontra.js"></script>
<script src="muri.js"></script>
<script src="main.js"></script>

View file

@ -44,44 +44,13 @@
// TODO: "speech bubbles" for text
// TODO: Item store
(function() {
kontra.init('js13k-2017');
kontra.assets.imagePath = 'assets/images';
kontra.assets.load(
'room_stasis_dark.png',
'room_stasis.png',
'player.png'
).then(function() {
document.getElementById('loading').style.display = 'none';
if (kontra.store.get('current-room') === null)
kontra.store.set('current-room', 'stasis_dark');
muri.bubble.talk([
'Uh ...',
'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?'
], [40, 20]);
var rooms = {
stasis_dark: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis_dark}),
stasis: kontra.sprite({x: 0, y: 0, image: kontra.assets.images.room_stasis})
};
var loop = kontra.gameLoop({
update: function() {
var currentRoom = kontra.store.get('current-room');
rooms[currentRoom].update();
},
render: function() {
var currentRoom = kontra.store.get('current-room');
rooms[currentRoom].render();
muri.bubble.render();
}
});
muri.init();
loop.start();
});
}());
// (function() {
//
// muri.bubble.talk([
// 'Uh ...',
// '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?'
// ], [40, 20]);
//
// });
// }());

View file

@ -1,64 +1,48 @@
this.muri = {
init: function(kontra) {
var muri = (function() {
kontra.init('js13k-2017');
kontra.assets.imagePath = 'assets/images';
var muri = {};
var bg = function(room) {
return kontra.sprite({
x: 0, y: 0,
image: kontra.assets.images['room_'+room]
});
};
muri.modules = [];
muri.start = function() {
kontra.assets.load(
'player.png',
'room_stasis_dark.png',
'room_stasis.png'
).then(function() {
document.getElementById('loading').style.display = 'none';
if (kontra.store.get('current-room') === null)
kontra.store.set('current-room', 'stasis_dark');
});
}
var rooms = {
stasis_dark: bg('stasis_dark'),
stasis: bg('stasis')
};
(function(m) {
var bubble = {};
bubble.show = function() {
};
m.bubble = bubble;
return bubble;
}(muri || {}));
init: function() {
muri.bubble.playerSprite = kontra.sprite({x: 0, y: 0, image: kontra.assets.images.player })
kontra.gameLoop({
update: function() {
var currentRoom = kontra.store.get('current-room');
rooms[currentRoom].update();
for (m in muri.modules) m.update();
},
bubble: {
isActive: false,
playerSprite: false,
show: function(text, position=[2, 7], delay=3, callback=false) {
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();
}
}
var currentRoom = kontra.store.get('current-room');
rooms[currentRoom].render();
for (m in muri.modules) m.render();
}
}).start();
});
};
return muri;
}());
window.onload = muri.start;