Parcourir la source

Added a Wilderness area to get lost in

tags/v0.2.8
Fen Dweller il y a 8 ans
Parent
révision
5ee984bcf3
3 fichiers modifiés avec 43 ajouts et 4 suppressions
  1. +7
    -1
      feast.js
  2. +20
    -0
      objects.js
  3. +16
    -3
      world.js

+ 7
- 1
feast.js Voir le fichier

@@ -1,3 +1,4 @@
let world = null;


let currentRoom = null; let currentRoom = null;
let currentDialog = null; let currentDialog = null;
@@ -251,6 +252,10 @@ function move(direction) {
moveTo(target,currentRoom.exitDescs[direction]); moveTo(target,currentRoom.exitDescs[direction]);
} }


function moveToByName(roomName, desc="You go places lol") {
moveTo(world[roomName], desc);
}

function moveTo(room,desc="You go places lol") { function moveTo(room,desc="You go places lol") {
actions = []; actions = [];
currentRoom = room; currentRoom = room;
@@ -279,7 +284,8 @@ function start() {
loadActions(); loadActions();
loadCompass(); loadCompass();
loadDialog(); loadDialog();
currentRoom = createWorld();
world = createWorld();
currentRoom = world["Bedroom"];
respawnRoom = currentRoom; respawnRoom = currentRoom;
moveTo(currentRoom); moveTo(currentRoom);
updateDisplay(); updateDisplay();


+ 20
- 0
objects.js Voir le fichier

@@ -125,3 +125,23 @@ function VendingMachine() {
} }
}); });
} }

function WildernessExplore(natureTrail) {
GameObject.call(this, "Explore the Wilderness");

this.actions.push({
"name": "Explore",
"action": function() {
let outcome = Math.random();
advanceTime(60*15);

if (outcome < 0.25) {
moveToByName("Nature Trail", "You find your way back");
} else if (outcome < 0.5) {
startCombat(new Anthro());
} else {
update(["You wander around for a bit, but haven't found anything."]);
}
}
});
}

+ 16
- 3
world.js Voir le fichier

@@ -12,8 +12,6 @@ let SOUTH_WEST = 5;
let WEST = 6; let WEST = 6;
let NORTH_WEST = 7; let NORTH_WEST = 7;


let startLocation = "Bedroom";

let locations = {}; let locations = {};


let locationsSrc = [ let locationsSrc = [
@@ -190,6 +188,11 @@ let locationsSrc = [
"name": "South Street", "name": "South Street",
"dir": NORTH, "dir": NORTH,
"desc": "You return to town." "desc": "You return to town."
},
{
"name": "Wilderness",
"dir": SOUTH,
"desc": "You wander into the wilderness...and immediately get lost."
} }
], ],
"objs": [ "objs": [
@@ -197,6 +200,16 @@ let locationsSrc = [
GetaObj GetaObj
] ]
}, },
{
"name": "Wilderness",
"desc": "Pretty spooky",
"conn": [

],
"objs": [
WildernessExplore
]
},
{ {
"name": "DANGER ZONE", "name": "DANGER ZONE",
"desc": "THE DANGER ZONE", "desc": "THE DANGER ZONE",
@@ -313,5 +326,5 @@ function createWorld() {
} }
} }


return locations[startLocation];
return locations;
} }

Chargement…
Annuler
Enregistrer