public override void onUpdate() { Vector gravity = new Vector(0, 1); Vector acc = Vector.Zero; Vector friction = new Vector(.08f, 0); if ((plr.Position - Gob.Position).Length < 1400) { bool isPlayerOnRight = (plr.X - Gob.X) > 0; if (isPlayerOnRight) { acc += Vector.UnitX * (.4f + (surface.Y < .2 ? .5f : 0)); } else { acc -= Vector.UnitX * (.4f + (surface.Y < .2 ? .5f : 0)); } if (surface.Y > .8f) { jumping = true; acc -= gravity * Math.Min(23, Math.Max(Gob.Y - plr.Y, 0)); } } acc += gravity; Gob.Velocity += acc; Gob.Velocity -= new Vector(Gob.Velocity.X * friction.X, Gob.Velocity.Y * friction.Y); Gob.Position += Gob.Velocity; Collisions <Wall> wallColls = Gob.currentCollisions <Wall>(); surface = Vector.Zero; foreach (Collision <Wall> c in wallColls) { Gob.Position -= c.MTV; Gob.Velocity = c.Normal.Perpendicular * c.Normal.Perpendicular.dot(Gob.Velocity); if (c.Normal.Y > .8f) { surface = c.Normal; jumping = false; } } if (Gob.Bounds.getCollisionInfo(plr.Bounds) != null) { Gob.close(); } }
public override void onUpdate() { Color c = Gob.Sprite.Color; c.A = (c.A * Gob.Decay) / (Gob.Decay + 1); Gob.Sprite.Color = c; Gob.Y -= .3f; if (c.A < 1) { Gob.close(); } //Gob.Position += Gob.Dir * Gob.Speed; }