private void Game2_KeyDown(object sender, KeyEventArgs e) { if (s.x > 30 && s.x < 1751) { if (e.KeyCode == Keys.Right) { s.x += 50; } if (e.KeyCode == Keys.Left) { s.x -= 50; } if (e.KeyCode == Keys.Space) { PlayerShoot1.Play(); Shoot shoot = new Shoot(); shoot.SetX(s.GetX() + 85); shoot.SetY(s.GetY()); ls.Insert(null, shoot); timer2.Start(); } } if (s.x < 30) { if (e.KeyCode == Keys.Right) { s.x += 50; } } if (s.x > 1751) { if (e.KeyCode == Keys.Left) { s.x -= 50; } } int mone = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 8; j++) { if (game2.GetBoard()[i, j].GetStatus() == 0) { mone++; //this.timer1.Interval = this.timer1.Interval - 1; } if (mone == 32) { this.Close(); LvlUp a = new LvlUp(); a.Show(); } } } Invalidate(); PlayerShoot1.Stop(); }
private void timer1_Tick(object sender, EventArgs e) { g = CreateGraphics(); if (sw == true) { if (countTick < 19) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 8; j++) { game.GetBoard()[i, j].SetX(game.GetBoard()[i, j].GetX() + 40); } } countTick++; } else { sw = false; countTick = 0; for (int i1 = 0; i1 < 4; i1++) { for (int j1 = 0; j1 < 8; j1++) { game.GetBoard()[i1, j1].SetY(game.GetBoard()[i1, j1].GetY() + 45); } } } } if (sw == false) { if (countTick < 19) { for (int i1 = 0; i1 < 4; i1++) { for (int j1 = 0; j1 < 8; j1++) { game.GetBoard()[i1, j1].SetX(game.GetBoard()[i1, j1].GetX() - 40); } } countTick++; } else { sw = true; countTick = 0; for (int i1 = 0; i1 < 4; i1++) { for (int j1 = 0; j1 < 8; j1++) { game.GetBoard()[i1, j1].SetY(game.GetBoard()[i1, j1].GetY() + 45); } } } } game.PaintBoard(g); Refresh(); int x = game.GetBoard()[3, 0].GetX(); int x1 = game.GetBoard()[3, 7].GetX() + 120; int y = game.GetBoard()[0, 0].GetY(); int y1 = game.GetBoard()[3, 7].GetY() + 120; if (s.GetX() >= x && s.GetX() <= x1 && s.GetY() >= y && s.GetY() <= y1) { s.SetStatus(0); } int mone = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 8; j++) { if (game.GetBoard()[i, j].GetStatus() == 0) { mone++; } if (mone == 32) { this.Close(); LvlUp a = new LvlUp(); a.Show(); } } } CheckLose(); }