Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FlappyBird
- {
- class PlayingState : GameObjectList
- {
- Bird bird;
- GameObjectList pipes;
- int frameCounter;
- public PlayingState()
- {
- this.Add(new SpriteGameObject("spr_background"));
- pipes = new GameObjectList();
- this.Add(pipes);
- bird = new Bird();
- this.Add(bird);
- }
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
- if (frameCounter >100)
- {
- this.Add(new Pipe());
- frameCounter = 0;
- }
- frameCounter++;
- bool isGameOver = false;
- foreach (Pipe pipe in pipes.Children) {
- if (pipe.Overlaps(bird))
- {
- Console.WriteLine("lol");
- SetGameOver();
- //Pipe.Reset();
- }
- }
- if (isGameOver == true)
- {
- SetGameOver();
- }
- }
- public void SetGameOver()
- {
- pipes.Children.Clear();
- frameCounter = 0;
- bird.Reset();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement