Beispiel #1
0
 private bool CollisionWithPlayer(Fixture f1, Fixture f2,
     Contact contact, PlayerEntity player)
 {
     if (player.EatEnemiesInRange())
     {
         // If this enemy was eaten, it will become invalid so return false to cancel the collision.
         return this.IsValid;
     }
     return true;
 }
        public void InitialiseLevel()
        {
            Texture2D backgroundTexture = Content.Load<Texture2D>("background");
            _bgSprite1 = new SpriteEntity(backgroundTexture, ScreenCenter);
            base.ActiveEntities.Add(_bgSprite1);
            _bgSprite2 = new SpriteEntity(backgroundTexture, new Vector2(ScreenCenter.X + ScreenSizeDefault.X, ScreenCenter.Y));
            base.ActiveEntities.Add(_bgSprite2);

            Player = new PlayerEntity(this, Clips["player"], ScreenCenter);
            ActiveEntities.Add(Player);
        }
Beispiel #3
0
 private void ApplyImpactImpulse(PlayerEntity player)
 {
     Vector2 toPlayer = 0.075f * (player.Position - Position);
     player.DynamicBody.ApplyLinearImpulse(toPlayer);
 }