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;
Sprite spr;
Panel panel;
Rectangle collisionBox;
public Rectangle getCollisionBox() {
return collisionBox;
}
public void setCollisionBox(Rectangle collisionBox) {
this.collisionBox = collisionBox;
}
protected Rectangle collisionBox;
public Panel getPanel() {
return panel;

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

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

@ -3,11 +3,11 @@ package sig.objects.actor;
import sig.RabiClone;
import sig.engine.AnimatedSprite;
import sig.engine.Panel;
import sig.engine.Rectangle;
import sig.engine.objects.AnimatedObject;
import sig.engine.objects.CollisionEntity;
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 NORMAL_FRICTION = 6400;
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;
import sig.engine.Rectangle;
public interface PhysicsObjectRequirements {
boolean rightKeyHeld();
boolean leftKeyHeld();
Rectangle getCollisionBounds();
void setCollisionBounds(Rectangle bounds);
}

Loading…
Cancel
Save