Game Development Reference
In-Depth Information
ic = new ItemClient();
ic.setQuadrant(m_id);
ic.setIndex(m_itemId);
ic.setItemType(Item.BLACK_HOLE);
ic.setPosX(sx);
ic.setPosY(sy);
ic.setStateKey(item.getKey());
p.addGameState(ic);
m_itemId++;
item = new Item(m_id, m_itemId, Item.MUSHROOM);
sx = ((Math.random()*1000000)%RaceTrack.QUADRANT_
LENGTH)+800;
sy = (Math.random()*1000000)%600;
ic = new ItemClient();
ic.setQuadrant(m_id);
ic.setIndex(m_itemId);
ic.setItemType(Item.MUSHROOM);
ic.setPosX(sx);
ic.setPosY(sy);
ic.setStateKey(item.getKey());
p.addGameState(ic);
m_itemId++;
var a:Astroid = new Astroid(m_id, m_itemId);
sx = ((Math.random()*1000000)%RaceTrack.QUADRANT_
LENGTH)+800;
sy = (Math.random()*1000000)%600;
ic = new ItemClient();
ic.setQuadrant(m_id);
ic.setIndex(m_itemId);
ic.setItemType(Item.ASTROID);
ic.setPosX(sx);
ic.setPosY(sy);
ic.setStateKey(a.getKey());
p.addGameState(ic);
m_itemId++;
}
}
The items are created and added to the array ( m_objects ). The number of items
created in each quadrant is proportional to the ID of the quadrant. Notice the loop
runs as many times as the ID (plus 1) of the quadrant. This makes the quadrant with
a higher ID (towards the end of race) have more items or obstacles than the
quadrants in the initial part of the race.
 
Search WWH ::




Custom Search