Class Snake
java.lang.Object
GameObject
Snake
- Direct Known Subclasses:
SnakeAI,SnakePlayer
GameObject that implements snake. Check colission each time it moves.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Boardprotected Colorprotected Vector2Dprotected intprotected intprotected intFields inherited from class GameObject
game, timer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidawake()Like unity Awake (invoke on create of object or create gameplay).protected voidcontrol()Control of snake depending if it's player od AIprotected voiddead()Destroy all snake's parts and destroy snake.Head()Return head of the snake.voidModeLeft()Set snake direction to the left.voidMoveDown()Set snake direction downwards.voidSet snake direction to the right.voidMoveUp()Set snake direction upwards.protected voidLike unity OnDestroy (invoke after destroy object or on end of game).protected voidstart()Like unity Start (invoke on first frame of object like or before begin main loop).protected voidupdate()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:GameObjectLike unity Awake (invoke on create of object or create gameplay).- Overrides:
awakein classGameObject
-
start
protected void start()Description copied from class:GameObjectLike unity Start (invoke on first frame of object like or before begin main loop).- Overrides:
startin classGameObject
-
update
protected void update()Description copied from class:GameObjectLike unity Update (invoke after render on each frames).- Overrides:
updatein classGameObject
-
onDestroy
protected void onDestroy()Description copied from class:GameObjectLike unity OnDestroy (invoke after destroy object or on end of game).- Overrides:
onDestroyin classGameObject
-