Skip to content

Commit

Permalink
Fix issue with collision dimension <= 0
Browse files Browse the repository at this point in the history
There is now no collision, if the width/height of the collisionbox are <= 0.
Also fix the default value for the collisionBoxHeight and collisionBoxWidth from the annotation.
  • Loading branch information
steffen-wilke committed Apr 4, 2020
1 parent 180b568 commit 7c46a6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/de/gurkenlabs/litiengine/entities/CollisionEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@CollisionInfo(collision = true)
public abstract class CollisionEntity extends Entity implements ICollisionEntity {
private static final Logger log = Logger.getLogger(CollisionEntity.class.getName());

private static final double HEIGHT_FACTOR = 0.4;

private static final double WIDTH_FACTOR = 0.4;
Expand Down Expand Up @@ -130,7 +130,7 @@ public Collision getCollisionType() {
*/
@Override
public boolean hasCollision() {
return this.collision;
return this.collision && this.getCollisionBoxWidth() > 0 && this.getCollisionBoxHeight() > 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/de/gurkenlabs/litiengine/entities/CollisionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

boolean collision();

float collisionBoxHeight() default -1;
float collisionBoxHeight() default 0;

float collisionBoxWidth() default -1;
float collisionBoxWidth() default 0;

Valign valign() default Valign.DOWN;

Expand Down

0 comments on commit 7c46a6f

Please sign in to comment.