Game Development Reference
In-Depth Information
//or faster than the player ship
//add xMove to dx and dy so the missiles fire faster if ship is moving faster
nextX+=(dx*(speed+Math.abs(xAdjust)))*step;
nextY+=(dy*(speed+Math.abs(yAdjust)))*step;
if (nextX > xMax || nextX < xMin || nextY > yMax || nextY < yMin) {
return(true)
}else {
return(false);
}
}
}
}
Designing the BlitArrayPlayerFollowMouse class
The BlitArrayPlayerFollowMouse class is the most complicated subclass of the
BasicBlitArrayObject class. It contains some very specific code for the Blaster Mines game, so
it will be part of the Blaster Mines game package rather than the framework package.
BlitArrayPlayerFollowMouse relies on a calculated offset passed in to the update function to
move the player in the correct direction and speed to follow the mouse. The current mouse
position will be passed into the update function along with a delay value that is used to slow the
speed of the player ship so it doesn't just attach itself directly to the mouse pointer. This provides
a little more realistic movement for the ship.
Using the mouse for control and allowing automatic firing of missiles is a relatively new and mostly
Flash-based control mechanism. It is also a good one to employ when targeting any handheld
touch-screen devices that might have a Flash Player capable of running game applications.
The package location is com.efg.games.blastermines .
These are the public attributes:
public var xMove:int : The calculated new change in x based on the mouse position
public var yMove:int : The calculated new change in y based on the mouse position
public var shipBitmapData:BitmapData : Holds the BitmapData version of the
drawingCanvas for the player ship
public var shieldBitmapData:BitmapData : Holds the BitmapData version of the ship's
shield
public var shieldRender:Boolean : Tells the render function to display the shield
around the player ship if the player's ship is hit by a Mine instance
public var shieldCount:int : Counts from 0 to the shieldLife frame ticks before
setting shieldRender to false so the shield will stay engaged for the shieldLife value
public var shieldLife:int : The number of frame ticks for the shield to be active when
the player is hit by a Mine
Search WWH ::




Custom Search