The picture used for the snake is not very beautiful. And using pictures to construct the snake body may increase the difficulty of developing the AI Mode.
The snake body is now replaced by directly painting on the JPanel. The redundant snake pictures are deleted. Below are the code implementation of painting the snake: //set its head DARK_GRAY and body Black protected void drawSnake(Graphics snake) { for (int i = 0; i < length; i++) { if (i == 0) { snake.setColor(Color.DARK_GRAY); } else { snake.setColor(Color.BLACK); } snake.fillRect(coordinate.get(i).get(SConstant.SC_COORDINATE_XPOS_KEY),coordinate.get(i).get(SConstant.SC_COORDINATE_YPOS_KEY), SConstant.SC_DEFAULT_NODE_SIZE,SConstant.SC_DEFAULT_NODE_SIZE); } drawInformation(snake); }