better collision

This commit is contained in:
nora 2020-12-13 15:57:39 +01:00
parent 90c5950e0b
commit 69f784b913
8 changed files with 16 additions and 32 deletions

View file

@ -58,7 +58,7 @@ public abstract class GameObject implements Drawable {
if (this instanceof Collidable) {
((Collidable) this).getHitbox().moveTo(position, size);
if (master.doesCollide((Collidable) this)) {
if (master.doesCollide((Collidable) this) != null) {
this.position = oldPos;
((Collidable) this).getHitbox().moveTo(oldPos, size);
}

View file

@ -33,11 +33,6 @@ public class Submarine extends GameObject implements Collidable {
moveTo(centerRelPos);
}
@Override
public boolean collidesWith(Collidable o) {
return hitbox.collidesWith(o.getHitbox());
}
@Override
public Hitbox getHitbox() {
return hitbox;

View file

@ -26,11 +26,6 @@ public class Wall extends GameObject implements Collidable {
public void update() {
}
@Override
public boolean collidesWith(Collidable o) {
return this.hitbox.collidesWith(o.getHitbox());
}
@Override
public Hitbox getHitbox() {
return hitbox;