package com.codegym.games.snake;
import com.codegym.engine.cell.*;
public class SnakeGame extends Game {
public static final int WIDTH = 15;
public static final int HEIGHT = 15;
private Snake snake;
public void initialize() {
setScreenSize(WIDTH,HEIGHT);
createGame();
}
private void createGame() {
snake = new Snake(WIDTH/2,HEIGHT/2);
drawScene();
//Apple apple = new Apple(7,7);
//apple.draw(this);
}
private void drawScene() {
for(int i=0;i<WIDTH;i+=1) {
for(int j=0;j<HEIGHT;j+=1) {
setCellColor(i,j,Color.DARKSEAGREEN);
}
}
snake.draw(this);
}
}
Last two requirements not meeting
Under discussion
private List<GameObject> snakeParts = new ArrayList<>();
Not the whole snake is a GameObject, but its parts, because a GameObject is only one (x, y) pair. The whole snake cannot be described with an (x, y) coordinate, just the parts of the snake. (Believe me, my game is finished and works. :) ) So I recommend you to delete the ("extends GameObject" part from the class head. And also delete the super(x, y); row from the Snake constructor.