Game Development Reference
In-Depth Information
￿ : An interface that will be implemented by the player
￿ : The interface required by any object acting as a
hazard in the engine.
￿ : Any object that will be treated as a wall by the engine
will need to implement this interface.
final public class LabyrinthEngine extends Sprite
static public var MAX_BALL_SPEED:Number = 150;
static public var ACCELERATION_MULTIPLIER:Number = 80;
static private const DISTANCE_TO_ENDPOINT:Number = 10;
private var _currentLevel:LabyrinthLevel;
private var _ball:IBall;
private var _ballDO:DisplayObject;
private var _levelEndCallback:Function;
private var _accelerometer:Accelerometer;
private var _ax:Number = 0;
private var _ay:Number = 0;
private var _previousTime:int;
There are relatively few member variables in this class: one to
store the current level, two for the ball (one that uses IBall and the
other that casts it as a DisplayObject for convenience later), a call-
back for when the level is complete (meaning the player success-
fully moved the ball to a designated endpoint), and a few to store
the Accelerometer instance and its acceleration values. Also
included are a couple of static variables that can be used to alter
general properties of the engine.
public function LabyrinthEngine(ballClass:Class,levelClass:
_ball = new ballClass();
_ballDO = DisplayObject(_ball);
_currentLevel = new levelClass();
var validationError:Error = _currentLevel.validate();
if (validationError) throw validationError;
Search Nedrilad ::

Custom Search