public override void CustomUpdate() { component.GetCircleColliderComponent().SetCenterPosition(component.GetTransformComponent().GetPosition().X, component.GetTransformComponent().GetPosition().Y); component.GetActionComponent().StartAction("changeSprite"); if (isFalling) { if (component.GetTransformComponent().GetRotateAngle() < 1.5f) { component.GetTransformComponent().Rotate(0.03f); } component.GetTransformComponent().MoveDown(); if (SEKeyboardManager.CheckKeyDown(Keys.Space)) { Jump(); } } else { TimeSpan span = DateTime.Now - timeFalling; if ((span.TotalSeconds) > 0.2f) { component.GetTransformComponent().SetSpeed(fallingSpeed); isFalling = true; } component.GetTransformComponent().MoveUp(); } if ((GetComponent().GetTransformComponent().GetPositionY() > FlappyBirdProperties.GetGroundHeigth()) || (GetComponent().GetTransformComponent().GetPositionY() < 0)) { component.GetAudioSourceComponent().Play(@"FlappyBird\sfx_die"); Collapse(); } }
public override void Update() { if (FlappyBirdProperties.IsBirdFly()) { base.Update(); } else { if (FlappyBirdProperties.IsGameWaiting()) { bird.WaitRunGame(); } else { if (SEKeyboardManager.CheckKeyDown(Keys.Space)) { Reload(); } bird.GetComponent().GetCircleColliderComponent().SetCenterPosition(bird.GetComponent().GetTransformComponent().GetPosition().X, bird.GetComponent().GetTransformComponent().GetPosition().Y); if (bird.GetComponent().GetTransformComponent().GetPositionY() < FlappyBirdProperties.GetGroundHeigth()) { bird.GetComponent().GetTransformComponent().Rotate(0.02f); bird.GetComponent().GetTransformComponent().MoveDown(); } } } }
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); }