Bug 667 - The Snake picture is ugly and may reduce the flexibility of future extension.
Summary: The Snake picture is ugly and may reduce the flexibility of future extension.
Status: RESOLVED FIXED
Alias: None
Product: CS3343 2021/22 Group16 Greedy Snake
Classification: Unclassified
Component: System section (show other bugs)
Version: Ver 2.0
Hardware: PC Windows
: --- enhancement
Assignee: Baron Qu
URL:
Depends on:
Blocks:
 
Reported: 2021-12-06 18:20 HKT by LI Ruoxin
Modified: 2021-12-06 18:25 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LI Ruoxin 2021-12-06 18:20:40 HKT
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.
Comment 1 LI Ruoxin 2021-12-06 18:25:07 HKT
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);
		
}