// draw the snake g.setColor(Color.BLACK); LinkedList na = snakeModel.nodeArray; Iterator it = na.iterator(); while(it.hasNext()){ Node n = (Node)it.next(); drawNode(g,n); }
// draw the food g.setColor(Color.RED); Node n = snakeModel.food; drawNode(g,n);
class SnakeModel implements Runnable{ GreedSnake gs; boolean[][] matrix; LinkedList nodeArray = new LinkedList(); Node food; int maxX; int maxY; int direction = 2; boolean running = false;
// UP and DOWN should be even // RIGHT and LEFT should be odd public static final int UP = 2; public static final int DOWN = 4; public static final int LEFT = 1; public static final int RIGHT = 3;