/// <summary> /// This method will draw the combined layers to the screen. /// NOTE: ALL DRAW TO SCREEN METHODS MUST SET THE RENDER TARGET TO null /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawToScreen(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(null); pack.sb.Begin(); pack.sb.Draw(pack.state.UI, Vector2.Zero, Color.White); pack.sb.End(); }
/// <summary> /// Draw the effects. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawEffects(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.effects); pack.sb.Begin(); pack.sb.Draw(pack.state.gameWorld, Vector2.Zero, Color.White); pack.sb.End(); }
/// <summary> /// This method will be called once before each pause, to take a "screenshot" which the pause menu will be drawn over. /// NOTE: ALL DRAW TO PAUSE METHODS MUST SET THE RENDER TARGET TO pack.state.pauseBG /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawToPause(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.pauseBG); pack.sb.Begin(); pack.sb.Draw(pack.state.UI, Vector2.Zero, Color.Gray); pack.sb.End(); }
/// <summary> /// This method will draw the options menu. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawPause(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(null); pack.sb.Begin(); pack.sb.Draw(pack.state.pauseBG, Vector2.Zero, Color.Gray); pack.sb.Draw(background, drawRect, null, Color.White); pack.sb.DrawString(font, "Return", POSITION_RETURN, Color.Black); pack.sb.End(); }
SpriteBatch sb; //The sprite batch, used to draw things. #endregion Fields #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="sb">The sprite batch</param> /// <param name="c">The content manager</param> public GameState(SpriteBatch sb, ContentManager c) { GameTime time = new GameTime(); controller = new Controller(); doPack = new doPacket(this, time, controller); drawPack = new drawPacket(this, time, sb); content = c; gameWorld = new RenderTarget2D(sb.GraphicsDevice, 1280, 720); effects = new RenderTarget2D(sb.GraphicsDevice, 1280, 720); UI = new RenderTarget2D(sb.GraphicsDevice, 1280, 720); pauseBG = new RenderTarget2D(sb.GraphicsDevice, 1280, 720); exitGame = false; playerPosition = new CollisionPoint(); cameraPosition = new Point(); paused = false; frameCaptured = false; }
public override void drawWorld(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.gameWorld); pack.sb.Begin(); //pack.sb.Draw(TextureLoader.junkSpaceBG, Vector2.Zero, Color.White); pack.sb.End(); pack.sb.GraphicsDevice.SetRenderTarget(pack.state.gameWorld); pack.sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Matrix.CreateTranslation(new Vector3(-pack.state.cameraPosition.X, -pack.state.cameraPosition.Y, 0)) * Matrix.CreateScale(1)); foreach (Doodad d in background) d.drawThis(pack); foreach (LevelBlock w in walls) w.drawThis(pack); foreach (GameObject o in objects) o.drawThis(pack); foreach (HitBoxInteractable h in interactables) h.drawThis(pack); pack.sb.End(); }
/// <summary> /// This method will draw all postprocessing effects on the game world, and then return it to the master game state. /// NOTE: ALL DRAW EFFECTS METHODS MUST SET THE RENDER TARGET TO pack.state.effects /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawEffects(drawPacket pack) { }
/// <summary> /// This method will draw all objects in the game world, and then return it to the master game state. /// NOTE: ALL DRAW WORLD METHODS MUST SET THE RENDER TARGET TO pack.state.gameWorld /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawWorld(drawPacket pack) { }
/// <summary> /// This draws the title menu to the screen /// </summary> /// <param name="pack">see drawPacket</param> public override void drawToScreen(drawPacket pack) { pack.sb.Begin(); pack.sb.Draw(bgImage, Vector2.Zero, Color.White); for(int i=0;i<totalItems;i++) { if(selectedIndex == i) c = Color.White; else c = Color.Gray; switch(i) { case 0: s = "Play Game"; v = POSITION_PLAY_GAME; break; case 1: s = "Credits"; v = POSITION_CREDITS; break; case 2: s = "Options"; v = POSITION_OPTIONS; break; case 3: s = "Exit"; v = POSITION_EXIT; break; case 4: s = "Level Editor"; v = POSITION_LEVEL_EDIT; break; } pack.sb.DrawString(TextureLoader.ArBonnie, s, v, c); } pack.sb.End(); }
/// <summary> /// Must be overridden. This method will draw the object into the game world. /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawThis(drawPacket pack) { }
/// <summary> /// This method will draw the slope. NOTE: This method is currently a placeholder. It needs a better implementation. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawThis(drawPacket pack) { float length = (float)Math.Sqrt((Math.Pow((end.X - start.X), 2)) + Math.Pow((end.Y - start.Y), 2)); if (repeatX) { float progress = 0; int counter = 0; drawRect.Height = height; drawRect.Width = sprite.Width; spriteRect.X = 0; spriteRect.Y = 0; spriteRect.Height = sprite.Height; spriteRect.Width = sprite.Width; while (progress < length) { drawRect.X = (int)(start.X + (counter * (Math.Cos(rotation) * sprite.Width))); drawRect.Y = (int)(start.Y + (counter * (Math.Sin(rotation) * sprite.Width))); if (length - progress < sprite.Width) { drawRect.Width = (int)(length - progress) + 1; spriteRect.Width = (int)(length - progress); } pack.sb.Draw(sprite, drawRect, spriteRect, tint, rotation, origin, effect, depth); progress += sprite.Width; counter++; } } else { drawRect.X = start.X; drawRect.Y = start.Y; drawRect.Height = height; drawRect.Width = (int)length + 1; pack.sb.Draw(sprite, drawRect, null, tint, rotation, origin, effect, depth); } }
/// <summary> /// This method will draw the doodad to the screen /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawThis(drawPacket pack) { pack.sb.Draw(sprite, position, Color.White); }
public override void drawThis(drawPacket pack) { drawRect.X = (int)_X; drawRect.Y = (int)_Y; drawRect.Width = (int)_Width; drawRect.Height = (int)_Height; pack.sb.Draw(sprite, drawRect, null, tint, rotation, origin, effect, depth); }
/// <summary> /// This is the basic draw method for every particle /// </summary> /// <param name="pack">see drawPacket</param> public void drawThis(drawPacket pack) { //Stuff }
/// <summary> /// This logic is for when the menu is paused, and thus, the options menu is shown. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawPause(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(null); pack.sb.Begin(); pack.sb.Draw(pack.state.pauseBG, Vector2.Zero, Color.Gray); }
/// <summary> /// This is the actual normal draw for the hub screen. /// </summary> /// <param name="pack">see drawPacket</param> private void drawThis(drawPacket pack) { pack.sb.Begin(); pack.sb.Draw(background, Vector2.Zero, Color.White); for (int i = 0; i < totalItems; i++) { if (i == selectedIndex) c = Color.White; else c = Color.Gray; switch (i) { case 0: pack.sb.Draw(playGame, POSITION_PLAY_GAME, c); break; case 1: pack.sb.Draw(goToDatabase, POSITION_GO_TO_DATABASE, c); break; case 2: pack.sb.Draw(goToOptions, POSITION_GO_TO_OPTIONS, c); break; case 3: pack.sb.Draw(exit, POSITION_EXIT, c); break; } } pack.sb.End(); }
/// <summary> /// No effects are necessary on the hub screen, only one draw is needed. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawToScreen(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(null); drawThis(pack); }
/// <summary> /// This will draw the game world. Every draw should be conditional, since null elements will be common. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawWorld(drawPacket pack) { if (graphics == null) graphics = pack.sb.GraphicsDevice; pack.sb.GraphicsDevice.SetRenderTarget(pack.state.gameWorld); //Set render target //Draw underlay without translation pack.sb.Begin(); if (underlay != null) pack.sb.Draw(underlay, Vector2.Zero, Color.White); pack.sb.End(); //Draw world pack.sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Matrix.CreateTranslation(new Vector3(-pack.state.cameraPosition.X, -pack.state.cameraPosition.Y, 0)) * Matrix.CreateScale(pack.state.cameraScale)); foreach (Doodad d in background) if (d.Sprite != null) d.drawThis(pack); foreach (LevelBlock w in walls) //Draw the world stuff if(w.Sprite != null) w.drawThis(pack); foreach (Doodad d in doodads) if (d.Sprite != null) d.drawThis(pack); foreach (GameObject o in objects) if(o.sprite != null) o.drawThis(pack); foreach (HitBoxInteractable h in interactables) if(h.Sprite != null) h.drawThis(pack); pack.sb.Draw(TextureLoader.redsquare, new Rectangle(-1, -1, (int)levelSize.X + 2, 2), Color.White);//Top pack.sb.Draw(TextureLoader.redsquare, new Rectangle(-1, -1, 2, (int)levelSize.Y + 2), Color.White);//Left pack.sb.Draw(TextureLoader.redsquare, new Rectangle(-1, (int)levelSize.Y, (int)levelSize.X + 2, 2), Color.White);//Bottom pack.sb.Draw(TextureLoader.redsquare, new Rectangle((int)levelSize.X, -1, 2, (int)levelSize.Y + 2), Color.White);//Right pack.sb.End(); }
/// <summary> /// Draws the cursor; /// </summary> /// <param name="pack">see drawPacket</param> public override void drawUI(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.UI); pack.sb.Begin(); pack.sb.Draw(pack.state.effects, Vector2.Zero, Color.White); pack.sb.Draw(TextureLoader.cursor, new Vector2(mNew.X, mNew.Y), Color.White); pack.sb.End(); }
/// <summary> /// This method will draw the pause menu of a state. The draw of the pause menu itself should be delegated to the pause menu state. /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawPause(drawPacket pack) { }
/// <summary> /// This is invoked if the options screen is selected, since options screen only appears on pause. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawToPause(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.pauseBG); drawThis(pack); }
/// <summary> /// This handles the drawing of garbage particles /// </summary> /// <param name="pack"></param> private void drawGarbage(drawPacket pack) { //Stuff }
/// <summary> /// This method will draw all UI components on the effects layer, and then return it to the master game state. /// NOTE: ALL DRAW UI METHODS MUST SET THE RENDER TARGET TO pack.state.UI /// </summary> /// <param name="pack">see drawPacket</param> public virtual void drawUI(drawPacket pack) { }
/// <summary> /// This method will draw the animation at the given position. /// </summary> /// <param name="pack">see drawPacket</param> /// <param name="position">The position to draw the animation at</param> public void drawThis(drawPacket pack, Vector2 position) { drawRect.X = (int)position.X; drawRect.Y = (int)position.Y; spriteRect.X = (width * currentFrame); spriteRect.Y = (height * currentRow); pack.sb.Draw(sprite, drawRect, spriteRect, Color.White); }
/// <summary> /// This method will draw the options menu. /// </summary> /// <param name="pack">see drawPacket</param> public void drawThis(drawPacket pack) { pack.sb.Draw(pack.state.pauseBG, Vector2.Zero, Color.Gray); pack.sb.Draw(TextureLoader.redsquare, drawRect, null, Color.LightGray); }
//EACH OF THE DRAW METHODS ARE DEFAULTS. Sometimes you may not want to draw all layers. //These defaults will pass the current frame through the layers unchanged. /// <summary> /// Draw the world. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawWorld(drawPacket pack) { pack.sb.GraphicsDevice.SetRenderTarget(pack.state.gameWorld); pack.sb.Begin(); foreach (Doodad d in background) d.drawThis(pack); foreach(GameObject o in objects) o.drawThis(pack); pack.sb.End(); }
/// <summary> /// This method will draw the animation /// </summary> /// <param name="pack">see drawPacket</param> public override void drawThis(drawPacket pack) { animation.drawThis(pack, position); }
/// <summary> /// Only one draw layer is needed for splash state. This will draw directly to screen. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawToScreen(drawPacket pack) { pack.sb.Begin(); pack.sb.Draw(background, Vector2.Zero, Color.White); pack.sb.End(); }
/// <summary> /// This calls the base class's draw. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawThis(drawPacket pack) { base.drawThis(pack); }
/// <summary> /// This will draw this bot into the game world. /// </summary> /// <param name="pack">see drawPacket</param> public override void drawThis(drawPacket pack) { }