public void TickLoop() { if (TheShip != null) { int last_x = TheShip.Position.X; int last_y = TheShip.Position.Y; // Calculate Ship movement if the engines are running if (TheShip.Engines == 1) { TheShip.Position = new Point(MovementUtil.new_x(TheShip.volicity, TheShip.direction, TheShip.Position.X) , MovementUtil.new_y(TheShip.volicity, TheShip.direction, TheShip.Position.Y)); //TheShip.set_status(Ship.Status.Moving); }; //------------ Collisions ------------------------- //Check Astorides //TheShip.ShipStatus = Ship.Status.Nothing; foreach (Asteroid tempAsteriod in LevelData.Asteroids) { //Check for astoride collisions whith ships if (TheShip.IsShipColliding(tempAsteriod.GetBounds())) { if (!(TheShip.ShipStatus == Ship.Status.Explode)) { TheShip.ShipStatus = Ship.Status.HitAstorid; TheShip.Engines = 0; TheShip.Position = new Point(MovementUtil.new_x(TheShip.volicity - 5, TheShip.direction, TheShip.Position.X) , MovementUtil.new_y(TheShip.volicity - 5, TheShip.direction, TheShip.Position.Y)); PlayerCommander.ProcessGameEvent(new GameEvent(GameEvent.Event_Types.HitAstorid)); lastGameEvent = new GameEvent(GameEvent.Event_Types.HitAstorid); lastGameEventTick = TimerVal; } } } /* Check for the screen edges and stop the ship */ if (TheShip.Position.Y < 2 || TheShip.Position.Y > ClientRectangle.Height - 60 || TheShip.Position.X < 2 || TheShip.Position.X > ClientRectangle.Width - 60) { TheShip.shipSetStatus(Ship.Status.Stopped); TheShip.Engines = 0; TheShip.Position = new Point(MovementUtil.new_x(TheShip.volicity - 10, TheShip.direction, TheShip.Position.X), MovementUtil.new_y(TheShip.volicity - 10, TheShip.direction, TheShip.Position.Y)); PlayerCommander.ProcessGameEvent(new GameEvent(GameEvent.Event_Types.EdgeOfSpace)); lastGameEventTick = TimerVal; } /* Check the Ship has reached the finish */ if (TheShip.IsShipColliding(LevelData.theFinish.GetBounds())) { time_GameTick.Enabled = false; MessageBox.Show("Ship : [" + TheShip.ShipName + "], finish level in :" + TimerVal.ToString() + " ticks"); this.Close(); }; }; //Draw the screen Invalidate(); if (TheShip != null) { //Post screen update check for ship explosion if (TheShip.ShipStatus == Ship.Status.Explode) { time_GameTick.Enabled = false; MessageBox.Show("Game Over!"); this.Close(); } } /*NOW Perform the players game tick code */ PlayerCommander.ProcessGameTick(); /* Finally Add to the timer variable */ TimerVal = TimerVal + 1; }
public void ProcessGameEvent(GameEvent TempEvent) { }