// This class is kind of weird // First of all, all elements are drawn to external texture, why? // To ensure that the HUD is // a) drawn all at once // b) drawn over everything else (we will draw the HUD last in the draw order of the main draw function) // and c) not a part of collision detection // This also allows us to define custom behavior for drawing whatever sprites are added to // the HUD's list of sprites to draw. And adjust the color of the entire HUD itself. public HUD(Game game, GraphicsDevice d) : base(new RenderTarget2D(d, d.PresentationParameters.BackBufferWidth, d.PresentationParameters.BackBufferHeight, false, d.PresentationParameters.BackBufferFormat, DepthFormat.Depth24), false) { BasicSprite hud_key_frame = new BasicSprite(game, "hud_key_frame", false); hud_key_frame.spriteSize = new Point(60, 60); hud_key_frame.spritePos = new Vector2(740, 0); BasicSprite hud_health_frame = new BasicSprite(game, "health_bar_frame", false); hud_health_frame.spriteSize = new Point(200, 30); hud_health_frame.spritePos = new Vector2(1, 0); BasicSprite hud_health_color = new BasicSprite(game, "health_bar_color", false); hud_health_color.spriteSize = new Point(202, 32); hud_health_color.spritePos = new Vector2(0, 0); hud_key_frame.addTo(hudSprites); hud_health_color.addTo(hudSprites); hud_health_frame.addTo(hudSprites); gd = d; }
public AboutScreen(Game game) { about = new BasicSprite(game, "Interface\\aboutPage", false); about.spritePos = new Vector2(0, 100); returnButton = new BasicSprite(game, "Interface\\return", false); returnButton.spritePos = new Vector2(690, 20); about.addTo(aboutSprites); returnButton.addTo(aboutSprites); }
// This class is kind of weird // First of all, all elements are drawn to external texture, why? // To ensure that the HUD is // a) drawn all at once // b) drawn over everything else // and c) not a part of collision detection (most important reason) // This also allows us to define custom behavior for drawing whatever sprites are added to // the HUD's list of sprites to draw. And adjust the color of the entire HUD itself. public HUD(Game game) : base(new RenderTarget2D(game.GraphicsDevice, game.GraphicsDevice.PresentationParameters.BackBufferWidth, game.GraphicsDevice.PresentationParameters.BackBufferHeight), false) { spriteTex = new RenderTarget2D(game.GraphicsDevice, game.GraphicsDevice.PresentationParameters.BackBufferWidth, game.GraphicsDevice.PresentationParameters.BackBufferHeight); BasicSprite hud_key_frame = new BasicSprite(game, "hud_key_frame", false); hud_key_frame.spriteSize = new Point(60, 60); hud_key_frame.spritePos = new Vector2(740, 0); BasicSprite hud_health_frame = new BasicSprite(game, "health_bar_frame", false); hud_health_frame.spriteSize = new Point(200, 30); hud_health_frame.spritePos = new Vector2(1, 0); BasicSprite hud_insanity_frame = new BasicSprite(game, "insanity_bar_frame", false); hud_insanity_frame.spriteSize = new Point(200, 30); hud_insanity_frame.spritePos = new Vector2(211, 0); healthBar = new Bar(game, "health_bar_color"); healthBar.spriteSize = new Point(202, 32); healthBar.spritePos = new Vector2(0, 0); healthBar.level = 100; insanityBar = new Bar(game, "insanity_bar_color"); insanityBar.spriteSize = new Point(0, 32); insanityBar.spritePos = new Vector2(210, 0); insanityBar.level = 0; hud_key_frame.addTo(hudSprites); healthBar.addTo(hudSprites); hud_health_frame.addTo(hudSprites); insanityBar.addTo(hudSprites); hud_insanity_frame.addTo(hudSprites); gd = game.GraphicsDevice; }
public void addStatic(BasicSprite s) { s.addTo(statics); s.addTo(collidables); }
public void addFadeInObject(BasicSprite s) { s.addTo(fadeIns); }