Class Snake
java.lang.Object
GameObject
Snake
- Direct Known Subclasses:
SnakeAI
,SnakePlayer
GameObject that implements snake. Check colission each time it moves.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Board
protected Color
protected Vector2D
protected int
protected int
protected int
Fields inherited from class GameObject
game, timer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
awake()
Like unity Awake (invoke on create of object or create gameplay).protected void
control()
Control of snake depending if it's player od AIprotected void
dead()
Destroy all snake's parts and destroy snake.Head()
Return head of the snake.void
ModeLeft()
Set snake direction to the left.void
MoveDown()
Set snake direction downwards.void
Set snake direction to the right.void
MoveUp()
Set snake direction upwards.protected void
Like unity OnDestroy (invoke after destroy object or on end of game).protected void
start()
Like unity Start (invoke on first frame of object like or before begin main loop).protected void
update()
Like unity Update (invoke after render on each frames).Methods inherited from class GameObject
getDeltaTime, render, setTimer, timerClockDown
-
Field Details
-
board
-
body
-
newPartsNumber
protected int newPartsNumber -
direction
-
color
-
points
protected int points -
TIMER_BASE_VALUE
protected final int TIMER_BASE_VALUE- See Also:
- Constant Field Values
-
-
Constructor Details
-
Snake
Constructor pass reference to board.
-
-
Method Details
-
Head
Return head of the snake. -
MoveUp
public void MoveUp()Set snake direction upwards. -
MoveDown
public void MoveDown()Set snake direction downwards. -
ModeLeft
public void ModeLeft()Set snake direction to the left. -
MoveRight
public void MoveRight()Set snake direction to the right. -
control
protected void control()Control of snake depending if it's player od AI -
dead
protected void dead()Destroy all snake's parts and destroy snake. -
awake
protected void awake()Description copied from class:GameObject
Like unity Awake (invoke on create of object or create gameplay).- Overrides:
awake
in classGameObject
-
start
protected void start()Description copied from class:GameObject
Like unity Start (invoke on first frame of object like or before begin main loop).- Overrides:
start
in classGameObject
-
update
protected void update()Description copied from class:GameObject
Like unity Update (invoke after render on each frames).- Overrides:
update
in classGameObject
-
onDestroy
protected void onDestroy()Description copied from class:GameObject
Like unity OnDestroy (invoke after destroy object or on end of game).- Overrides:
onDestroy
in classGameObject
-