From 3d2973c5b1ea594c23a9b1d8324578ce3587465a Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 14 Jun 2022 19:35:32 +0000 Subject: [PATCH] Setup physics for Erinoah Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- src/sig/objects/Erinoah.java | 12 +++++------- src/sig/objects/Player.java | 6 +++++- src/sig/objects/actor/PhysicsObject.java | 6 +----- src/sig/objects/actor/PhysicsObjectRequirements.java | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/sig/objects/Erinoah.java b/src/sig/objects/Erinoah.java index 8fd6a31..67fd0a3 100644 --- a/src/sig/objects/Erinoah.java +++ b/src/sig/objects/Erinoah.java @@ -15,6 +15,11 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ setY(y); } + @Override + public Rectangle setCollisionBounds() { + return new Rectangle(12,4,24,38); + } + @Override public void update(double updateMult) { super.update(updateMult); @@ -31,18 +36,11 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ @Override public boolean rightKeyHeld() { - // TODO Auto-generated method stub return false; } @Override public boolean leftKeyHeld() { - // TODO Auto-generated method stub return false; } - - @Override - public Rectangle getCollisionBounds() { - return new Rectangle(8,2,16,30); - } } diff --git a/src/sig/objects/Player.java b/src/sig/objects/Player.java index 3042730..d94220b 100644 --- a/src/sig/objects/Player.java +++ b/src/sig/objects/Player.java @@ -66,7 +66,11 @@ public class Player extends PhysicsObject implements RenderedObject{ super(Sprite.ERINA, 5, panel); setX(RabiClone.BASE_WIDTH / 2 - getAnimatedSpr().getWidth() / 2); setY(RabiClone.BASE_HEIGHT * (2 / 3d) - getAnimatedSpr().getHeight() / 2); - setCollisionBounds(new Rectangle(10,2,12,27)); + } + + @Override + public Rectangle setCollisionBounds() { + return new Rectangle(10,2,12,27); } @Override diff --git a/src/sig/objects/actor/PhysicsObject.java b/src/sig/objects/actor/PhysicsObject.java index 083a3b0..465108f 100644 --- a/src/sig/objects/actor/PhysicsObject.java +++ b/src/sig/objects/actor/PhysicsObject.java @@ -26,6 +26,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj protected PhysicsObject(AnimatedSprite spr, double animationSpd, Panel panel) { super(spr, animationSpd, panel); + setCollisionBox(setCollisionBounds()); } @Override @@ -214,10 +215,5 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj public Rectangle getCollisionBounds() { return getCollisionBox(); } - - @Override - public void setCollisionBounds(Rectangle bounds) { - setCollisionBox(bounds); - } } diff --git a/src/sig/objects/actor/PhysicsObjectRequirements.java b/src/sig/objects/actor/PhysicsObjectRequirements.java index 3a24bca..fbfb612 100644 --- a/src/sig/objects/actor/PhysicsObjectRequirements.java +++ b/src/sig/objects/actor/PhysicsObjectRequirements.java @@ -6,5 +6,5 @@ public interface PhysicsObjectRequirements { boolean rightKeyHeld(); boolean leftKeyHeld(); Rectangle getCollisionBounds(); - void setCollisionBounds(Rectangle bounds); + Rectangle setCollisionBounds(); }