-
Notifications
You must be signed in to change notification settings - Fork 0
Shot
Shot is the abstract class that all shots in the game should inherent from. It contains fields and methods for initializing and maintaining shots. Important Fields:
- pos The position of the shot
-
areaOfEffect The area the
onCollisionEffect()
will effect. Uses a Slick2d Shape - shotName The string to identify what the shot represents.
- damage The int that specifies how much damage the shot will make if it collides with a tank.
One of the more important parts of the shot class is the three boolean variables isAlive
isShot
and isAnimating
. These booleans dictate the state of the shot. A shot has 4 states: alive and not shot, alive and shot, animating, and dead. these 4 states can be represented by the three boolean variables. One major todo for this class is to create an easier way to transition between these states. This will likely be done with an enumeration of states and a method call.
Being an abstract class, Shot has several abstract methods. Currently, these include onCollisionEffect()
update()
render()
and finished()
. onCollisionEffect()
should be called when the shot is ready to use its effect. update()
and render()
should be called from the state update/render loop and should implement whatever is needed to update position and state of the shot and to display it. Lastly, finished()
should implement whatever is needed to be called upon death. This currently includes setting the Tanks state to falling.
Finally, while not abstract, the init()
method should be called to set position upon firing and overridden to include anything else needed other than firing. Make sure to call the super method if you do.
See: Source