Get Started:Create a Room
Creating a room uses exactly the same process as creating a player.
// game constructor block...
MyGame.createAsset({
class: "Room",
name: "Dungeon Antechamber",
description: "You're in a dingy dungeon antechamber. Every surface seems to be made of pitted cobblestones. ",
});
MyGame.createAsset({
class: "Player",
name: "Mighty Hero",
is: { active: true, },
place: { in: "Dungeon Antechamber" },
});
We included the player constructor again so you could take special note of this particular property that we're setting on the player:
place: { in: "Dungeon Antechamber" },
This is how to place things in Adventurejs. We'll get into specifics shortly, but it's worth noting that players are unique in that, if you don't set a place, their place will be set automatically to the first room available. Other assets, if not given a place, will exist in a limbo outside the game world, until moved somewhere.
Now we have a player and a room, but not much else. Let's add another room.
// game constructor block...
MyGame.createAsset({
class: "Room",
name: "Dungeon Antechamber",
description: "You're in a dingy dungeon antechamber. Every surface seems to be made of pitted cobblestones. ",
});
MyGame.createAsset({
class: "Player",
name: "Mighty Hero",
is: { active: true, },
place: { in: "Dungeon Antechamber" },
});
MyGame.createAsset({
class: "Room",
name: "Central Chamber",
description: "You're in the central chamber of the dungeon, a round room with a high stone ceiling. Paths in several directions are blocked by fallen stones. ",
});
Psych! If you tried to play that, you will have found yourself in the Dungeon Antechamber but with no way to reach the new room. What we need now are some exits!