Procházet zdrojové kódy

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

tags/v0.1.0
Fen Dweller před 6 roky
rodič
revize
9fe021ea4e
4 změnil soubory, kde provedl 77 přidání a 7 odebrání
  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 Zobrazit soubor

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

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));

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

}

function stopClassTimers(timerClass, state, inverse) {


+ 0
- 2
satiate.css Zobrazit soubor

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



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


+ 67
- 0
stories/fen-snack.js Zobrazit soubor

@@ -98,9 +98,28 @@ stories.push({
},
enter: (room, state) => {
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) => {
stopLoop("loop/fen-stomach.ogg");
stopRoomTimers("stomach", state);
},
hooks: [

@@ -171,9 +190,33 @@ stories.push({
},
enter: (room, state) => {
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) => {
stopLoop("loop/fen-intestines.ogg");
stopRoomTimers("intestines", state);
},
exits: {
"up": {
@@ -233,9 +276,33 @@ stories.push({
},
enter: (room, state) => {
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) => {
stopLoop("loop/fen-bowels.ogg");
stopRoomTimers("bowels", state);
},
exits: {
"up": {


+ 1
- 1
world.js Zobrazit soubor

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

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

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


Načítá se…
Zrušit
Uložit