Menu

Game World

Krishnakumar Muraleedharan

Game World Home

A game is a represented by the game world and the state variables which represent the player characteristics ( current scene, current set of events, number of turns, health etc)​

A gameworld is defined as a set of javascript variables and objects in gameworld.js file. To create a new game, you just have to create a new gameworld.js file.

Understanding gameworld.js file structure
A gameworld.js file contains the following variables.

scenes //Set of scenes in the game
objects//The items(or objects) in the game that the player can interact with
events// Events that can happen in the game
doors//Doors to other rooms or scenes
// Below ones are game state variables
locat//holds the reference to current scene the player is in
evnt//is the list of currently occuring events. The gameworld behaves differently to each event as defined
health//holds the health information of the player. Can be configured to display health as levels rather than numbers
inventory//is the list of identifiers of objects that the player is carrying now

Scene
A gameworld is defined as a collection of scenes. Each scene has objects which the player can interact with, and exits which leads the player to another scene. A scene has a behaviour for an event ( adds or deletes objects, exits, NPCs, starts or ends events etc).

Data Format

scenes = array of scene

scene = {
id : string //scene identifier
title : string //title to be displayed
description : string//description of the room
events : array of behaviour //behaviour to each event
exits : array of string //could be scene identifiers or door identifiers
objects : array of string // strings, object identifiers
}

behaviour = {
id : string // id of the event
msg : string // Message to be shown in response to the event
code : array of string // script to be executed in response to the event
}

Event
An event is a flag which signals that a particular thing has happened or has begun. Each scene can behave differently to a particular event. There can be more than one event happening at a time.

Data Format

events = array of event
event = { id : string // event identifier
defaultMsg : string // Default message to be displayed when a scene specific message is not defined
}

Object
An object is an item in a scene with which the player can interact. The object can also be used in combination with another object in the player's inventory.

Data Format

objects = array of object
object = {
id : string // object identifier
title: string // short description for displaying
in inventory list etc

msg: string// long description for display in scene
workswith : array of interaction // defines how this object interacts with another object
code: array of string // script to be executed when player picks up object
type: array of ObjType // classification of objects
}
interaction = {
id : string // id of the interacting object
msg : string // message to be shown in response to the interaction
code : array of string // script to be executed on interaction
}

ObjType datatype is defined in badengine.js ( core library). It can have the following values
KEY : 1
PROP : 2
WEAPON :3
FLAG : 4
CONTAINER : 5
CANNOT_CARRY : 6
LOCK : 7

Doors ( soon might get deprecated)

Doors are special objects which connects two scenes. They can be closed and locked. A door can be specified as an exit in a scene. But it has to opened ( maybe after unlocking with a designated key) before the player can use that exit. Opening a door connects the scenes mentioned in the door object.

Data Format

doors = array of door

door = {
id : string// door identifier
connects : array of string // list of scenes( or doors) this door connects
status : integer // 0 - Open, 1- Closed,2- Locked
key : array of string // list of object identifiers which can be used as a key for this door
}

Health
Health object is has three main fields - maximum health value, current health value and the labels representing the different health levels of the player (this is an optional field).

health = {
current : integer,
max : integer,
labels : array of string // Starting from the lowest to highest life levels each string can represent the current state of the player
}

Back to Home