adamjw / SnakeWS

0 stars 1 forks source link

3] The snake and fruit aren't drawn #3

Closed adamjw closed 9 years ago

adamjw commented 9 years ago

Implement the necessary code to draw the snake and fruit to the screen.

Start by implementing drawSquare and drawTriangle in snake.game.drawer.BoardDrawer. Then implement drawFruit in snake.game.drawer.FruitDrawer and drawSnake in snake.game.drawer.SnakeDrawer.

Acceptance Criteria:

  1. The snake is drawn with a triangle for its head, which is pointed in the correct direction.
  2. The snake is drawn with one square per segment of its body.
  3. The fruit is drawn as a square.
  4. The fruit and snake are drawn according to their position in the grid.
  5. The fruit and snake are drawn with appropriate colouring (the snake's colour should be consistent, the fruit can be anything but black).
adamjw commented 9 years ago

Drawing a triangle is kind of a pain in the ass. Here's an example of a switch statement that you can use on the Snake's facing direction to determine the orientation of the triangle:

http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

Drawing the square and the triangle uses a method similar to drawing the line.

adamjw commented 9 years ago

This is the Colour class: https://github.com/adamjw/SnakeWS/blob/master/Projects/SimpleIo/src/simpleio/common/Colour.java

adamjw commented 9 years ago

If you write Colour colour; and Eclipse underlines it with red, it's probably complaining that it doesn't know which class you're talking about (I'm not sure if this will actually happen). Hover over the red line to see the error, and it will suggest some classes to import. Select the one from simpleio so it knows which class you want.