Restructure the modules and finish implementing the bubbles
This commit is contained in:
parent
409ec35c23
commit
bb6d861712
6 changed files with 108 additions and 96 deletions
13
src/act1.js
Normal file
13
src/act1.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
(function() {
|
||||||
|
var act1 = {};
|
||||||
|
|
||||||
|
muri.get('bubble').talk(['Hi', 'I Think, this works ...', 'This looks kinda cool. I think , I can work with that to build a nice little adventure game with some clicky things.', 'Just need to find out a way to click on things.']);
|
||||||
|
|
||||||
|
act1.update = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
act1.render = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
muri.modules.push(act1);
|
||||||
|
}());
|
43
src/bubble.js
Normal file
43
src/bubble.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
(function() {
|
||||||
|
var bubble = {};
|
||||||
|
|
||||||
|
var isactive = false;
|
||||||
|
var show = function(text, position, callback) {
|
||||||
|
isactive = true;
|
||||||
|
|
||||||
|
var dom = document.getElementById('bubble');
|
||||||
|
dom.style.display = '';
|
||||||
|
dom.style.left = position[0]*8;
|
||||||
|
dom.style.top = position[1]*8;
|
||||||
|
dom.innerHTML = '';
|
||||||
|
|
||||||
|
parts = text.split(' ');
|
||||||
|
var show = function() {
|
||||||
|
if (parts.length === 0) {
|
||||||
|
setTimeout(function() {
|
||||||
|
isactive = false;
|
||||||
|
dom.style.display = 'none';
|
||||||
|
callback.call();
|
||||||
|
}, 4000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dom.innerHTML += parts.shift() + ' ';
|
||||||
|
setTimeout(show, 150);
|
||||||
|
};
|
||||||
|
show();
|
||||||
|
};
|
||||||
|
|
||||||
|
bubble.talk = function(texts, position, callback) {
|
||||||
|
if (texts.length === 0) {
|
||||||
|
if (callback !== undefined) callback.call();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var text = texts.shift();
|
||||||
|
show(text, position || [5, 40], function() {
|
||||||
|
bubble.talk(texts, position);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
bubble.name = 'bubble';
|
||||||
|
muri.modules.push(bubble);
|
||||||
|
}());
|
|
@ -1,38 +0,0 @@
|
||||||
// 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();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//};
|
|
|
@ -13,3 +13,5 @@
|
||||||
|
|
||||||
<script src="vendor/kontra.js"></script>
|
<script src="vendor/kontra.js"></script>
|
||||||
<script src="muri.js"></script>
|
<script src="muri.js"></script>
|
||||||
|
<script src="bubble.js"></script>
|
||||||
|
<script src="act1.js"></script>
|
||||||
|
|
56
src/main.js
56
src/main.js
|
@ -1,56 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// Plot: You are in the dark, and you have no clue where you are
|
|
||||||
// and what happened. You wake up in completely dark and stumble
|
|
||||||
// around. You explore the area and you find out you are on a
|
|
||||||
// old space ship. You need to find out whats going on here and
|
|
||||||
// why you are here. After finding and combining some items, you
|
|
||||||
// find out that your stasis capsule had some malfunctioning and
|
|
||||||
// you are the only one on this mission. But what mission? And
|
|
||||||
// where are your crew members? Where are you? You are drifting
|
|
||||||
// along, lost in space with no hope of rescue. But you want to
|
|
||||||
// surrender.
|
|
||||||
// You find out that you are the only surrender on an ancient
|
|
||||||
// space ship, carring cargo from one place to another when
|
|
||||||
// space pirates killed the crew except you. You want to fly
|
|
||||||
// home, but you need to bring the ship back to life.
|
|
||||||
|
|
||||||
// Ship:
|
|
||||||
// Statis capsule room
|
|
||||||
// Cargo room
|
|
||||||
// Command station
|
|
||||||
// Crew quarters
|
|
||||||
// Machine/Engine room
|
|
||||||
|
|
||||||
// Act 1: No light at all. Only player. Can walk. If the player
|
|
||||||
// hit a wall (he stands in a corridor), he can switch on the light.
|
|
||||||
// He sees the room and the stasis capsule. Explore the room,
|
|
||||||
// find out more details about your current situation (statis
|
|
||||||
// no one is here, ship don't move, warning signs everywhere).
|
|
||||||
|
|
||||||
// Act 2: Open the pressure door, find a space suite, get a map
|
|
||||||
// fix a leak in the ship.
|
|
||||||
|
|
||||||
// Act 3: Go into the command station, find out more on the
|
|
||||||
// terminals, fix some things by exploring the rest of the ship.
|
|
||||||
|
|
||||||
// Act 4: Bring the ship back to operation, find the way home,
|
|
||||||
// end.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: draw the different rooms
|
|
||||||
// TODO: Put it on the screen, "player" movement (mouse is the player)
|
|
||||||
// TODO: "speech bubbles" for text
|
|
||||||
// TODO: Item store
|
|
||||||
|
|
||||||
// (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]);
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// }());
|
|
52
src/muri.js
52
src/muri.js
|
@ -1,4 +1,43 @@
|
||||||
|
// Plot: You are in the dark, and you have no clue where you are
|
||||||
|
// and what happened. You wake up in completely dark and stumble
|
||||||
|
// around. You explore the area and you find out you are on a
|
||||||
|
// old space ship. You need to find out whats going on here and
|
||||||
|
// why you are here. After finding and combining some items, you
|
||||||
|
// find out that your stasis capsule had some malfunctioning and
|
||||||
|
// you are the only one on this mission. But what mission? And
|
||||||
|
// where are your crew members? Where are you? You are drifting
|
||||||
|
// along, lost in space with no hope of rescue. But you want to
|
||||||
|
// surrender.
|
||||||
|
// You find out that you are the only surrender on an ancient
|
||||||
|
// space ship, carring cargo from one place to another when
|
||||||
|
// space pirates killed the crew except you. You want to fly
|
||||||
|
// home, but you need to bring the ship back to life.
|
||||||
|
|
||||||
|
// Ship:
|
||||||
|
// Statis capsule room
|
||||||
|
// Cargo room
|
||||||
|
// Command station
|
||||||
|
// Crew quarters
|
||||||
|
// Machine/Engine room
|
||||||
|
|
||||||
|
// Act 1: No light at all. Only player. Can walk. If the player
|
||||||
|
// hit a wall (he stands in a corridor), he can switch on the light.
|
||||||
|
// He sees the room and the stasis capsule. Explore the room,
|
||||||
|
// find out more details about your current situation (statis
|
||||||
|
// no one is here, ship don't move, warning signs everywhere).
|
||||||
|
|
||||||
|
// Act 2: Open the pressure door, find a space suite, get a map
|
||||||
|
// fix a leak in the ship.
|
||||||
|
|
||||||
|
// Act 3: Go into the command station, find out more on the
|
||||||
|
// terminals, fix some things by exploring the rest of the ship.
|
||||||
|
|
||||||
|
// Act 4: Bring the ship back to operation, find the way home,
|
||||||
|
// end.
|
||||||
|
|
||||||
var muri = (function() {
|
var muri = (function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
kontra.init('js13k-2017');
|
kontra.init('js13k-2017');
|
||||||
kontra.assets.imagePath = 'assets/images';
|
kontra.assets.imagePath = 'assets/images';
|
||||||
|
|
||||||
|
@ -11,6 +50,11 @@ var muri = (function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
muri.modules = [];
|
muri.modules = [];
|
||||||
|
muri.get = function(moduleName) {
|
||||||
|
for (var i in muri.modules)
|
||||||
|
if (muri.modules[i].name === moduleName)
|
||||||
|
return muri.modules[i];
|
||||||
|
};
|
||||||
|
|
||||||
muri.start = function() {
|
muri.start = function() {
|
||||||
kontra.assets.load(
|
kontra.assets.load(
|
||||||
|
@ -31,12 +75,16 @@ var muri = (function() {
|
||||||
update: function() {
|
update: function() {
|
||||||
var currentRoom = kontra.store.get('current-room');
|
var currentRoom = kontra.store.get('current-room');
|
||||||
rooms[currentRoom].update();
|
rooms[currentRoom].update();
|
||||||
for (m in muri.modules) m.update();
|
muri.modules.forEach(function(m) {
|
||||||
|
if (m.update !== undefined) m.update();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var currentRoom = kontra.store.get('current-room');
|
var currentRoom = kontra.store.get('current-room');
|
||||||
rooms[currentRoom].render();
|
rooms[currentRoom].render();
|
||||||
for (m in muri.modules) m.render();
|
muri.modules.forEach(function(m) {
|
||||||
|
if (m.render !== undefined) m.render();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue