public void Draw(Mode13hPanel panel) { foreach (Bullet bullet in Bullets) { panel.PutPixel((int)Math.Round(bullet.X), (int)Math.Round(bullet.Y), BulletColor); panel.PutPixel((int)Math.Round(bullet.X) + 1, (int)Math.Round(bullet.Y), BulletColor); panel.PutPixel((int)Math.Round(bullet.X), (int)Math.Round(bullet.Y) + 1, BulletColor); panel.PutPixel((int)Math.Round(bullet.X) + 1, (int)Math.Round(bullet.Y) + 1, BulletColor); } if (IsExploding) { if (_ExplosionIndex < 19) { panel.DrawVGARotated(X, Y, Angle, Explosion[ExplosionSequence[_ExplosionIndex % 4] - 1]); _ExplosionIndex++; } else { } } else { panel.DrawVGARotated(X, Y, Angle, VGA); } }
void NewRound() { StopRound(); Mode13hPanel.Clear(_Mode13hPanel.Screen); _Mode13hPanel.Invalidate(); Tank.Red = new Tank(); Tank.Red.IsAlive = true; Tank.Red.VGA = Properties.Resources.T1; Tank.Red.Explosion[0] = Properties.Resources.RF1; Tank.Red.Explosion[1] = Properties.Resources.RF2; Tank.Red.Explosion[2] = Properties.Resources.RF3; Tank.Red.X = 270; Tank.Red.Y = 175; Tank.Red.Angle = 12; Tank.Red.Speed = 2; Tank.Blue = new Tank(); Tank.Blue.IsAlive = true; Tank.Blue.VGA = Properties.Resources.T2; Tank.Blue.Explosion[0] = Properties.Resources.BF1; Tank.Blue.Explosion[1] = Properties.Resources.BF2; Tank.Blue.Explosion[2] = Properties.Resources.BF3; Tank.Blue.X = 60; Tank.Blue.Y = 20; Tank.Blue.Angle = 4; Tank.Blue.Speed = 2; _Thread = new System.Threading.Thread(GameLoop); _Thread.IsBackground = true; _Thread.Start(); }
void GameLoop() { const int ExplodeDelay = 50; _FinishedRound = false; _Done = false; int delay = Globals.GameLoopTick_ms; while (!_Done) { CheckKeys(); Tank.BulletCheckResults result = Tank.Red.CheckBullets(_Map); result |= Tank.Blue.CheckBullets(_Map); if ((result & Tank.BulletCheckResults.RedDied) != 0) { delay = ExplodeDelay; Tank.Red.Explode(); } if ((result & Tank.BulletCheckResults.BlueDied) != 0) { delay = ExplodeDelay; Tank.Blue.Explode(); } Mode13hPanel.FlipScreen(_Background, _Mode13hPanel.Screen); Tank.Red.Draw(_Mode13hPanel); Tank.Blue.Draw(_Mode13hPanel); _Mode13hPanel.DoPaint(); if ((Tank.Red.IsExploding || Tank.Blue.IsExploding) && Tank.Red.DoneExploding && Tank.Blue.DoneExploding) { if (Tank.Blue.IsExploding) { Tank.RedScore++; } if (Tank.Red.IsExploding) { Tank.BlueScore++; } _FinishedRound = true; return; } if (!_Done) { System.Threading.Thread.Sleep(delay); } } }
void NewGame(string map) { StopRound(); if (_Thread != null) { _Thread.Abort(); } LoadMap(map); Mode13hPanel.DrawMap(_Map, _Background); Mode13hPanel.FlipScreen(_Background, _Mode13hPanel.Screen); _Mode13hPanel.GameOver = false; Tank.RedScore = 0; Tank.BlueScore = 0; NewRound(); }
static Tank() { BulletColor = Mode13hPanel.GetDefaultPaletteColor(8); }