/// <summary> /// Renders MoonLander visual components based on their correlating simulation values /// </summary> /// <param name="scale"></param> /// <returns>Rendered instance of Simulation moment (SimFrame)</returns> public override SimFrame DrawTurn(Vec2 scale) { #region Draws and spits out a SimFrame based on current SpaceShip state // NEW FRAME SimFrame ret = new SimFrame { Error = false, ToBeDrawn = true, BackGround = Color.Black, FrameId = Globals.TurnCount, Renderables = new List<Drawable>() }; AddTracePathBlip(ret); DrawText(30, ret); //ADD MOON BACKGROUND ret.AddRenderable(new Sprite("surface1") { Picture = SpriteList.MoonSurface, Position = new Vec2(0, FrameResolution.Y - 20) }); ret.AddRenderable(new Sprite("surface2") { Picture = SpriteList.MoonSurface_Flip, Position = new Vec2(SpriteList.MoonSurface.Width, FrameResolution.Y - 20) }); //SET UP THE SPACESHIP Sprite shipSprite = new Sprite("ss"); shipSprite.Picture = SpriteList.SpaceShip; //Set Image for ship //Add the thrust to the Space Ship Sprite downThrust = new Sprite("downThrust") { Picture = SpriteList.ThrustDown }; Sprite leftThrust = new Sprite("leftThrust") { Picture = SpriteList.ThrustLeft }; Sprite rightThrust = new Sprite("rightThrust") { Picture = SpriteList.ThrustRight }; if (Globals.DrawTracePath) DrawTracePath(ret); //CALCULATE SS RELATIVE POSITION ON SCREEN shipSprite.Position = new Vec2(SpaceShip.X, (FrameResolution.Y - (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 60); ret.AddRenderable(shipSprite);//ADD THE SS OBJECT if(!CheckForFinishText(ret)) // true if finished //do the thrust image { downThrust.Scale = new Vec2(1, SpaceShip.Throttle * .04); leftThrust.Scale = new Vec2(SpaceShip.Left /3, .5); rightThrust.Scale = new Vec2(SpaceShip.Right/3, .5); downThrust.Position = new Vec2(SpaceShip.X + 4, (FrameResolution.Y - (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 20); leftThrust.Position = new Vec2(SpaceShip.X - 10 - (leftThrust.Picture.Width * leftThrust.Scale.X), (FrameResolution.Y - (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 50); rightThrust.Position = new Vec2(SpaceShip.X + 42, (FrameResolution.Y - (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 50); if (SpaceShip.Fuel > 0) { ret.AddRenderable(downThrust); //add the thrust object to the frame ret.AddRenderable(leftThrust); //add the thrust object to the frame ret.AddRenderable(rightThrust); //add the thrust object to the frame } } //DRAW ROCKS(IF APPLICABLE) List<Drawable> rocks = DrawRocks(); if (rocks != null) foreach (Drawable d in rocks) ret.AddRenderable(d); if (Globals.DrawDebug && State != SimulatorStateEnum.Complete) DrawDebug(ret, new Vec2(leftThrust.Position.X - 15 - (SpaceShip.Left * leftThrust.Scale.X * 6), leftThrust.Position.Y) , new Vec2(downThrust.Position.X + 1, downThrust.Position.Y + (30 * downThrust.Scale.Y)), new Vec2(rightThrust.Position.X + (SpaceShip.Right * rightThrust.Scale.X * 12) , rightThrust.Position.Y)); if (Globals.DrawTracePath) if(TracePath != null) for (int i = 1; i < TracePath.Count; i++) { ret.AddRenderable(new Line(TracePath[i - 1].Position, TracePath[i].Position, new SolidBrush(Color.MediumBlue), .5f )); } #endregion ret.TracePath = TracePath; return ret; //RETURN THE FINAL FRAME }
private void DrawLines(SimFrame ret) { double xx = 0, yy = 0; float throttleThickness = (float)((((Harrier.Throttle) - 60)/40) * 8f); //throttleThickness = 0.05f; if (throttleThickness < .05f) throttleThickness = .05f; Move2DInDirHS(Harrier.X, Harrier.Y, DegToRad(270 - Harrier.ThrustVector), Harrier.Throttle/4, ref xx, ref yy); ret.AddRenderable(new Line(new Vec2(ToX(Harrier.X+1), ToY(Harrier.Y-2)), new Vec2(ToX(xx+1), ToY(yy)), new SolidBrush(Color.Red), throttleThickness) { Id = "ThrustLine" }); ret.AddRenderable(new Line(new Vec2(ToX(Harrier.UnsafeX1), ToY(Harrier.SafeYDraw + 1)), new Vec2(ToX(Harrier.SafeX2), ToY(Harrier.SafeYDraw + 1)), new SolidBrush(Color.Red), 3f) {Id = "LandingLine"}); ret.AddRenderable(new Line(new Vec2(ToX(Harrier.MidSafeX - 3), ToY(Harrier.SafeYDraw + 1)), new Vec2(ToX(Harrier.MidSafeX + 3), ToY(Harrier.SafeYDraw + 1)), new SolidBrush(Color.Green), 3f) {Id = "MiddleSafe"}); }
/// <summary> /// Renders MoonLander visual components based on their correlating simulation values /// </summary> /// <param name="xscale"></param> /// <param name="yscale"></param> /// <returns>Rendered instance of Simulation moment (SimFrame)</returns> public override SimFrame DrawTurn(Vec2 scale) { // NEW FRAME SimFrame ret = new SimFrame { Error = false, ToBeDrawn = true, BackGround = Color.Black, FrameId = Globals.turnCount, Renderables = new List<Drawable>() }; //ADD STRINGS ret.AddText("---SpaceShip---", new Vec2(500, 30), new SolidBrush(Color.Cornsilk)); ret.AddText("Speed X: " + SpaceShip.Variables["YVel"].ToString(), new Vec2(500, 50), new SolidBrush(Color.Cornsilk)); ret.AddText("Height: " + SpaceShip.Variables["Y"].ToString(), new Vec2(500, 70), new SolidBrush(Color.Cornsilk)); ret.AddText("Throttle: " + SpaceShip.Variables["Throttle"].ToString(), new Vec2(500, 90), new SolidBrush(Color.Cornsilk)); ret.AddText("Fuel: " + SpaceShip.Variables["Fuel"].ToString(), new Vec2(500, 110), new SolidBrush(Color.Cornsilk)); //ADD MOON BACKGROUND ret.AddRenderable(new Sprite {Picture = SpriteList.MoonSurface, Position = new Vec2(0, FrameResolution.Y - 70)}); //SET UP THE SPACESHIP Sprite shipSprite = new Sprite(); shipSprite.Picture = SpriteList.SpaceShip; //Set Image for ship if (bool.Parse(SpaceShip.Variables["Landed"].ToString())) { if (bool.Parse(SpaceShip.Variables["Boom"].ToString())) { ret.AddText("FAIL", new Vec2(250, 150), new SolidBrush(Color.Red), 100); shipSprite.Picture = SpriteList.SpaceShip_Explode; Fail(); } else { ret.AddText("SAFE", new Vec2(250, 150), new SolidBrush(Color.Green), 100); shipSprite.Picture = SpriteList.SpaceShip_Landed; } } //CALCULATE SS RELATIVE POSITION ON SCREEN int simHeight = 5000; shipSprite.Position = new Vec2(double.Parse(SpaceShip.Variables["X"].ToString()), (FrameResolution.Y - (double.Parse(SpaceShip.Variables["Y"].ToString())/(simHeight/FrameResolution.Y))) - 60); ret.AddRenderable(shipSprite);//ADD THE SS OBJECT return ret; //RETURN THE FINAL FRAME }
//scale provides the height (Y) public override SimFrame DrawTurn(Vec2 scale) { double height = scale.Y; Harrier.CarrierImageY = scale.Y - Harrier.CarrierHeightPixels - 28; SimFrame ret = new SimFrame { Error = false, ToBeDrawn = true, BackGround = Color.FromArgb(255, 0, 255, 255), Renderables = new List<Drawable> {} }; AddTracePathBlip(ret); ret.AddRenderable((new Sprite("ship") { Picture = Harrier.ShipImage, Position = new Vec2(Harrier.CarrierImageX, Harrier.CarrierImageY) } )); DrawLines(ret); CheckForFinishText(ret); if (Globals.DrawTracePath) DrawTracePath(ret); ret.AddRenderable(new Sprite("hs") { Picture = Harrier.PlaneImage, Position = new Vec2(ToX(Harrier.X-8),ToY(Harrier.Y+4)), Scale = new Vec2(1.5,1.5) } ); DrawText(30, ref ret); if(Globals.DrawDebug) DrawDebug(ret); ret.TracePath = TracePath; return ret; }