Rearrange physics object specific methods so the hierarchy makes more sense

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent a982d13302
commit 8e35ea24d7
  1. 10
      src/sig/engine/objects/Object.java
  2. 12
      src/sig/objects/Erinoah.java
  3. 10
      src/sig/objects/Player.java
  4. 22
      src/sig/objects/actor/PhysicsObject.java
  5. 4
      src/sig/objects/actor/PhysicsObjectRequirements.java

@ -19,15 +19,7 @@ public abstract class Object implements GameEntity{
double x,y; double x,y;
Sprite spr; Sprite spr;
Panel panel; Panel panel;
Rectangle collisionBox; protected Rectangle collisionBox;
public Rectangle getCollisionBox() {
return collisionBox;
}
public void setCollisionBox(Rectangle collisionBox) {
this.collisionBox = collisionBox;
}
public Panel getPanel() { public Panel getPanel() {
return panel; return panel;

@ -43,14 +43,6 @@ public class Erinoah extends PhysicsObject implements RenderedObject{
@Override @Override
public Rectangle getCollisionBounds() { public Rectangle getCollisionBounds() {
// TODO Auto-generated method stub return new Rectangle(8,2,16,30);
return null; }
}
@Override
public void setCollisionBounds(Rectangle bounds) {
// TODO Auto-generated method stub
}
} }

@ -347,16 +347,6 @@ public class Player extends PhysicsObject implements RenderedObject{
+ getY() + "]"; + getY() + "]";
} }
@Override
public Rectangle getCollisionBounds() {
return getCollisionBox();
}
@Override
public void setCollisionBounds(Rectangle bounds) {
setCollisionBox(bounds);
}
@Override @Override
public Transform getSpriteTransform() { public Transform getSpriteTransform() {
return facing_direction?Transform.HORIZONTAL:Transform.NONE; return facing_direction?Transform.HORIZONTAL:Transform.NONE;

@ -3,11 +3,11 @@ package sig.objects.actor;
import sig.RabiClone; import sig.RabiClone;
import sig.engine.AnimatedSprite; import sig.engine.AnimatedSprite;
import sig.engine.Panel; import sig.engine.Panel;
import sig.engine.Rectangle;
import sig.engine.objects.AnimatedObject; import sig.engine.objects.AnimatedObject;
import sig.engine.objects.CollisionEntity;
import sig.map.Tile; import sig.map.Tile;
public abstract class PhysicsObject extends AnimatedObject implements CollisionEntity,PhysicsObjectRequirements{ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObjectRequirements{
final public static double GRAVITY = 1300; final public static double GRAVITY = 1300;
final public static double NORMAL_FRICTION = 6400; final public static double NORMAL_FRICTION = 6400;
final public static double NORMAL_JUMP_VELOCITY = -300; final public static double NORMAL_JUMP_VELOCITY = -300;
@ -202,4 +202,22 @@ public abstract class PhysicsObject extends AnimatedObject implements CollisionE
} }
} }
public Rectangle getCollisionBox() {
return collisionBox;
}
public void setCollisionBox(Rectangle collisionBox) {
this.collisionBox = collisionBox;
}
@Override
public Rectangle getCollisionBounds() {
return getCollisionBox();
}
@Override
public void setCollisionBounds(Rectangle bounds) {
setCollisionBox(bounds);
}
} }

@ -1,6 +1,10 @@
package sig.objects.actor; package sig.objects.actor;
import sig.engine.Rectangle;
public interface PhysicsObjectRequirements { public interface PhysicsObjectRequirements {
boolean rightKeyHeld(); boolean rightKeyHeld();
boolean leftKeyHeld(); boolean leftKeyHeld();
Rectangle getCollisionBounds();
void setCollisionBounds(Rectangle bounds);
} }

Loading…
Cancel
Save