Skip to content
Riemann edited this page Nov 20, 2013 · 9 revisions

The class that defines the tank, the player class. Contains many fields and methods important to the functioning of the program, so see source code for complete understanding.

Select Important Fields:

  • pos Position of top left of tank
  • shots ArrayList of available shots
  • image The picture that represents the tank
  • xRange The range that the tank covers in the x dimension
  • yRange The range that the tank covers in the y dimension
  • movementLimit Max number of cycles a player can move
  • isMoving,isFalling,isShooting State indicators stored as boolean
  • isTurn A flag that indicates if it is this tanks turn

Updates and Render

Tank takes care of updates for all its shots aswell as the tank. Shot also sends back when the shot is dead and initiates a turn switch. There are several different states for tank, all shown in the source code in update().

-setFirstPos()

This takes the position and puts it right on top of land at the previous x. Automatically called when tank info set.

-onTurnSwitch()

Gets a tank ready for its turn. Resets movement limits among other things.

-move()

Takes in input and moves the tank accordingly, working with movePos(). All that needs to be called to handle movement.

###-checkcollision() Used by several other methods to check if a collision has happened. Uses pixel operations to check the area within the xRange and yRange. Returns true if any pixels collide or if tank hits edge of screen.

Tanks

   

Created by Adam, Zach H. and Ben Riemann See: Source

Clone this wiki locally