public GameBorder(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameContent gameContent) { Width = screenWidth; Height = screenHeight; imgPixel = gameContent.imgPixel; this.spriteBatch = spriteBatch; }
private SpriteBatch spriteBatch; //allows us to write on backbuffer when we need to draw self public Paddle(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameContent gameContent) { X = x; Y = y; imgPaddle = gameContent.imgPaddle; Width = imgPaddle.Width; Height = imgPaddle.Height; this.spriteBatch = spriteBatch; ScreenWidth = screenWidth; }
public Paddle(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameContent gameContent) { this.X = x; this.Y = y; _paddleImg = gameContent.PaddleImg; this.Width = _paddleImg.Width; this.Height = _paddleImg.Height; this.spriteBatch = spriteBatch; this.ScreenWidth = screenWidth; }
public Brick(float x, float y, Color color, SpriteBatch spriteBatch, GameContent gameContent) { X = x; Y = y; _brickImg = gameContent.BrickImg; Width = _brickImg.Width; Height = _brickImg.Height; this.spriteBatch = spriteBatch; Visible = true; _color = color; }
public Brick(float x, float y, Color color, SpriteBatch spriteBatch, GameContent gameContent) { X = x; Y = y; ImgBrick = gameContent.ImgBrick; Width = ImgBrick.Width; Height = ImgBrick.Height; this.spriteBatch = spriteBatch; Visible = true; this.color = color; }
public _wall(float x, float y, SpriteBatch spriteBatch, GameContent gameContent) { BrickWall = new Brick[7, 10]; float brickX = x; float brickY = y; Color color = Color.White; /* Rainbow loop */ for (int i = 0; i < 7; i++) { switch (i) { case 0: color = Color.Red; break; case 1: color = Color.Orange; break; case 2: color = Color.Yellow; break; case 3: color = Color.Green; break; case 4: color = Color.Blue; break; case 5: color = Color.Indigo; break; case 6: color = Color.Violet; break; } brickY = y + i * (gameContent.BrickImg.Height + 1); for (int j = 0; j < 10; j++) { brickX = x + j * (gameContent.BrickImg.Width); Brick brick = new Brick(brickX, brickY, color, spriteBatch, gameContent); BrickWall[i, j] = brick; } } } // End _wall()
public Ball(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameContent gameContent) { X = 0; Y = 0; XVelocity = 0; YVelocity = 0; Rotation = 0; imgBall = gameContent.imgBall; Width = imgBall.Width; Height = imgBall.Height; this.spriteBatch = spriteBatch; this.gameContent = gameContent; ScreenWidth = screenWidth; ScreenHeight = screenHeight; Visible = false; Score = 0; bricksCleared = 0; UseRotation = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); gameContent = new GameContent(this.Content); _screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; _screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; /* Set the game to 502x700 or screen max if smaller */ if (_screenWidth >= 502) { _screenWidth = 502; } if (_screenHeight >= 700) { _screenHeight = 700; } graphics.PreferredBackBufferWidth = _screenWidth; graphics.PreferredBackBufferHeight = _screenHeight; graphics.ApplyChanges(); /* Create game objects */ int paddleX = (_screenWidth - gameContent.PaddleImg.Width) / 2; // Center the image on the start int paddleY = _screenHeight - 100; // Paddle will be 100px from the bottom of the screen _paddle = new Paddle(paddleX, paddleY, _screenWidth, spriteBatch, gameContent); _wall = new _wall(1, 50, spriteBatch, gameContent); _gameBorder = new GameBorder(_screenWidth, _screenHeight, spriteBatch, gameContent); _ball = new Ball(_screenWidth, _screenHeight, spriteBatch, gameContent); _staticBall = new Ball(_screenWidth, _screenHeight, spriteBatch, gameContent); _staticBall.X = 25; _staticBall.Y = 25; _staticBall.Visible = true; _staticBall.UseRotation = false; MediaPlayer.Play(gameContent.MusicList[0]); MediaPlayer.Volume = 0.3f; }
protected override void LoadContent() { // Create new SpriteBatch for texture drawing. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: this.Content for loading game content gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; if (screenWidth >= 502) { screenWidth = 502; } if (screenHeight >= 700) { screenHeight = 700; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); // Game Objects int paddleX = (screenWidth - gameContent.ImgPaddle.Width) / 2; // center paddle int paddleY = screenHeight - 100; // paddle 100 pixels from bottom paddle = new Paddle(paddleX, paddleY, screenWidth, spriteBatch, gameContent); // create paddle wall = new Wall(1, 50, spriteBatch, gameContent); // create wall gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent); // create game border ball = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall = new Ball(screenWidth, screenHeight, spriteBatch, gameContent) // for indicating 'balls left' { X = 25, Y = 25, Visible = true, UseRotation = false }; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // 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 gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; //set game to 502x700 or screen max if smaller if (screenWidth >= 502) { screenWidth = 502; } if (screenHeight >= 700) { screenHeight = 700; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); //create game objects int paddleX = (screenWidth - gameContent.imgPaddle.Width) / 2; //we'll center the paddle on the screen to start int paddleY = screenHeight - 100; //paddle will be 100 pixels from the bottom of the screen paddle = new Paddle(paddleX, paddleY, screenWidth, spriteBatch, gameContent); // create the game paddle wall = new Wall(1, 50, spriteBatch, gameContent); gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent); ball = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall.X = 25; staticBall.Y = 25; staticBall.Visible = true; staticBall.UseRotation = false; }