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; }
private SpriteBatch spriteBatch; //allows us to write on backbuffer when we need to draw self 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; for (int i = 0; i < 7; i++) { switch (i) { case 0: color = Color.DarkBlue; break; case 1: color = Color.Blue; break; case 2: color = Color.CornflowerBlue; break; case 3: color = Color.SkyBlue; break; case 4: color = Color.LightSkyBlue; break; case 5: color = Color.LightBlue; break; case 6: color = Color.AliceBlue; break; } brickY = y + i * (gameContent.imgBrick.Height + 1); for (int j = 0; j < 10; j++) { brickX = x + j * (gameContent.imgBrick.Width); Brick brick = new Brick(brickX, brickY, color, spriteBatch, gameContent); BrickWall[i, j] = brick; } } }
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); // TODO: use this.Content to load your game content here 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(); int paddleX = (screenWidth - gameContent.imgPaddle.Width) / 2; int paddleY = (screenHeight - 100); 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; }
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; }