Public void keyReleased (KeyEvent ke) {
The switch (ke getKeyCode ()) {
Case KeyEvent. VK_UP:
If (snake. GetDirection ()!
=2)Snake. SetDirection (0);
break;
Case KeyEvent. VK_RIGHT:
If (snake. GetDirection ()!
=3)The snake. SetDirection (1);
break;
Case KeyEvent. VK_DOWN:
If (snake. GetDirection ()!=0)
The snake. SetDirection (2);
break;
Case KeyEvent. VK_LEFT:
If (snake. GetDirection ()!
=1)The snake. SetDirection (3);
break;
Case KeyEvent. VK_ENTER:
If (SnakeGameView gameState==true) {
SnakeGameView. GameState=false;
} else {
SnakeGameView. GameState=true;
}
break;
Case KeyEvent. VK_ESCAPE:
System.exit(0);
break;
}
}
CodePudding user response:
Detailed test requirements and rulesThen confirm whether to automatic testing