public IOControl() { InitializeComponent(); KeyDown += KeyPressed; KeyUp += KeyReleased; InitGraphics(); g = new GameBoard(this); g.Start(); }
public void KeyPressed(object sender, KeyEventArgs e) { if (longPress || keyTimer.Enabled) { return; } switch (e.KeyCode) { case Keys.Up: longPress = true; g.RotatePiece(); break; case Keys.Down: longPress = true; g.SetFastFall(); break; case Keys.Left: g.ShiftPiece(Direction.Left); break; case Keys.Right: g.ShiftPiece(Direction.Right); break; case Keys.Space: g.Stop(); break; case Keys.X: g.Start(); break; } if (!longPress && !multiPress) { keyTimer.Elapsed += MultiPressEvent; keyTimer.Start(); } }
private void start_MouseUp(object sender, MouseButtonEventArgs e) { board.Start(); }