Пример #1
0
        public MenuState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content)
            : base(game, graphicsDevice, content)
        {
            var buttonTexture = _content.Load <Texture2D>("Button");
            var buttonFont    = _content.Load <SpriteFont>("ButtonFont");


            var newGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 2 - buttonTexture.Width / 2, Game1.screenHeight / 2 - Game1.screenHeight / 10),
                Text     = "Play Game",
            };

            newGameButton.Click += NewGameButton_Click;

            var quitGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 2 - buttonTexture.Width / 2, Game1.screenHeight / 2 + Game1.screenHeight / 10),
                Text     = "Quit Game",
            };

            quitGameButton.Click += QuitGameButton_Click;

            _components = new List <Component>()
            {
                newGameButton,
                quitGameButton,
            };
        }
Пример #2
0
        public Endgame(Game1 game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            var buttonTexture = _content.Load <Texture2D>("Button");
            var buttonFont    = _content.Load <SpriteFont>("ButtonFont");

            var RestartGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 2 - buttonTexture.Width / 2, Game1.screenHeight / 2 - Game1.screenHeight / 10),
                Text     = "Play Again",
            };

            RestartGameButton.Click += RestartGameButton_Click;

            var MenuGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 2 - buttonTexture.Width / 2, Game1.screenHeight / 2 + Game1.screenHeight / 14),
                Text     = "Main Menu",
            };

            MenuGameButton.Click += MenuGameButton_Click;

            var quitGameButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 2 - buttonTexture.Width / 2, Game1.screenHeight / 2 + Game1.screenHeight / 4),
                Text     = "Quit Game",
            };

            quitGameButton.Click += QuitGameButton_Click;

            _components = new List <Component>()
            {
                RestartGameButton,
                MenuGameButton,
                quitGameButton,
            };
        }
Пример #3
0
        public GameState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content)
            : base(game, graphicsDevice, content)
        {
            difficultyCase = 0;
            _spriteBatch   = new SpriteBatch(_graphicsDevice);
            //use this.Content to load your game content here
            var ballTexture             = _content.Load <Texture2D>("Ball");
            var playerTexture           = _content.Load <Texture2D>("Player1");
            var player2Texture          = _content.Load <Texture2D>("player2");
            var buttonTexture           = _content.Load <Texture2D>("home");
            var buttonFont              = _content.Load <SpriteFont>("ButtonFont");
            var DifficultybuttonTexture = _content.Load <Texture2D>("difficultyButton");
            var DifficultybuttonFont    = _content.Load <SpriteFont>("ButtonDifficultyFont");
            var pausebuttonTexture      = _content.Load <Texture2D>("Pause");

            score      = new Score(_content.Load <SpriteFont>("File"));
            screenFont = new ScreenText(_content.Load <SpriteFont>("ScreenFont"));

            var HomeButton = new Button(buttonTexture, buttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 20, screenHeight - screenHeight / 10),
                Text     = "",
            };

            HomeButton.Click += HomeButton_Click;

            var PauseButton = new Button(pausebuttonTexture, buttonFont)
            {
                Position = new Vector2(screenWidth / 2, screenHeight - screenHeight / 20),
                Text     = "",
            };

            PauseButton.Click += PauseButton_Click;

            var DifficultyButton = new Button(DifficultybuttonTexture, DifficultybuttonFont)
            {
                Position = new Vector2(Game1.screenWidth / 8, screenHeight - screenHeight / 10),
                Text     = "Play Style",
            };

            DifficultyButton.Click += DifficultyButton_Click;

            var MultiplayerButton = new Button(DifficultybuttonTexture, DifficultybuttonFont)
            {
                Position = new Vector2((Game1.screenWidth / 4) * 3, screenHeight - screenHeight / 10),
                Text     = "Player 2",
            };

            MultiplayerButton.Click += MultiplayerButton_Click;

            _componentsPause = new List <Component>()
            {
                HomeButton,
                DifficultyButton,
                PauseButton,
                MultiplayerButton,
            };
            _components = new List <Component>()
            {
                PauseButton,
            };

            ball = new Ball(ballTexture)
            {
                position = new Vector2((screenWidth / 2) - (ballTexture.Width / 2), (screenHeight / 2) - (ballTexture.Height / 2)), //positions the ball in the centre of the screen
                score    = score,
            };

            AIplayer = new AIPlayer(player2Texture)
            {
                position = new Vector2(Game1.screenWidth - (Game1.screenWidth / 10), (screenHeight / 2) - (playerTexture.Height / 2)),
            };

            Player1 = new Player(playerTexture)
            {
                position = new Vector2(Game1.screenWidth / 15, (screenHeight / 2) - (playerTexture.Height / 2)),
            };

            //load in the sprites
            sprites = new List <Sprite>()
            {
                ball,
                Player1,
                AIplayer,
            };

            Pause       = false;
            Multiplayer = false;
        }