Example #1
0
        // METHODS

        // UPDATE and DRAW
        public override void Update(GameTime gameTime, Input input, Game1 game)
        {
            this.startButton.Update(gameTime, input);
            this.scoreButton.Update(gameTime, input);
            this.settingsButton.Update(gameTime, input);
            this.quitButton.Update(gameTime, input);

            if (this.startButton.IsPressed())
            {
                game.ChangeMenu(MenuState.GAME);
            }
            if (this.settingsButton.IsPressed())
            {
                game.ChangeMenu(MenuState.SETTINGS);
            }
            if (this.scoreButton.IsPressed())
            {
                game.ChangeMenu(MenuState.SCORE);
            }
            if (this.quitButton.IsPressed())
            {
                game.Exit();
            }

            base.Update(gameTime, input, game);
        }
Example #2
0
        // METHODS

        // UPDATE and DRAW
        public override void Update(GameTime gameTime, Input input, Game1 game)
        {
            this.menuButton.Update(gameTime, input);

            if (this.menuButton.IsPressed())
            {
                game.ChangeMenu(MenuState.MAIN);
            }

            Console.WriteLine("{0}", Settings.gameMode);

            base.Update(gameTime, input, game);
        }
Example #3
0
        // METHODS

        // UPDATE and DRAW
        public override void Update(GameTime gameTime, Input input, Game1 game)
        {
            this.skyModeButton.Update(gameTime, input);
            this.seaModeButton.Update(gameTime, input);
            this.jungleModeButton.Update(gameTime, input);
            this.spaceModeButton.Update(gameTime, input);
            this.menuButton.Update(gameTime, input);


            if (this.skyModeButton.IsPressed())
            {
                Settings.gameMode = GameMODE.SKY;
                game.ChangeMenu(MenuState.MAIN);
            }
            if (this.seaModeButton.IsPressed())
            {
                Settings.gameMode = GameMODE.SEA;
                game.ChangeMenu(MenuState.MAIN);
            }
            if (this.jungleModeButton.IsPressed())
            {
                Settings.gameMode = GameMODE.JUNGLE;
                game.ChangeMenu(MenuState.MAIN);
            }
            if (this.spaceModeButton.IsPressed())
            {
                Settings.gameMode = GameMODE.SPACE;
                game.ChangeMenu(MenuState.MAIN);
            }
            if (this.menuButton.IsPressed())
            {
                game.ChangeMenu(MenuState.MAIN);
            }

            Console.WriteLine("{0}", Settings.gameMode);

            base.Update(gameTime, input, game);
        }
Example #4
0
        // UPDATE & DRAW
        public override void Update(GameTime gameTime, Input input, Game1 game)
        {
            base.Update(gameTime, input, game);

            if (!gameover)
            {
                this.ground.Update(gameTime, input);
                this.timer += gameTime.ElapsedGameTime.Milliseconds;

                foreach (Pipe pipe in new List <Pipe>(this.pipes))
                {
                    pipe.Update(gameTime, input);
                    if (pipe.ToDelete())
                    {
                        this.pipes.Remove(pipe);
                    }
                    if (this.player.CollisionWith(pipe))
                    {
                        this.gameover = true;
                        Resources.Sounds["pipe_hit"].Play();
                        break;
                    }
                    if (pipe.GetPipeType() == PipeType.TOP && !pipe.IsPassed() && this.player.X > pipe.Right)
                    {
                        pipe.SetPassed();
                        this.score += 1;
                        Resources.Sounds["pipe_pass"].Play();
                    }
                }

                if (this.player.CollisionWith(this.ground))
                {
                    this.gameover = true;
                    this.GameOver(gameTime);
                }
                else
                {
                    this.player.Update(gameTime, input);
                }

                if (!this.start)
                {
                    if (timer >= 1500)
                    {
                        this.start = true;
                        this.timer = 2000;
                        this.player.ActiveGravity();
                    }
                }
                else
                {
                    if (this.timer >= 2000)
                    {
                        this.timer = 0;

                        switch (Settings.gameMode)
                        {
                        case GameMODE.SKY:
                            int topPipeSkyY = this.random.Next(-400, -100);
                            int botPipeSkyY = topPipeSkyY + 1000;
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, topPipeSkyY, PipeType.TOP));
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, botPipeSkyY, PipeType.BOT));
                            break;

                        case GameMODE.SEA:
                            //int topPipeSeaY = this.random.Next(0, 200);
                            //int botPipeSeaY = topPipeSeaY + 700;
                            int topPipeSeaY = this.random.Next(-400, -100);
                            int botPipeSeaY = topPipeSeaY + 1000;
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, topPipeSeaY, PipeType.TOP));
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, botPipeSeaY, PipeType.BOT));
                            break;

                        case GameMODE.JUNGLE:
                            //int topPipeSeaY = this.random.Next(0, 200);
                            //int botPipeSeaY = topPipeSeaY + 700;
                            int topPipeJungleY = this.random.Next(-400, -100);
                            int botPipeJungleY = topPipeJungleY + 1000;
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, topPipeJungleY, PipeType.TOP));
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, botPipeJungleY, PipeType.BOT));
                            break;

                        case GameMODE.SPACE:
                            //int topPipeSeaY = this.random.Next(0, 200);
                            //int botPipeSeaY = topPipeSeaY + 700;
                            int topPipeSpaceY = this.random.Next(-400, -100);
                            int botPipeSpaceY = topPipeSpaceY + 1000;
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, topPipeSpaceY, PipeType.TOP));
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, botPipeSpaceY, PipeType.BOT));
                            break;


                        default:
                            int topPipeY = this.random.Next(-400, -100);
                            int botPipeY = topPipeY + 1000;
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, topPipeY, PipeType.TOP));
                            this.pipes.Add(new Pipe(Settings.SCREEN_WIDTH, botPipeY, PipeType.BOT));
                            break;
                        }
                    }
                }
            }

            else if (!this.setRotation)
            {
                if (!this.player.CollisionWith(this.ground))
                {
                    this.player.Update(gameTime, null);
                }
                else
                {
                    this.GameOver(gameTime);
                }
            }
            else
            {
                this.retryButton.Update(gameTime, input);
                if (this.retryButton.IsPressed())
                {
                    game.ChangeMenu(MenuState.GAME);
                }
                this.menuButton.Update(gameTime, input);
                if (this.menuButton.IsPressed())
                {
                    game.ChangeMenu(MenuState.MAIN);
                }
            }
        }