public bool CanRotate() { int figurot = figure.rotation; figure.Rotate(); foreach (Point pp in figure.FillPoints) { if (pp.X >= 0 && pp.Y < panel1.Height && pp.X <= panel1.Width) { foreach (Point po in Fallist) { if (po.Equals(pp)) { figure.rotation = figurot; return(false); } } } else { figure.rotation = figurot; return(false); } } figure.rotation = figurot; return(true); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.A: if (CanLeft()) { figure.location = new Point(figure.location.X - r, figure.location.Y); } panel1.Invalidate(); break; case Keys.D: if (CanRight()) { figure.location = new Point(figure.location.X + r, figure.location.Y); } panel1.Invalidate(); break; case Keys.S: while (CanFall()) { figure.step(); } break; case Keys.Space: if (CanFall()) { figure.Rotate(); } break; } }