mirror of
https://github.com/Noratrieb/Java2DGame.git
synced 2026-01-15 22:45:00 +01:00
better collision
This commit is contained in:
parent
90c5950e0b
commit
69f784b913
8 changed files with 16 additions and 32 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue