Example #1
0
 /// <summary>
 /// Renders an Entity at a specified X Y position.
 /// </summary>
 /// <param name="e">The Entity to render.</param>
 /// <param name="x">The X position to place the Entity for rendering.</param>
 /// <param name="y">The Y position to place the Entity for rendering.</param>
 public static void Entity(Entity e, float x = 0, float y = 0) {
     var tempX = e.X;
     var tempY = e.Y;
     e.SetPosition(x, y);
     Entity(e);
     e.SetPosition(tempX, tempY);
 }
        public override void Collide(Entity entity)
        {
            base.Enter(entity);

            if (entity is PlayerEntity)
                ((PlayerEntity)entity).OnGrounded();
            else
                return;

            Block block;
            if (Id % 2 == 0)
                block = Level.GetBlockById(Id + 1);
            else
                block = Level.GetBlockById(Id - 1);

            entity.SetPosition(block.GetPosition() - new Vector2(0, entity.GetBounds().Height));
            float vy = Math.Min(-500, entity.GetVelocity().Y * -.89f);
            entity.SetVelocity(0, vy);
        }
Example #3
0
 private static void StandardInit(Entity ent, string name, int tileSize, float scale, Vector2 pos)
 {
     ent.Name = name;
     ent.Scale = scale;
     ent.TileSize = tileSize;
     ent.SetPosition(pos);
 }