private void StartForm_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyCode.ToString()); if (e.KeyCode == Keys.Down) { pacman.MoveDown(); pacman.Display(paper); } else if (e.KeyCode == Keys.Up) { pacman.MoveUp(); pacman.Display(paper); } else if (e.KeyCode == Keys.Left) { pacman.MoveLeft(); pacman.Display(paper); } else if (e.KeyCode == Keys.Right) { pacman.Display(paper); pacman.MoveRight(); } }
public void MoveDown() { stepSize = 1; _yValue = _yValue - stepSize; } public void MoveUp() { stepSize = 1; _yValue = _yValue + stepSize; } public void MoveLeft() { stepSize = 1; _xValue = _xValue - stepSize; } public void MoveRight() { stepSize = 1; _xValue = _xValue + stepSize; } }