Ejemplo n.º 1
0
 public static void draw(StationarySprite a,SpriteBatch drawer, GraphicsDevice graphics,
     SpriteEffects effect, float rot, float depth)
 {
     drawer.Draw(a.img, new Rectangle((int)a.pos.X, (int)a.pos.Y, (int)a.dim.X, (int)a.dim.Y)
         , null, Color.White, rot, new Vector2(a.dim.X / 2, a.dim.Y / 2),
          effect, depth);
 }
Ejemplo n.º 2
0
 public Boolean isAbove(GameTime gameTime, StationarySprite b)
 {
     float newY = (float)pos.Y - speed.Y * (float)gameTime.ElapsedGameTime.TotalSeconds;
     float newX = (float)pos.X - speed.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
     return speed.Y > 0 && newY + dim.Y < b.pos.Y -
                 (b is Platform ? (b as Platform).maxHeight((int)newX, (int)(newX + dim.X)) : 0)
                 + dim.Y;
 }
Ejemplo n.º 3
0
 public Boolean isRightOf(GameTime gameTime,StationarySprite b)
 {
     return speed.X < 0 && pos.X - speed.X * (float)gameTime.ElapsedGameTime.TotalSeconds
         > b.pos.X + b.dim.X;
 }
Ejemplo n.º 4
0
 public Boolean isLeftOf(GameTime gameTime, StationarySprite b)
 {
     return speed.X > 0 && dim.X + pos.X
         - 2 * speed.X * (float)gameTime.ElapsedGameTime.TotalSeconds
         < b.pos.X;
 }
Ejemplo n.º 5
0
 public virtual Boolean intersects(StationarySprite other)
 {
     return new Rectangle((int)pos.X, (int)pos.Y, (int)dim.X, (int)dim.Y).Intersects(
            new Rectangle((int)other.pos.X, (int)other.pos.Y,
                 (int)(other.dim.X), (int)(other.dim.Y)));
 }
Ejemplo n.º 6
0
 public float distance(StationarySprite other)
 {
     double xDist = Math.Abs(getCenter().X-other.getCenter().X);
     double yDist = Math.Abs(getCenter().Y-other.getCenter().Y);
     return (float)Math.Sqrt(Math.Pow(xDist, 2) + Math.Pow(yDist, 2));
 }
Ejemplo n.º 7
0
 public StationarySprite(StationarySprite a)
 {
     img = a.img;
     pos = a.pos;
     dim = a.dim;
 }
Ejemplo n.º 8
0
 //Checks whether a sprite (really a player) is in a wind area
 public int isInWindArea(StationarySprite a)
 {
     foreach (Area r in areas) if (r.intersects(a) && r is WindArea)
         {
             WindArea ar = r as WindArea;
             if(ar.left)
                 return -1;
             else
             {
                 return 1;
             }
         }
     return 0;
 }
Ejemplo n.º 9
0
 //Checks whether a sprite is in a time-stopped area
 public Boolean timeStop(StationarySprite a)
 {
     foreach (Area r in areas) if (r.intersects(a) && r is TStopArea)
             return true;
     return false;
 }
Ejemplo n.º 10
0
 public float getLandFriction(StationarySprite a)
 {
     foreach (Area r in areas)
         if (r.intersects(a) && r is HeavyArea) return GROUND_FRICTION * 2;
     return GROUND_FRICTION;
 }
Ejemplo n.º 11
0
 //If a player is on land in an anti-grav area, they should go up
 public float getLandGravity(StationarySprite a)
 {
     foreach (Area r in areas)
         if (r.intersects(a) && r is ReverseArea) return GRAVITY * -.5f;
     return 0;
 }
Ejemplo n.º 12
0
 //Gets the local gravity for a sprite
 public float getGravity(StationarySprite a)
 {
     foreach (Area r in areas)
         if (r.intersects(a)&& r is ReverseArea) return GRAVITY * -1;
     foreach (Area r in areas)
         if (r.intersects(a) && r is HeavyArea) return GRAVITY * 2;
     return GRAVITY;
 }
Ejemplo n.º 13
0
 //Check whether a sprite intersects with anything
 public Boolean allIntersects(StationarySprite a)
 {
     List<StationarySprite> all = All();
     foreach (Area r in areas) all.Remove(r);
     for (int i = 0; i < all.Count; i++)
     {
         if (!all[i].Equals(a) && (all[i].intersects(a) || a.intersects(all[i])))
             return true;
     }
     return false;
 }
Ejemplo n.º 14
0
 public Boolean intersectsHill(StationarySprite other)
 {
     for (int i = 0; i < heights.Length; i++)
         if (new Rectangle(i + (int)pos.X, (int)pos.Y - heights[i], 1, heights[i]).Intersects(
             new Rectangle((int)other.pos.X, (int)other.pos.Y, (int)other.dim.X, (int)other.dim.Y)))
             return true;
     return false;
 }
Ejemplo n.º 15
0
 public Boolean intersectsBase(StationarySprite other)
 {
     return base.intersects(other);
 }
Ejemplo n.º 16
0
 public override Boolean intersects(StationarySprite other)
 {
     return (base.intersects(other)
             ||
             intersectsHill(other));
 }