Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            PlayingState PS = GameWorld as PlayingState;

            foreach (Mushroom item in PS.Mushroom.Objects)
            {
                if (this.CollidesWith(item))
                {
                    this.Reset();
                    PS.Mushroom.Remove(item);
                    break;
                }
            }

            foreach (SnakeSegment item in PS.Snake.Objects)
            {
                if (this.CollidesWith(item))
                {
                    PS.Score.ScoreValue += 10;
                    this.Reset();
                    PS.Mushroom.Add(new Mushroom(item.Position));
                    PS.Snake.Remove(item);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 protected override void LoadContent()
 {
     spriteBatch  = new SpriteBatch(GraphicsDevice);
     screen       = new Point(1280, 720);
     playingState = new PlayingState();
     gameOver     = new GameOver();
     ApplyResolutionSettings();
     gameStateManager.AddGameState("TitleScreen", new TitleScreen());
     gameStateManager.AddGameState("PlayingState", playingState);
     gameStateManager.AddGameState("GameOver", gameOver);
     gameStateManager.SwitchTo("TitleScreen");
 }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            PlayingState PS = GameWorld as PlayingState;

            foreach (SnakeSegment snakeSegment in PS.snakeSegments.Objects)
            {
                if (this.CollidesWith(snakeSegment))
                {
                    this.Reset();
                    PS.mushrooms.Add(new Mushroom(snakeSegment.Position));
                    PS.snakeSegments.Remove(snakeSegment);
                    PS.score.ScoreValue += 10;
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (this.Position.X >= (Centipede.Screen.X - Sprite.Width) || this.position.X < 0)
            {
                this.Bounce();
            }

            PlayingState PS = GameWorld as PlayingState;

            foreach (Mushroom item in PS.Mushroom.Objects)
            {
                if (this.CollidesWith(item))
                {
                    this.Bounce();
                }
            }

            if (this.CollidesWith(PS.Player))
            {
                Centipede.GameStateManager.SwitchTo(Centipede.gameoverState);
            }
        }