Class Snake

Direct Known Subclasses:
SnakeAI, SnakePlayer

public abstract class Snake extends GameObject
GameObject that implements snake. Check colission each time it moves.
  • Field Details

    • board

      protected Board board
    • body

      protected List<SnakePart> body
    • newPartsNumber

      protected int newPartsNumber
    • direction

      protected Vector2D direction
    • color

      protected Color color
    • points

      protected int points
    • TIMER_BASE_VALUE

      protected final int TIMER_BASE_VALUE
      See Also:
      Constant Field Values
  • Constructor Details

    • Snake

      public Snake(Board board)
      Constructor pass reference to board.
  • Method Details

    • Head

      public SnakePart 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 class GameObject
    • 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 class GameObject
    • update

      protected void update()
      Description copied from class: GameObject
      Like unity Update (invoke after render on each frames).
      Overrides:
      update in class GameObject
    • onDestroy

      protected void onDestroy()
      Description copied from class: GameObject
      Like unity OnDestroy (invoke after destroy object or on end of game).
      Overrides:
      onDestroy in class GameObject