Snake/Java: Difference between revisions

m
→‎Code: small changes
(created page for Java entry)
 
m (→‎Code: small changes)
Line 82:
stop();
initGrid();
treats = new LinkedList<>();
 
dir = 3;
Line 91 ⟶ 90:
score = 0;
 
treats = new LinkedList<>();
snake = new ArrayList<>();
for (int x = 0; x < 7; x++)
Line 134:
gameOver();
 
else if (hitsWormhitsSnake())
gameOver();
 
Line 239:
void addTreat() {
if (treats.size() < 3) {
 
if (rand.nextInt(10) == 0) {
if (rand.nextInt(410) !== 0) { // 1 in 10
 
if (rand.nextInt(104) =!= 0) { // 3 in 4
int x, y;
while (true) {
Line 269 ⟶ 271:
}
 
boolean hitsWormhitsSnake() {
Point head = snake.get(0);
int nextCol = head.x + dirs[dir][0];
Anonymous user