Explorar el Código

Added some random events to each area. Fixed a bug where timers could not stop themselves

tags/v0.1.0
Fen Dweller hace 6 años
padre
commit
9fe021ea4e
Se han modificado 4 ficheros con 77 adiciones y 7 borrados
  1. +9
    -4
      game.js
  2. +0
    -2
      satiate.css
  3. +67
    -0
      stories/fen-snack.js
  4. +1
    -1
      world.js

+ 9
- 4
game.js Ver fichero

@@ -87,11 +87,17 @@ function startTimer(config, state) {
if (config.loop) { if (config.loop) {
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
const result = config.func(state); const result = config.func(state);
state.timers = state.timers.filter(x => x.timeout != timeout);
refresh(); refresh();


if (result)
startTimer(config, state);
// the timer may have terminated itself!
// we have to make sure it still exists

if (state.timers.some(x => x.timeout == timeout)){
state.timers = state.timers.filter(x => x.timeout != timeout);
if (result)
startTimer(config, state);
}

}, config.delay); }, config.delay);


state.timers.push({id: config.id, timeout: timeout, room: config.room, classes: config.classes || []}); state.timers.push({id: config.id, timeout: timeout, room: config.room, classes: config.classes || []});
@@ -112,7 +118,6 @@ function stopRoomTimers(room, state) {
matches.forEach(timer => clearTimeout(timer.timeout)); matches.forEach(timer => clearTimeout(timer.timeout));


state.timers = state.timers.filter(timer => timer.room != room); state.timers = state.timers.filter(timer => timer.room != room);

} }


function stopClassTimers(timerClass, state, inverse) { function stopClassTimers(timerClass, state, inverse) {


+ 0
- 2
satiate.css Ver fichero

@@ -312,8 +312,6 @@ a:hover {
} }
} }




#moves { #moves {
padding: 25px; padding: 25px;
position: relative; position: relative;


+ 67
- 0
stories/fen-snack.js Ver fichero

@@ -98,9 +98,28 @@ stories.push({
}, },
enter: (room, state) => { enter: (room, state) => {
playLoop("loop/fen-stomach.ogg"); playLoop("loop/fen-stomach.ogg");

startTimer({
id: "stomach-churns",
func: state => {
if (Math.random() > 0.8) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
print(["The crux's stomach clenches around you, smothering you in the beast's slimy embrace."]);
}
return true;
},
delay: 10000,
loop: true,
room: "stomach",
classes: [
"alive"
]
}, state);
}, },
exit: (room, state) => { exit: (room, state) => {
stopLoop("loop/fen-stomach.ogg"); stopLoop("loop/fen-stomach.ogg");
stopRoomTimers("stomach", state);
}, },
hooks: [ hooks: [


@@ -171,9 +190,33 @@ stories.push({
}, },
enter: (room, state) => { enter: (room, state) => {
playLoop("loop/fen-intestines.ogg"); playLoop("loop/fen-intestines.ogg");

startTimer({
id: "intestines-churns",
func: state => {
if (Math.random() > 0.8) {
if (state.player.stats.stamina.value > 50) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
print(["Your prison's walls ripple and grind, shoving you against the valve leading to the crux's boiling stomach - but you manage to resist the powerful pull."]);
} else {
print(["Too exhausted to resist, your slimy body is crammed into the crux's churning stomach by a powerful wave of peristalsis."]);
goToRoom("stomach", state);
}
}
return true;
},
delay: 10000,
loop: true,
room: "intestines",
classes: [
"alive"
]
}, state);
}, },
exit: (room, state) => { exit: (room, state) => {
stopLoop("loop/fen-intestines.ogg"); stopLoop("loop/fen-intestines.ogg");
stopRoomTimers("intestines", state);
}, },
exits: { exits: {
"up": { "up": {
@@ -233,9 +276,33 @@ stories.push({
}, },
enter: (room, state) => { enter: (room, state) => {
playLoop("loop/fen-bowels.ogg"); playLoop("loop/fen-bowels.ogg");

startTimer({
id: "bowels-churns",
func: state => {
if (Math.random() > 0.8) {
if (state.player.stats.stamina.value > 50) {
state.player.stats.stamina.value -= 25;
state.player.stats.stamina.value = Math.max(0, state.player.stats.stamina.value);
print(["Fen's bowels clench and churn, grinding you into their musky walls."]);
} else {
state.player.stats.health.value /= 4;
print(["Drained of stamina, you can do little to resist as Fen's bowels grind you away."]);
}
}
return true;
},
delay: 10000,
loop: true,
room: "bowels",
classes: [
"alive"
]
}, state);
}, },
exit: (room, state) => { exit: (room, state) => {
stopLoop("loop/fen-bowels.ogg"); stopLoop("loop/fen-bowels.ogg");
stopRoomTimers("bowels", state);
}, },
exits: { exits: {
"up": { "up": {


+ 1
- 1
world.js Ver fichero

@@ -85,7 +85,7 @@ function goToRoom(dest, state) {
} }


if (from && from.exit) if (from && from.exit)
from.exit(state.world[dest], state);
from.exit(from, state);


if (room.enter) if (room.enter)
room.enter(state.world[dest], state); room.enter(state.world[dest], state);


Cargando…
Cancelar
Guardar