created physics system and new Drawable interface

This commit is contained in:
nora 2020-12-12 14:34:15 +01:00
parent 6bc1f74016
commit 87ca37c9ca
19 changed files with 390 additions and 43 deletions

View file

@ -1,14 +1,21 @@
package objects.world;
import core.Master;
import core.math.Vector2D;
import core.physics.Collidable;
import core.physics.Hitbox;
import core.physics.RectHitBox;
import objects.GameObject;
import java.awt.*;
public class Wall extends GameObject {
public class Wall extends GameObject implements Collidable {
private RectHitBox hitbox;
public Wall(double x, double y, double xSize, double ySize) {
super(x, y, xSize, ySize);
this.hitbox = new RectHitBox(new Vector2D(x, y), new Vector2D(xSize, ySize));
}
@Override
@ -19,4 +26,24 @@ public class Wall extends GameObject {
@Override
public void update(Master master) {
}
@Override
public boolean collidesWith(Collidable o) {
return this.hitbox.collidesWith(o.getHitbox());
}
@Override
public Hitbox getHitbox() {
return hitbox;
}
@Override
public Vector2D getCenterPos() {
return position;
}
@Override
public Vector2D getSize() {
return size;
}
}