예제 #1
0
        protected override void CreateExplosion(Vec2 pos)
        {
            float x = pos.x;
            float y = pos.y - 2f;

            Level.Add(new Frog(x, y, Rando.Double() < 0.5f));

            int amount = Rando.Int(2, 4);

            for (int i = 0; i < amount; i++)
            {
                float deg = (float)i * 360f / amount + Rando.Float(-10f, 10f);
                float rad = Maths.DegToRad(deg);

                float xDir = (float)Math.Cos(rad);
                float yDir = (float)Math.Sin(rad);

                Frog thing = new Frog(x, y, xDir > 0);
                thing.hSpeed = xDir * 3;
                thing.vSpeed = yDir * yDir * -3 - 2;

                Level.Add(thing);
            }

            for (int i = 0; i < 3; i++)
            {
                Level.Add(SmallSmoke.New(x + Rando.Float(-8f, 8f), y + Rando.Float(-8f, 8f)));
            }
        }
예제 #2
0
 private void Init(float xpos, float ypos, DuckPersona who)
 {
     this.position.x = xpos;
     this.position.y = ypos;
     this.alpha      = 1f;
     this.hSpeed     = Rando.Float(6f) - 3f;
     this.vSpeed     = (float)((double)Rando.Float(2f) - 1.0 - 1.0);
     this._sprite    = who.featherSprite.CloneMap();
     this._sprite.SetAnimation("feather");
     this._sprite.frame = Rando.Int(3);
     if (Rando.Double() > 0.5)
     {
         this._sprite.flipH = true;
     }
     else
     {
         this._sprite.flipH = false;
     }
     this.graphic = (Sprite)this._sprite;
     this._rested = false;
 }
예제 #3
0
        private void UpdateBehavior()
        {
            if (Math.Abs(hSpeed) + Math.Abs(vSpeed) < 0.1f)  //standing still
            {
                if (jumpTime > 0)
                {
                    jumpTime -= Maths.IncFrameTimer();
                }
                else
                {
                    hSpeed = jumpDirection * 3;
                    vSpeed = Rando.Float(-2f, -3f);

                    jumpTime = Rando.Float(0.5f, 1.5f);
                    if (Rando.Double() < 0.15f)
                    {
                        jumpDirection = -jumpDirection;
                    }
                }
            }
        }