Game Development Reference
In-Depth Information
Creating the Game and Level Data
The GameData object will hold values that pertain to the game as a whole, including the game's current level, the cost
and power of magic items, and most importantly, the level data. This is an array of objects what will be used to build
each level. The attributes that make up a level are as follows:
type : Can be 'field' or 'boss' . Used to determine if the battle should load multiple enemies,
or one boss.
enemies : An array of string keys. Used to instantiate the enemy objects in a battle.
boss : The string key for the boss enemy.
enemyStreak : The number of consecutive enemy attacks when an enemy attack commences.
enemyAttackWait : The duration between enemy attack streaks.
powerIncreaseAwarded : The amount that the player's power will increase by when beating the
level.
defenseIncreaseAwarded : The amount that the player's defense will increase by when beating
the level.
HPEarned : The amount that the player's max hit points will increase by when beating the level.
coinsAwarded : The amount of coins the player receives when beating the level.
Listing 14-7 shows this level data within the entire GameData object.
Listing 14-7. data.js - The GameData Object Declares the Level Data
GameData = {
currentLevel:1
}
GameData.levelData = [
{
type:'field',
enemies:['troll1', 'troll1', 'troll1'],
enemyStreak:1,
enemyAttackWait:5000,
powerIncreaseAwarded:1,
defenseIncreaseAwarded:0,
coinsAwarded:3,
HPEarned:1
},
{
type:'field',
enemies:['troll1', 'sorcerer1', 'troll1', 'troll1',
'sorcerer1', 'troll1'],
enemyStreak:2,
enemyAttackWait:5000,
powerIncreaseAwarded:2,
defenseIncreaseAwarded:1,
coinsAwarded:4,
HPEarned:3
},
 
Search WWH ::




Custom Search