Przeglądaj źródła

Rooms have separate exit/enter functions as well as the one for moving in.

tags/v0.1.0
Fen Dweller 6 lat temu
rodzic
commit
e574c7fb9f
4 zmienionych plików z 34 dodań i 7 usunięć
  1. +1
    -0
      satiate.html
  2. +6
    -0
      stories/demo.js
  3. +7
    -3
      stories/fen-snack.js
  4. +20
    -4
      world.js

+ 1
- 0
satiate.html Wyświetl plik

@@ -26,6 +26,7 @@
<a href="https://discord.gg/dSwNN8T">Discord Server</a>
<p class="version">Version: </p>
<p><b>This game contains 18+ content</b></p>
<p><b>Most of the games have sound!</b></p>
<p>Select a story:</p>
</div>
<div>


+ 6
- 0
stories/demo.js Wyświetl plik

@@ -15,6 +15,12 @@ stories.push({
"move": (room, state) => {
print(["You go back to your living room"]);
},
"enter": (room, state) => {
print(["*sound of you entering your house*"]);
},
"exit": (room, state) => {
print(["You are exiting your house"]);
},
"actions": [
{
"name": "Squint",


+ 7
- 3
stories/fen-snack.js Wyświetl plik

@@ -17,10 +17,14 @@ stories.push({
move: (room, state) => {
print(["You slide into Fen's humid stomach."]);
},
enter: (room, state) => {
playLoop("loop/fen-stomach.ogg");
},
exit: (room, state) => {
stopLoop("loop/fen-stomach.ogg");
},
hooks: [
(room, state) => {
playLoop("loop/fen-stomach.ogg");
}

]
}
}


+ 20
- 4
world.js Wyświetl plik

@@ -36,6 +36,7 @@ function removeActionDescription() {
}

function moveToRoom(src, exit, dest, state) {
const from = state.world[state.player.location];
const room = state.world[dest];

if (exit.hooks) {
@@ -54,13 +55,22 @@ function moveToRoom(src, exit, dest, state) {
}
}

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

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

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

state.player.location = dest;

refresh();
}

function goToRoom(dest, state) {
const from = state.world[state.player.location];
const room = state.world[dest];

if (room.hooks) {
@@ -71,17 +81,23 @@ function goToRoom(dest, state) {
}
}

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

state.player.location = dest;

refresh();
}

function updateRoom(state) {
const name = state.player.location
const name = state.player.location;
const room = state.world[name];

if (!state.player.rooms[name.id]) {
state.player.rooms[name.id] = {};
if (!state.player.rooms[room.id]) {
state.player.rooms[room.id] = {};
}

const areaName = document.querySelector("#area-name");


Ładowanie…
Anuluj
Zapisz