Snake (Part 6/20)

  • 3
  • Locked
Once we have a snake, we need to draw it. To do this, by analogy with the Apple class, create HEAD_SIGN and BODY_SIGN constants in the Snake class. They will store symbols for drawing the head and body of the snake. Also, create a draw(Game) method to draw the snake on the playing field. We'll han
You can't complete this task, because you're not signed in.
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
TThink Modell
Level 0
24 May 2020, 17:47
The following step is giving me problems: The draw(Game) method must call the Game class's setCellValue(int, int, String) method on each GameObject in the snakeParts list Can anyone share his method implementation to compare? Mine is below: public void draw(Game game){ for (GameObject snakePart : snakeParts) { game.setCellValue(snakePart.x, snakePart.y,BODY_SIGN); } game.setCellValue(snakeParts.get(0).x, snakeParts.get(0).y,HEAD_SIGN); }
Kamil Kazana
Level 19 , Lublin, Poland
31 August 2020, 01:05
for (GameObject snakePart : snakeParts) { if(snakeParts.indexOf(snakePart) == 0){ game.setCellValue(snakeParts.get(0).x, snakeParts.get(0).y,HEAD_SIGN); } else { game.setCellValue(snakePart.x, snakePart.y, BODY_SIGN); } }