diff --git a/entity.js b/entity.js
new file mode 100644
index 0000000..e69de29
diff --git a/game.js b/game.js
new file mode 100644
index 0000000..cb38b85
--- /dev/null
+++ b/game.js
@@ -0,0 +1,26 @@
+function initGame(game, state) {
+ state.info = {};
+ state.info.time = 60 * 60 * 9;
+}
+
+// TODO: format string this lol
+function renderTime(time) {
+ let hours = Math.floor(time / 3600) % 12;
+ const ampm = Math.floor(time / 3600) % 24 < 12 ? "AM" : "PM";
+ let minutes = Math.floor(time / 60) % 60;
+ let seconds = time % 60;
+
+ if (minutes <= 9)
+ minutes = "0" + minutes;
+
+ if (seconds <= 9)
+ seconds = "0" + seconds;
+
+ return hours + ":" + minutes + ":" + seconds + " " + ampm;
+}
+
+function updateWorldInfo(state) {
+ const timeInfo = document.querySelector("#world-info-time");
+
+ timeInfo.textContent = "Time: " + renderTime(state.info.time);
+}
diff --git a/satiate.css b/satiate.css
index a55dbe9..0e46e30 100644
--- a/satiate.css
+++ b/satiate.css
@@ -36,6 +36,12 @@ html, body {
flex: 2;
}
+#world-info {
+ margin: 10px;
+ background: #222;
+ flex: 5;
+}
+
#self-info {
margin: 10px;
background: #222;
diff --git a/satiate.html b/satiate.html
index 907aa8d..5e3697f 100644
--- a/satiate.html
+++ b/satiate.html
@@ -6,6 +6,8 @@
Satiate
+
+
@@ -22,6 +24,10 @@
+
+ this is world info
+
Time to get a watch!
+
this is your own info
diff --git a/satiate.js b/satiate.js
index 701841d..fff45ec 100644
--- a/satiate.js
+++ b/satiate.js
@@ -28,11 +28,17 @@ function print(lines) {
log.scrollTop = log.scrollHeight;
}
+function refresh() {
+ updateRoom(state);
+ updateWorldInfo(state);
+}
+
// setup the game
function init() {
initWorld("demo", state);
initAudio("demo", state);
+ initGame("demo", state);
goToRoom("Home", state);
}
diff --git a/world.js b/world.js
index 47cb080..59bb76a 100644
--- a/world.js
+++ b/world.js
@@ -55,8 +55,9 @@ function moveToRoom(src, exit, dest, state) {
}
state.world[dest].move(state.world[dest], state);
+ state.player.location = dest;
- updateRoom(dest, state);
+ updateRoom(state);
}
function goToRoom(dest, state) {
@@ -70,14 +71,16 @@ function goToRoom(dest, state) {
}
}
- updateRoom(dest, state);
+ state.player.location = dest;
+ updateRoom(state);
}
-function updateRoom(dest, state) {
- const room = state.world[dest];
+function updateRoom(state) {
+ const name = state.player.location
+ const room = state.world[name];
- if (!state.player.rooms[dest.id]) {
- state.player.rooms[dest.id] = {};
+ if (!state.player.rooms[name.id]) {
+ state.player.rooms[name.id] = {};
}
const areaName = document.querySelector("#area-name");
@@ -160,7 +163,7 @@ function updateRoom(dest, state) {
button.addEventListener("click", () => {
action.execute(room, state);
- updateRoom(room.id, state);
+ refresh();
});
button.addEventListener("mouseenter", () => {