public void reset() { List <int[]> part = sn.getPart(); int size = part.Count; for (int i = 1; i < size; i++) { matrix[part[i][1], part[i][0]] = 0; } sn = null; small = null; big = null; timeToSnakeGrow = 0; count = 0; bigTime = 0; GameOver = false; }
public void addSnake(UserSnake n) { n.fx = x; n.fy = y; n.setDir(direction); List <int[]> part = n.getPart(); int size = part.Count; int a, b; switch (direction) { case Snake.DOWN: a = 0; b = -1; break; case Snake.UP: a = 0; b = 1; break; case Snake.RIGHT: a = -1; b = 0; break; default: a = 1; b = 0; break; } for (int i = 0; i < size; i++) { part[i][0] = x + a * i; part[i][1] = y + b * i; matrix[part[i][1], part[i][0]] = 2; } n.lx = part[size - 1][0]; n.ly = part[size - 1][1]; sn = n; }