public static void Draw(SpriteBatch batch, GraphicsDevice g, GameTime gametime) { int winW = g.Viewport.Width; int winH = g.Viewport.Height; float pct = (float)progress / (float)goal; Rectangle Rect = CenteredRect(new Rectangle(0, 0, winW, winH), winW / 4, winH / 20); var tex = GraphUtils.GetTexture(g, Color.Blue); var background = GraphUtils.GetTexture(g, new Color(0.0f, 0.0f, 0.0f, 0.5f)); var progRect = new Rectangle(Rect.X, Rect.Y, (int)(Rect.Width * ((float)progress / (float)goal)), Rect.Height); batch.Draw(background, progRect, Color.White); batch.Draw(tex, progRect, Color.White); batch.DrawString(Settings.equationFont, message, new Vector2(progRect.X + 10.0f, progRect.Y + 10.0f), Color.White); var Thickness = 2; tex = GraphUtils.GetTexture(g, Color.Cyan); // Draw top line batch.Draw(tex, new Rectangle(Rect.X, Rect.Y, Rect.Width, Thickness), Color.White); batch.Draw(tex, new Rectangle(Rect.X, Rect.Y, Thickness, Rect.Height), Color.White); batch.Draw(tex, new Rectangle((Rect.X + Rect.Width - Thickness), Rect.Y, Thickness, Rect.Height), Color.White); batch.Draw(tex, new Rectangle(Rect.X, Rect.Y + Rect.Height - Thickness, Rect.Width, Thickness), Color.White); }
public void Draw(SpriteBatch batch, GameTime gameTime) { int h = (int)(state.g.Viewport.Height * 0.75f); int w = (int)(state.g.Viewport.Width * 0.5f); var back = GraphUtils.GetTexture(state.g, new Color(0.0f, 0.0f, 0.0f, 0.85f)); var bounds = GraphUtils.CenteredRect(state.g.Viewport.Bounds, w, h); batch.Draw(back, bounds, Color.White); Vector2 pos = new Vector2(bounds.X + bounds.Width * .01f, bounds.Y); var fontHeight = Settings.otherFont.MeasureString("A").Y; int yPlus = (int)(fontHeight * 1.1f); foreach (var img in GameState.externalImages) { img.button.bounds = GraphUtils.FRect(bounds.X + bounds.Width - fontHeight, pos.Y, fontHeight, fontHeight); img.button.Draw(batch, state.g, gameTime); batch.DrawString(Settings.otherFont, img.filename, pos, Color.White); pos.Y += yPlus; } addButton.bounds = GraphUtils.FRect(pos.X, pos.Y, addButton.GetWidth() / 2, addButton.GetHeight() / 2); addButton.Draw(batch, state.g, gameTime); var closeScale = 4; closeButton.bounds = new Rectangle(bounds.X + bounds.Width - closeButton.GetWidth() / closeScale, bounds.Y + bounds.Height - closeButton.GetHeight() / closeScale, closeButton.GetWidth() / closeScale, closeButton.GetHeight() / closeScale); closeButton.Draw(batch, state.g, gameTime); }
public void Draw(SpriteBatch batch, GraphicsDevice g, GameWindow w, GameTime gameTime, InputState state) { // only draw if the tex is ready if (selected) { Rectangle rect = new Rectangle(bounds.X - 5, bounds.Y - 5, bounds.Width + 10, bounds.Height + 10); batch.Draw(Settings.selectedTexture, rect, Color.White); } batch.Draw(smallImage, bounds, Color.White); if (hover) { batch.Draw(GraphUtils.GetTexture(g, new Color(0.0f, 0.0f, 0.0f, 0.75f)), injectButton.bounds, Color.White); injectButton.Draw(batch, g, gameTime); } }
private void SharedConstructor(PicType type, GraphicsDevice g, GameWindow w, GameState state) { this.g = g; this.w = w; this.type = type; imageCancellationSource = new CancellationTokenSource(); smallImage = GraphUtils.GetTexture(g, Color.Black); bigImage = GraphUtils.GetTexture(g, Color.Black); InitButtons(state); if (type != PicType.GRADIENT) { Trees = new AptNode[3]; Machines = new StackMachine[3]; } else { Trees = new AptNode[1]; Machines = new StackMachine[1]; } }
public GameState Init(GraphicsDevice g, GameWindow window, ContentManager content) { state = new GameState(); state.r = new Random(); state.g = g; state.w = window; state.inputState = new InputState(); Settings.selectedTexture = GraphUtils.GetTexture(g, Color.Cyan); Settings.panelTexture = GraphUtils.GetTexture(g, new Color(0.0f, 0.0f, 0.0f, 0.75f)); state.lowFont = content.Load <SpriteFont>("equation-font"); state.hiFont = content.Load <SpriteFont>("equation-font-hi"); state.lowOtherFont = content.Load <SpriteFont>("other-font"); state.hiOtherFont = content.Load <SpriteFont>("other-font-hi"); PickFonts(content, g); LoadButtons(); state.imageAdder = new ImageAdder(state); //Tests.BreedingPairs(g, window); //Tests.BreedingSelf(g, window); //Tests.PicGenerate(g, window,state,this); //Console.ReadLine(); //Parsing(g, window); //Optimizing(g, window); //Console.ReadLine(); state.populationSize = Settings.POP_SIZE_COLUMNS * (Math.Max(Settings.POP_SIZE_COLUMNS - 1, 1)); Random r = state.r; state.pictures = GenPics(r); LayoutUI(); return(state); }