private void LoadFallingBrick() { GameContent gameContent = new GameContent(mContentManager); SpriteBatch sB = new SpriteBatch(graphicsDevice); // fallingBrick = new BrickDrop( (float)2f * (ScreenGlobals.SCREEN_WIDTH / 3f), (float)(ScreenGlobals.SCREEN_HEIGHT / 3f), sB, gameContent ); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { GameContent gameContent = new GameContent(Content); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here _currentState = new GameState(this, graphics.GraphicsDevice, Content); //_currentState.LoadContent(); if (_currentState.GetStateType() == true) { mPlayerSprite.LoadContent(this.Content); } }
public BrickDrop(float x, float y, SpriteBatch spriteBatch, GameContent gameContent) : base(x, y, spriteBatch, gameContent) { float brickX = x; float brickY = y; Color color = Color.Firebrick; Visible = true; int i = GenRandInt(); switch (i) { case 0: color = Color.Red; fire = true; break; case 1: color = Color.Blue; fire = false; break; } // X is overridden anyway with rand and Y is always 0 could get rid of that but base sprite needs the x,y FallingBrick = new Brick(brickX, brickY, color, spriteBatch, gameContent); }
private void CheckBulletBrickHit() { bool hitBrick = false; if (hitBrick == false) { // check player and brick detection if (fallingBrick.Visible) { // loop through bulltets if (mBullets.Count >= 1) { foreach (Bullet bullet in mBullets) { if (bullet != null) { if (fallingBrick.Visible) { //Brick //Each brick is 16 x 50 int orY = (int)fallingBrick.Origin.Y; int orX = (int)fallingBrick.Origin.X; Rectangle BrickRect = new Rectangle( (int)fallingBrick.GetX(), (int)fallingBrick.GetY() - orY - 1, (int)16, (int)50 ); // bullet Rectangle bulletRect = new Rectangle( (int)bullet.Position.X, (int)bullet.Position.Y, (int)bullet.Size.Width, (int)bullet.Size.Height); if (HitTest(bulletRect, BrickRect)) { // // if both fire GameContent gameContent = new GameContent(mContentManager); if (bullet.isFire() == true && fallingBrick.fire == true) { PlaySound(gameContent.brickSound); fallingBrick.Visible = false; bullet.Visible = false; ++score; } // if both ice else if ((!bullet.isFire() == true) && (!fallingBrick.fire == true)) { PlaySound(gameContent.brickSound); fallingBrick.Visible = false; bullet.Visible = false; ++score; } else // bullet hit but was wrong type { bullet.Visible = false; } hitBrick = true; break; } } } } } } } }