public PacemakerComponent(Game game, Rectangle bounds) : base(game) { this.game = game; boundingRec = bounds; p = new PhysicsComponent(game, bounds); }
/** * Returns true if the PhysicsComponents are the same **/ public bool checkColliding(PhysicsComponent p) { if (p.id != id) { return bounds.Intersects(p.bounds); } return false; }
public void moveRight(List<PhysicsComponent> p) { int velocity = (int)Math.Round((decimal)(3*(game.Heart.BodyPressure/100))); bool collision = false; PhysicsComponent core = new PhysicsComponent(base.p); core.Update(base.boundingRec.X + velocity, base.boundingRec.Y); foreach (PhysicsComponent f in p) { collision = core.checkColliding(f); if (collision) return; } Position.X = Position.X + velocity; UpdateCollision(new Rectangle(base.boundingRec.X + velocity, base.boundingRec.Y, base.boundingRec.Width, base.boundingRec.Height)); }
/** * Just copies a class **/ public PhysicsComponent(PhysicsComponent rec) : this(rec.game, rec.bounds) { this.id = rec.id; totalID--; }