bool bUndoDown = false;
// checking for ctrl key
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Z:
if (bUndoDown)
break;
if (e.Modifiers == (Keys.Control | Keys.Shift))
{
bUndoDown = true;
Console.WriteLine("redo pressed");
}
else if (Control.ModifierKeys == Keys.Control)
{
bUndoDown = true;
undodebugcnt++;
Console.WriteLine("undo pressed "+undodebugcnt);
}
break;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (bUndoDown)
{
if (e.KeyCode==Keys.Z)
{
bUndoDown = false;
}
}
}
I originally thought I could get this to work with just the KeyPressed event, but had to do it a little deeper in the KeyDown and KeyUp events.
The game is called Balance Air. You have a hair dryer at the bottom of the screen and you need to balance the ball on air and force it into the goal. You move the blower left or right to change the direction of the ball. There are 7 levels which are basically just different locations for the goal. The score for each goal is dropping over time. 