public static void drawgame(SpriteBatch sb, GraphicsDevice gd, Matrix matrix, GameTime gameTime, List <Craft> craftlist) { if (Play.mainmenu) { gd.Clear(Color.Black); sb.Begin(); sb.Draw(Drawing.white, new Rectangle(200, 120, 400, 30), Color.Green); sb.DrawString(Drawing.menufont, "Start Game", new Vector2(250, 120), Color.White); sb.Draw(Drawing.white, new Rectangle(200, 160, 400, 30), Color.Red); sb.DrawString(Drawing.menufont, "Exit", new Vector2(350, 160), Color.White); sb.End(); } if (Play.escmenu) { sb.Begin(); sb.Draw(white, new Rectangle((int)Camera.screencenter.X - 210, 110, 420, 130), Color.Gray); sb.Draw(Drawing.white, new Rectangle((int)Camera.screencenter.X - 200, 120, 400, 30), Color.Green); sb.DrawString(Drawing.menufont, "Continue", new Vector2((int)Camera.screencenter.X - 200, 120), Color.White); sb.Draw(Drawing.white, new Rectangle((int)Camera.screencenter.X - 200, 160, 400, 30), Color.Yellow); sb.DrawString(Drawing.menufont, "Exit to mainmenu", new Vector2((int)Camera.screencenter.X - 200, 160), Color.White); sb.Draw(Drawing.white, new Rectangle((int)Camera.screencenter.X - 200, 200, 400, 30), Color.Red); sb.DrawString(Drawing.menufont, "Exit game", new Vector2((int)Camera.screencenter.X - 200, 200), Color.White); sb.End(); } else if (Play.editor) { DrawEditor.draw(sb, gd, matrix, gameTime, craftlist); } else if (Play.flight) { Drawflight.draw(sb, gd, matrix, gameTime, craftlist); } }
public static void draw(SpriteBatch sb, GraphicsDevice gd, Matrix matrix, GameTime gameTime, List <Craft> craftlist) { gd.Clear(Color.Black); #region rendertarget foreach (Craft c in craftlist) { if (c.needsrerendering > 0) { c.rendertarget = new RenderTarget2D(gd, (int)((c.size.X - c.posoffset.X) * 1000), (int)((c.size.Y - c.posoffset.Y) * 1000)); gd.SetRenderTarget(c.rendertarget); gd.Clear(Color.Transparent); sb.Begin(); foreach (Part p in c.partlist) { sb.Draw(Drawing.dictionary[p.type], new Rectangle((int)((p.pos.X - c.posoffset.X) * 1000), (int)((p.pos.Y - c.posoffset.Y) * 1000), (int)(p.size.X * 1000), (int)(p.size.Y * 1000)), Color.White); } sb.End(); c.needsrerendering--; gd.SetRenderTarget(null); } } #endregion #region draw world sb.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Camera.matrix(gd.Viewport)); #region draw path if (Camera.zoom < 1.76313472) { //drawaccurateorbits(sb, gd, matrix, gameTime, craftlist); draworbits(sb, gd, matrix, gameTime, craftlist); sb.Draw(Drawing.arrow, craftlist[0].pos, null, Color.White, (float)craftlist[0].rotation, new Vector2(32, 32), (1 / Camera.zoom) * 0.25f, SpriteEffects.None, 1); } #endregion #region draw planets if (Flight.planet[0].hasatmosphere) { Rectangle arec = new Rectangle((int)((Flight.planet[0].posx - (Flight.planet[0].radius + Flight.planet[0].atmosphereradius)) * worldscale), (int)((Flight.planet[0].posy - (Flight.planet[0].radius + Flight.planet[0].atmosphereradius)) * worldscale), (int)((Flight.planet[0].radius + Flight.planet[0].atmosphereradius) * 2 * worldscale), (int)((Flight.planet[0].radius + Flight.planet[0].atmosphereradius) * 2 * worldscale)); sb.Draw(Drawing.atmosphere, arec, Color.White); } Rectangle rec = new Rectangle((int)((Flight.planet[0].posx - Flight.planet[0].radius * 1) * worldscale), (int)((Flight.planet[0].posy - Flight.planet[0].radius * 1) * worldscale), (int)(Flight.planet[0].radius * 2 * worldscale), (int)(Flight.planet[0].radius * 2 * worldscale)); sb.Draw(Flight.planet[0].texture, rec, Color.White); //sb.Draw(Drawing.white, new Rectangle((int)craftlist[0].pos.X,(int)craftlist[0].pos.Y,1,1), Color.Green); #endregion #region draw crafts sb.End(); sb.Begin(); foreach (Craft c in craftlist) { Rectangle srec = new Rectangle(0, 0, c.rendertarget.Width, c.rendertarget.Height); sb.Draw(c.rendertarget, Camera.screencenter + (c.pos * worldscale), srec, Color.White, c.rotation, new Vector2(0, 0), Camera.zoom / 1000, SpriteEffects.None, 1); } sb.End(); #endregion #endregion #region draw menus sb.Begin(); sb.DrawString(Drawing.font, "Throttle = " + (craftlist[0].throttle * 100).ToString(), new Vector2(0, 0), Color.White); sb.DrawString(Drawing.font, "vel = " + Drawing.getsiprefix(craftlist[0].vel.Length()) + "M/S", new Vector2(0, 20), Color.White); foreach (Part p in craftlist[0].partlist) { if (p.type == "engine" & p.on) { sb.DrawString(Drawing.font, "TWR = " + (craftlist[0].throttle * p.thrust / (craftlist[0].mass * 9.81f)), new Vector2(0, 40), Color.White); } } sb.DrawString(Drawing.font, "Timewarp = " + Flight.timewarp.ToString() + "* speed", new Vector2(0, 60), Color.White); sb.DrawString(Drawing.font, "Altitude = " + Drawing.getsiprefix((Flight.planet[0].pos - craftlist[0].pos).Length()) + "m", new Vector2(200, 0), Color.White); sb.DrawString(Drawing.font, "Alt surf = " + Drawing.getsiprefix((Flight.planet[0].pos - craftlist[0].pos).Length() - Flight.planet[0].radius) + "m", new Vector2(200, 20), Color.White); if (Camera.zoom < 1.76313472) { sb.DrawString(Drawing.font, "Apoapsis = " + Drawing.getsiprefix(apoapsis) + "m", new Vector2(500, 0), Color.White); sb.DrawString(Drawing.font, "Periapsis = " + Drawing.getsiprefix(periapsis) + "m", new Vector2(500, 20), Color.White); sb.DrawString(Drawing.font, "Time to apoapsis = " + Drawing.getsiprefix(timetoapoapsis) + "s", new Vector2(800, 0), Color.White); sb.DrawString(Drawing.font, "Time to periapsis = " + Drawing.getsiprefix(timetoperiapsis) + "s", new Vector2(800, 20), Color.White); sb.DrawString(Drawing.font, "Eccentricity = " + eccentricity.ToString(), new Vector2(1100, 0), Color.White); } #region deltavstats if (Editor.stage != null & craftlist.Count != 0 & true) { Craft c = new Craft(); int laststage = 10; c.partlist = new List <Part>(craftlist[0].partlist); foreach (Part p in c.partlist) { p.dontcalculatemymass = false; } float[] deltav = new float[10]; float[] twr = new float[10]; for (int s = 0; s < 10; s++) { if (Editor.stage[s] != null) { foreach (int i in Editor.stage[s]) { for (int j = 0; j < c.partlist.Count(); j++) { Part p = c.partlist[j]; if (c.partlist[j].id == i) { if (c.partlist[j].type == "separator") { //separator part List <Part> lista = new List <Part>(); List <int> used = new List <int>(); foreach (Part pa in c.partlist) { if (pa.id != p.parent) { foreach (int n in p.neibours) { if (n == pa.id) { lista.Add(pa); } } } } for (int k = 0; k < lista.Count(); k++) { bool partused = false; foreach (int l in used) { if (lista[k].id == l) { partused = true; } } if (!partused) { foreach (Part pa in c.partlist) { foreach (int n in lista[k].neibours) { if (n == pa.id) { lista.Add(pa); used.Add(pa.id); } } } } } foreach (Part pa in lista) { pa.dontcalculatemymass = true; } } } } } for (int i = 0; i < c.partlist.Count(); i++) { if (c.partlist[i].removeme) { c.partlist.Remove(c.partlist[i]); } } if (Editor.stage[s].Count == 0 & laststage == 10) { laststage = s; } foreach (int i in Editor.stage[s]) { for (int j = 0; j < c.partlist.Count(); j++) { if (c.partlist[j].id == i) { if (c.partlist[j].type == "engine") { //engine part foreach (int k in c.partlist[j].neibours) { for (int l = 0; l < c.partlist.Count(); l++) { if (c.partlist[l].id == k) { //neibour of the engine float mass = DrawEditor.getmass(c); deltav[s] += (float)(Math.Log(mass / (mass - c.partlist[l].fuel)) * c.partlist[j].isp * 9.81f); //why ar u lying to me??? twr[s] = c.partlist[j].thrust / (mass * 9.81f); } } } } } } } } else { laststage = s; } } //explanations here int ssep = 50; sb.Draw(Drawing.white, new Rectangle(0, (int)Camera.screencenter.Y * 2 + 10 - (laststage + 1) * ssep, 600, (laststage + 2) * ssep), Color.Gray); for (int i = 0; i < laststage; i++) { sb.Draw(Drawing.white, new Rectangle(10, (int)Camera.screencenter.Y * 2 - 50 - i * ssep, 90, ssep), Color.Black); sb.DrawString(Drawing.font, deltav[i].ToString(), new Vector2(10, Camera.screencenter.Y * 2 - 50 - i * ssep), Color.White); sb.Draw(Drawing.white, new Rectangle(110, (int)Camera.screencenter.Y * 2 - 50 - i * ssep, 90, ssep), Color.Black); sb.DrawString(Drawing.font, twr[i].ToString(), new Vector2(110, Camera.screencenter.Y * 2 - 50 - i * ssep), Color.White); } sb.DrawString(Drawing.font, "deltav", new Vector2(10, Camera.screencenter.Y * 2 + 10 - (laststage + 1) * ssep), Color.White); sb.DrawString(Drawing.font, "TWR", new Vector2(110, Camera.screencenter.Y * 2 + 10 - (laststage + 1) * ssep), Color.White); foreach (Part p in c.partlist) { p.dontcalculatemymass = false; } } sb.End(); #endregion #endregion }