public void inputMovementManagement() { if (Input.GetKey("z")) { yButtonState = yDirection.Up; } else if (Input.GetKey("s")) { yButtonState = yDirection.Down; } else { yButtonState = yDirection.None; } if (Input.GetKey("q")) { xButtonState = xDirection.Left; } else if (Input.GetKey("d")) { xButtonState = xDirection.Right; } else { xButtonState = xDirection.None; } }
private void ChangeDirection(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Right: xDir = xDirection.Right; yDir = yDirection.None; break; case Keys.Left: xDir = xDirection.Left; yDir = yDirection.None; break; case Keys.Up: xDir = xDirection.None; yDir = yDirection.Up; break; case Keys.Down: xDir = xDirection.None; yDir = yDirection.Down; break; } }
public bool Update(xDirection xd, yDirection yd) { for (int n = Tail.Count - 1; n >= 1; n--) { Tail[n] = new Point(Tail[n - 1].X, Tail[n - 1].Y); } if (Tail.Count >= 1) { Tail[0] = new Point(Head.X, Head.Y); } Head = new Point(Head.X + (int)xd, Head.Y + (int)yd); int x = Head.X; Lerp(ref x, 0, Form1.ColCount - 1); int y = Head.Y; Lerp(ref y, 0, Form1.RowCount - 1); Head = new Point(x, y); foreach (Point p in Tail) { if (p.Equals(Head)) { return(false); } } if (Head.Equals(Fruit)) { EatFruit(); SortFruit(); } return(true); }