public Blaster(float x, float y, SpriteBatch spriteBatch, GameContent gameContent) { this.gameContent = gameContent; Visible = true; imgBlaster = gameContent.imgBlaster; Width = imgBlaster.Width / 3; Height = imgBlaster.Height / 3; this.spriteBatch = spriteBatch; X = x - Width / 2; Y = y; }
public Bullet(float x, float y, SpriteBatch spriteBatch, GameContent gameContent) { Visible = true; imgPixel = gameContent.imgPixel; this.spriteBatch = spriteBatch; Width = imgPixel.Width * 5; Height = imgPixel.Height * 5; X = x - Width / 2; Y = y; this.gameContent = gameContent; }
public UFO(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameContent gameContent) { X = x; Y = y; ScreenWidth = screenWidth; this.gameContent = gameContent; imgUFO = gameContent.imgUFO; Width = imgUFO.Width / 5; Height = imgUFO.Height / 5; Visible = false; this.spriteBatch = spriteBatch; ufoSoundInstance = gameContent.ufoSound.CreateInstance(); }
public SpaceShip(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameContent gameContent) { X = x; Y = y; this.gameContent = gameContent; imgSpaceShip = gameContent.imgSpaceShip; Width = imgSpaceShip.Width / 4; Height = imgSpaceShip.Height / 4; this.spriteBatch = spriteBatch; ScreenWidth = screenWidth; bullets = new List <Bullet>(); Visible = true; }
public Alien(float x, float y, float screenWidth, float spaceShipHeight, SpriteBatch spriteBatch, GameContent gameContent) { blasters = new List <Blaster>(); X = x; Y = y; ScreenWidth = screenWidth; SpaceShipHeight = spaceShipHeight; this.gameContent = gameContent; imgAlien = gameContent.imgAlien; Width = imgAlien.Width * 7 / 40; Height = imgAlien.Height * 7 / 40; Visible = true; this.spriteBatch = spriteBatch; }
public AlienFleet(float x, float y, float screenWidth, float spaceShipHeight, SpriteBatch spriteBatch, GameContent gameContent) { this.gameContent = gameContent; aliens = new Alien[11, 5]; float alienX = x; float alienY = y; ScreenWidth = screenWidth; SpaceShipHeight = spaceShipHeight; for (int i = 0; i < 11; i++) { alienX = x + i * ((gameContent.imgAlien.Width + 1) * 7 / 40 + 35); for (int j = 0; j < 5; j++) { alienY = y + j * ((gameContent.imgAlien.Height + 1) * 7 / 40 + 35); Alien alien = new Alien(alienX, alienY, ScreenWidth, SpaceShipHeight, spriteBatch, gameContent); aliens[i, j] = alien; } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; if (screenWidth >= 2500) { screenWidth = 2500; } if (screenHeight >= 1250) { screenHeight = 1250; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); speed1 = gameContent.speed1Sound.CreateInstance(); speed2 = gameContent.speed2Sound.CreateInstance(); speed3 = gameContent.speed3Sound.CreateInstance(); speed4 = gameContent.speed4Sound.CreateInstance(); int spaceShipX = (screenWidth - gameContent.imgSpaceShip.Width / 4) / 2; int spaceShipY = screenHeight - 150; spaceShip = new SpaceShip(spaceShipX, spaceShipY, screenWidth, spriteBatch, gameContent); shields = new Shield[3]; for (int x = 0; x < 3; x++) { shields[x] = new Shield(screenWidth / 3 * x + screenWidth / 8, spaceShip.Y - 150, spriteBatch, GraphicsDevice); } alienFleet = new AlienFleet(50, 150, screenWidth, spaceShip.Y, spriteBatch, gameContent); ufo = new UFO(0, 60, screenWidth, spriteBatch, gameContent); gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent); }
private SpriteBatch spriteBatch; //allows us to write on backbuffer when we need to draw self public GameBorder(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameContent gameContent) { Width = screenWidth; Height = screenHeight; imgPixel = gameContent.imgPixel; this.spriteBatch = spriteBatch; }