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.
Homework
  1. We need to change the direction of snake movement according to the arrow button that user presses.
    1. Inside GameBoardView.java
      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 GameActivity.java,
      1. get GameBoardView using findViewById(R.id.gameBoardView) 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)

Details

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