private SpriteBatch spriteBatch;  //allows write to backbuffer to draw self
                                   // gameComponents = game1 -> GameComponents
 public BreakableWall(float x, float y, Color color, SpriteBatch spriteBatch, GameComponents gameComponents)
 {
     X = x;
     Y = y;
     imgBreakableWall = gameComponents.imgBreakableWall;
     Height           = imgBreakableWall.Height;
     Width            = imgBreakableWall.Width;
     this.spriteBatch = spriteBatch;
     Visible          = true;
     this.color       = color;
 }
Exemplo n.º 2
0
 public ActionScene(Game game, SpriteBatch spriteBatch, GraphicsDeviceManager graphics, GameComponents gameComponents,
                    Border border, Platform platform, Wall wall, Ball ball, Ball staticBall) : base(game)
 {
     this.gameComponents = gameComponents;
     this.spriteBatch    = spriteBatch;
     this.graphics       = graphics;
     this.wall           = wall;
     this.border         = border;
     this.platform       = platform;
     this.staticBall     = staticBall;
     this.ball           = ball;
 }
        // gameComponents = game1 -> GameComponents
        //use Wall constructor to incrment the layout of walls in 5x10 grid
        public Wall(float x, float y, SpriteBatch spriteBatch, GameComponents gameComponents)
        {
            //multi array 5 rows down 10  row across
            BreakableWall = new BreakableWall[5, 10];
            float breakableX = x;
            float breakableY = y;
            Color color      = new Color();

            //5 rows of bricks. set colors
            for (int i = 0; i < 5; i++)
            {
                switch (i)
                {
                case 0:
                    color = Color.MidnightBlue;
                    break;

                case 1:
                    color = Color.DarkBlue;
                    break;

                case 2:
                    color = Color.MediumBlue;
                    break;

                case 3:
                    color = Color.Blue;
                    break;

                case 4:
                    color = Color.DodgerBlue;
                    break;

                case 5:
                    color = Color.SteelBlue;
                    break;
                }
                breakableY = y + i * (gameComponents.imgBreakableWall.Height + 1);
                //for loop to spawn bricks using array created + colors set.
                for (int j = 0; j < 10; j++)
                {
                    breakableX = x + j * (gameComponents.imgBreakableWall.Width);
                    BreakableWall Breakable = new BreakableWall(breakableX, breakableY, color, spriteBatch, gameComponents);
                    BreakableWall[i, j] = Breakable;
                }
            }
        }
 public Ball(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameComponents gameComponents)
 {
     XVelocity           = 0;
     YVelocity           = 0;
     Rotation            = 0;
     X                   = 0;
     Y                   = 0;
     imgBall             = gameComponents.imgBall;
     Width               = imgBall.Width;
     Height              = imgBall.Height;
     this.spriteBatch    = spriteBatch;
     this.gameComponents = gameComponents;
     ScreenHeight        = screenHeight;
     ScreenWidth         = screenWidth;
     Visible             = false;
     Score               = 0;
     bricksCleared       = 0;
     UseRotation         = true;
 }
Exemplo n.º 5
0
        protected override void LoadContent()
        {
            // SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Texture2D tex2d = this.Content.Load <Texture2D>("Images/night-background_PNG");

            background = new Background(this, spriteBatch, tex2d);
            this.Components.Add(background);

            startScene = new StartScene(this, spriteBatch);
            this.Components.Add(startScene);

            helpScene = new HelpScene(this, spriteBatch);
            this.Components.Add(helpScene);
            //
            aboutScene = new AboutScene(this, spriteBatch);
            this.Components.Add(aboutScene);

            gameComponents = new GameComponents(Content);

            screenWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            //set game to 502x700 or screen max if smaller
            //500 + 2 for 1px borders
            //bricks 50px ea
            if (screenWidth >= 502)
            {
                screenWidth = 502;
            }
            if (screenHeight >= 700)
            {
                screenHeight = 700;
            }
            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.ApplyChanges();

            //// game objects platform position
            int platformX = (screenWidth - gameComponents.imgPlatform.Width) / 2; //center paddle on the screen to start
            int platformY = screenHeight - 75;                                    //paddle will be 75 pixels from the bottom of the screen

            ////instantiated objects
            platform = new Platform(platformX, platformY, screenWidth, spriteBatch, gameComponents);  // create the game platform
            wall     = new Wall(1, 50, spriteBatch, gameComponents);
            border   = new Border(screenWidth, screenHeight, spriteBatch, gameComponents);
            ball     = new Ball(screenWidth, screenHeight, spriteBatch, gameComponents);

            // egg image location (502x700y)- to show balls left
            staticBall             = new Ball(screenWidth, screenHeight, spriteBatch, gameComponents);
            staticBall.X           = 465;
            staticBall.Y           = 675;
            staticBall.Visible     = true;
            staticBall.UseRotation = false;

            // added all item components to action scene
            actionScene = new ActionScene(this, spriteBatch, graphics, gameComponents, border, platform, wall, ball, staticBall);
            this.Components.Add(actionScene);
            //
            // instantiation ends
            startScene.show();
        }
Exemplo n.º 6
0
 // gameComponents = game1 -> GameComponents
 //use own components not drawable game
 public Border(float screenWidth, float screenHeight, SpriteBatch spriteBatch, GameComponents gameComponents)
 {
     //use pixel component for border
     Width            = screenWidth;
     Height           = screenHeight;
     imgPixel         = gameComponents.imgPixel;
     this.spriteBatch = spriteBatch;
 }
Exemplo n.º 7
0
        }                                      //game screen


        public Platform(float x, float y, float screenWidth, SpriteBatch spriteBatch, GameComponents gameComponents)
        {
            X                = x;
            Y                = y;
            imgPlatform      = gameComponents.imgPlatform;
            Height           = imgPlatform.Height;
            Width            = imgPlatform.Width;
            ScreenWidth      = screenWidth;
            this.spriteBatch = spriteBatch;
        }