American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

5 PM – Android Game Dev – Gamas

November 4, 2023 @ 5:00 pm - 6:00 pm

Today We Did
  1. We continued on Snake and Apple game.
  2. We added Snake into the screen and using android.os.Handler to move the snake once every 200 milliseconds.
  1. We need to change the direction of snake movement according to the arrow button that user presses.
    1. Inside
      1. Add a new attribute direction.
      2. Add a method setSnakeDirection(String direction)
      3. Change code inside update() method to increase and decrease snake.x and snake.y according to attribute direction.
    2. Inside,
      1. get GameBoardView using findViewById( method.
      2. when user click the right arrow, call gameBoardView.setSnakeDirection(“RIGHT)
      3. when user click the left arrow, call gameBoardView.setSnakeDirection(“LEFT)
      4. when user click the up arrow, call gameBoardView.setSnakeDirection(“UP)
      5. when user click the down arrow, call gameBoardView.setSnakeDirection(“DOWN)


November 4, 2023
5:00 pm - 6:00 pm
Verified by MonsterInsights