Explorar el Código

Added time and newlines

tags/v0.2.8
Fen Dweller hace 7 años
padre
commit
8ec779ed65
Se han modificado 2 ficheros con 21 adiciones y 3 borrados
  1. +1
    -0
      feast.html
  2. +20
    -3
      feast.js

+ 1
- 0
feast.html Ver fichero

@@ -22,6 +22,7 @@
Welcome to Feast v0.0.3
</div>
<div id="stats">
<div class="stat-line" id="time">Time: to get a watch</div>
<div class="stat-line" id="stat-name">Vim: 15</div>
<div class="stat-line" id="stat-health">Pulchritude: 44</div>
<div class="stat-line" id="stat-fullness">Imagination: 97</div>


+ 20
- 3
feast.js Ver fichero

@@ -3,6 +3,8 @@ let dirButtons = [];
let actionButtons = [];
let mode = "explore";
let actions = [];
let time = 9*60;
let newline = "&nbsp;";

let player = {
name: "Fen",
@@ -69,11 +71,27 @@ function updateDisplay() {
break;
}

document.getElementById("time").innerHTML = "Time: " + renderTime(time);
document.getElementById("stat-name").innerHTML = "Name: " + player.name;
document.getElementById("stat-health").innerHTML = "Health: " + player.health + "/" + player.maxHealth;
document.getElementById("stat-fullness").innerHTML = "Fullness: " + player.fullness + "/" + player.maxFullness;
}

function advanceTime(amount) {
time = (time + amount) % 1440;
}
function renderTime(time) {
let suffix = (time < 720) ? "AM" : "PM";
let hour = Math.floor((time % 720) / 60);
if (hour == 0)
hour = 12;
let minute = time % 60;
if (minute < 9)
minute = "0" + minute;

return hour + ":" + minute + " " + suffix;
}

function move(direction) {
let target = currentRoom.exits[direction];
if (target == null) {
@@ -87,6 +105,7 @@ function move(direction) {
function moveTo(room) {
actions = [];
currentRoom = room;
advanceTime(1);

currentRoom.objects.forEach(function (object) {
object.actions.forEach(function (action) {
@@ -94,9 +113,7 @@ function moveTo(room) {
})
})

update(["You move to " + currentRoom.name,currentRoom.description]);

updateDisplay();
update(["You move to " + currentRoom.name,currentRoom.description,newline]);
}

window.addEventListener('load', function(event) {


Cargando…
Cancelar
Guardar