Skip to content

Commit

Permalink
v.0005
Browse files Browse the repository at this point in the history
Техническое обновление, добавлена обработка клавиши R для ресета бэкграунда.
  • Loading branch information
Vladisvell committed May 7, 2022
1 parent 6e6f91a commit 877a812
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions Rendering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class SpaceField : Form

private bool isSpacePressed;
private bool isWPressed;
private bool isRPressed;

private Label velocity;
private Label acceleration;
Expand Down Expand Up @@ -149,42 +150,20 @@ public void InputTick()
}
if (isWPressed)
ship.ApplyForce();
if (isRPressed)
BackColor = Color.Black;

}

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
//pressedKeys.Enqueue(e.KeyCode);
if (e.KeyCode == Keys.Space)
isSpacePressed = true;
if (e.KeyCode == Keys.W)
isWPressed = true;
//if (e.KeyCode == Keys.W || e.KeyCode == Keys.Space)
//{
// ship.ApplyForce();
// if (ship.cooldown <= 0)
// {
// spaceObjects.Add(new Bullet(ship.GetCurrentCoordinates(), ship.GetVelocity() + new Vec2(1, 1) * angle * (1 / 180)));
// ship.SetShootCooldown(300);
// }
//}
//if (e.KeyCode == Keys.W)
//{
// ship.ApplyForce();
//}
//if (e.KeyCode == Keys.R)
// BackColor = Color.Black;
//if (e.KeyCode == Keys.Space)
//{

// if (ship.cooldown <= 0)
// {
// spaceObjects.Add(new Bullet(ship.GetCurrentCoordinates(), ship.GetVelocity() + new Vec2(1, 1) * angle * (1 / 180)));
// ship.SetShootCooldown(300);
// }
////TODO: физика пеллет
//}
if (e.KeyCode == Keys.R)
isRPressed = true;
}
protected override void OnKeyUp(KeyEventArgs e)
{
Expand All @@ -193,6 +172,8 @@ protected override void OnKeyUp(KeyEventArgs e)
isSpacePressed = false;
if (e.KeyCode == Keys.W)
isWPressed = false;
if (e.KeyCode == Keys.R)
isRPressed = false;
}

void Invalidate(object sender, EventArgs e) {this.Invalidate(); }
Expand Down

0 comments on commit 877a812

Please sign in to comment.