Exemplo n.º 1
0
        public FlappyBirdMainGameScene(string _name) : base(_name)
        {
            FlappyBirdProperties.Init();

            SEObject background = new SEObject("background");

            background.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("background-day"));
            background.GetComponent().GetTransformComponent().SetSize(SEProperties.GetGameWindowWidth(),
                                                                      SEProperties.GetGameWindowHeight());
            background.GetComponent().GetSpriteComponent().SetLayerDepth(1.0f);
            AddChild(background);

            bird = new Bird();
            AddChild(bird);

            obstacleManager = new ObstacleManager();
            AddChild(obstacleManager);

            Ground ground = new Ground();

            AddChild(ground);

            AddChild(FlappyBirdProperties.GetScoreLabel());
            AddChild(FlappyBirdProperties.GetHighScoreLabel());
            AddChild(FlappyBirdProperties.GetTextLabel());
        }
Exemplo n.º 2
0
 public Ground() : base("ground")
 {
     xPositionLastPart = 0;
     for (int i = 0; i < 2; ++i)
     {
         CreateNewGroundPart();
         xPositionLastPart += SEProperties.GetGameWindowWidth();
     }
     xPositionLastPart = SEProperties.GetGameWindowWidth();
 }
Exemplo n.º 3
0
        public FlappyBirdCore()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = SEProperties.GetGameWindowWidth();
            graphics.PreferredBackBufferHeight = SEProperties.GetGameWindowHeight();
            graphics.IsFullScreen        = SEProperties.IsGameFullScreen();
            graphics.PreferMultiSampling = true;

            IsMouseVisible        = SEProperties.IsGameMouseVisible();
            Content.RootDirectory = "Content";
        }
Exemplo n.º 4
0
        private void CreateNewGroundPart()
        {
            SEObject groundPart = new SEObject("ground");

            groundPart.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("base"));
            groundPart.GetComponent().GetTransformComponent().SetPosition(xPositionLastPart, FlappyBirdProperties.GetGroundHeigth());
            groundPart.GetComponent().GetTransformComponent().SetSize(SEProperties.GetGameWindowWidth(), (int)(SEProperties.GetGameWindowHeight() - FlappyBirdProperties.GetGroundHeigth()));
            groundPart.GetComponent().GetTransformComponent().SetRectangle(new Rectangle((int)xPositionLastPart,
                                                                                         (int)FlappyBirdProperties.GetGroundHeigth(),
                                                                                         SEProperties.GetGameWindowWidth(),
                                                                                         (int)(SEProperties.GetGameWindowHeight() - FlappyBirdProperties.GetGroundHeigth())));
            groundPart.GetComponent().GetSpriteComponent().SetLayerDepth(0.0f);

            groundPart.GetComponent().GetTransformComponent().SetSpeed(4f);
            AddChild(groundPart);
        }
Exemplo n.º 5
0
        public Obstacle() : base("obstacle")
        {
            float shift = SEProperties.GetRandomizer().Next(0, 80);

            component.GetTransformComponent().SetSpeed(5.0f);
            bool isTopHigher = SEProperties.GetRandomizer().Next(0, 100) > 50 ? true : false;

            if (isTopHigher)
            {
                topHeight    += shift;
                bottmoHeight -= shift;
            }
            else
            {
                topHeight    -= shift;
                bottmoHeight += shift;
            }

            SEObject top = new SEObject("top");

            top.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("pipe-green"));
            top.GetComponent().GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() + 50, 0);
            top.GetComponent().GetTransformComponent().SetSize(width, topHeight);
            top.GetComponent().GetTransformComponent().SetSpeed(5.0f);
            top.GetComponent().GetSpriteComponent().SetEffect(SpriteEffects.FlipVertically);
            top.GetComponent().GetSpriteComponent().SetLayerDepth(1.0f);

            SEObject bottom = new SEObject("bottom");

            bottom.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("pipe-green"));
            bottom.GetComponent().GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() + 50, SEProperties.GetGameWindowHeight() - bottmoHeight);
            bottom.GetComponent().GetTransformComponent().SetSize(width, bottmoHeight);
            bottom.GetComponent().GetTransformComponent().SetSpeed(5.0f);
            bottom.GetComponent().GetSpriteComponent().SetLayerDepth(1.0f);

            AddChild(top);
            AddChild(bottom);

            isActive = true;
        }
Exemplo n.º 6
0
        public static void Init()
        {
            score     = 0;
            highScore = SerializationSystem.GetValue <int>("highScore.json");

            isBirdFly     = false;
            isGameWaiting = true;

            highScoreLabel = new SELabel(SEResourcesManager.GetFontByName("PixelFontScore"));
            highScoreLabel.GetComponent().GetFontComponent().SetText(highScore.ToString());
            highScoreLabel.GetComponent().GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() / 2, SEProperties.GetGameWindowHeight() / 8);

            scoreLabel = new SELabel(SEResourcesManager.GetFontByName("PixelFontScore"));
            scoreLabel.GetComponent().GetFontComponent().SetText(score.ToString());
            scoreLabel.GetComponent().GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() / 2, SEProperties.GetGameWindowHeight() / 20);

            textLabel = new SELabel(SEResourcesManager.GetFontByName("PixelFontText"));
            textLabel.GetComponent().GetFontComponent().SetText("Tap on space to play game");
            textLabel.GetComponent().GetTransformComponent().SetPosition(150, 400);

            groundHeigth = 450;
        }
Exemplo n.º 7
0
        public Bird() : base("bird")
        {
            scaleValue   = 1.4f;
            isFalling    = true;
            fallingSpeed = 5.0f;
            jumpSpeed    = 7.0f;

            component.GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("yellowbird-downflap"));
            component.GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() / 4, SEProperties.GetGameWindowHeight() / 2);
            component.GetTransformComponent().SetSize(component.GetSpriteComponent().GetSpriteWidth(),
                                                      component.GetSpriteComponent().GetSpriteHeight());
            component.GetTransformComponent().SetScale(scaleValue, scaleValue);
            component.GetTransformComponent().SetOriginRotatePosition(component.GetSpriteComponent().GetSpriteWidth() / 2, component.GetSpriteComponent().GetSpriteHeight() / 2);
            component.GetTransformComponent().SetSpeed(fallingSpeed);
            component.GetSpriteComponent().SetLayerDepth(0.1f);

            SESequentialChangeSprite changeSpriteAnim = new SESequentialChangeSprite(0.1f);

            changeSpriteAnim.AddSprite(SEResourcesManager.GetSpriteByName("yellowbird-midflap"));
            changeSpriteAnim.AddSprite(SEResourcesManager.GetSpriteByName("yellowbird-upflap"));
            changeSpriteAnim.AddSprite(SEResourcesManager.GetSpriteByName("yellowbird-downflap"));
            changeSpriteAnim.SetObject(this);
            component.GetActionComponent().AddAction("changeSprite", changeSpriteAnim);

            component.GetAudioSourceComponent().AddSound(@"FlappyBird\sfx_die");
            component.GetAudioSourceComponent().AddSound(@"FlappyBird\sfx_hit");
            component.GetAudioSourceComponent().AddSound(@"FlappyBird\sfx_point");
            component.GetAudioSourceComponent().AddSound(@"FlappyBird\sfx_swooshing");
            component.GetAudioSourceComponent().AddSound(@"FlappyBird\sfx_wing");
            component.GetAudioSourceComponent().SetVolume(0.1f);
            //component.GetAudioSourceComponent().SetVolume(0.0f);

            component.GetCircleColliderComponent().SetRadius(component.GetSpriteComponent().GetSpriteWidth() / 2);
            component.GetCircleColliderComponent().SetCenterPosition(component.GetTransformComponent().GetPosition().X,
                                                                     component.GetTransformComponent().GetPosition().Y);
        }
Exemplo n.º 8
0
 public override void Reload()
 {
     component.GetTransformComponent().SetPosition(SEProperties.GetGameWindowWidth() / 4, SEProperties.GetGameWindowHeight() / 2);
     isFalling = true;
     component.GetTransformComponent().SetRotateAngle(0.0f);
 }