public Sprite(Texture2D image, float x, float y, float scale, SpriteEffects spriteEffect) : base(x, y, image.Width, image.Height, scale) { Image = image; this.bounds = new RectangleGraphic(x, y, image.Width, image.Height, scale); SpriteEffect = spriteEffect; }
public void DrawBounds(GraphicsHandler graphicsHandler, Color color) { RectangleGraphic scaledBounds = GetScaledBounds(); scaledBounds.Color = color; scaledBounds.Draw(graphicsHandler); }
// check if this overlaps with another rectangle public bool Overlaps(IntersectableRectangle other) { RectangleGraphic intersectRectangle = GetIntersectRectangle(); RectangleGraphic otherIntersectRectangle = other.GetIntersectRectangle(); return(intersectRectangle.GetX1().Round() <= otherIntersectRectangle.GetX2().Round() && intersectRectangle.GetX2().Round() >= otherIntersectRectangle.GetX1().Round() && intersectRectangle.GetY1().Round() <= otherIntersectRectangle.GetY2().Round() && intersectRectangle.GetY2().Round() >= otherIntersectRectangle.GetY1().Round()); }
public Frame(Texture2D image, float scale, SpriteEffects spriteEffect, RectangleGraphic bounds, int delay) : base(image, scale, spriteEffect) { if (bounds != null) { this.bounds = bounds; this.bounds.Scale = scale; } this.delay = delay; }
public override void DrawBounds(GraphicsHandler graphicsHandler, Color color) { if (map != null) { RectangleGraphic scaledCalibratedBounds = GetCalibratedScaledBounds(); scaledCalibratedBounds.Color = color; scaledCalibratedBounds.Draw(graphicsHandler); } else { base.DrawBounds(graphicsHandler, color); } }
// gets scaled bounds taking into account map camera position public RectangleGraphic GetCalibratedScaledBounds() { if (map != null) { RectangleGraphic scaledBounds = GetScaledBounds(); return(new RectangleGraphic( scaledBounds.GetX1().Round() - map.GetCamera().X.Round(), scaledBounds.GetY1().Round() - map.GetCamera().Y.Round(), scaledBounds.GetScaledWidth(), scaledBounds.GetScaledHeight() )); } else { return(GetScaledBounds()); } }
public void SetBounds(RectangleGraphic bounds) { currentFrame.SetBounds(bounds); }
public void SetBounds(RectangleGraphic hurtbox) { this.bounds = new RectangleGraphic(hurtbox.X, hurtbox.Y, hurtbox.Width, hurtbox.Height, Scale); }
public void SetBounds(float x, float y, int width, int height) { this.bounds = new RectangleGraphic(x, y, width, height, Scale); }
public GameObject(Texture2D image, float x, float y, float scale, SpriteEffects spriteEffect, RectangleGraphic bounds) : base(x, y) { this.animations = new Dictionary <string, Frame[]>(); this.animations.Add("DEFAULT", new Frame[] { new FrameBuilder(image, 0) .WithScale(scale) .WithSpriteEffect(spriteEffect) .WithBounds(bounds) .Build() }); this.currentAnimationName = "DEFAULT"; UpdateCurrentFrame(); this.startPositionX = x; this.startPositionY = y; this.previousX = x; this.previousY = y; }