| 1 | package io.github.some_example_name; | |
| 2 | ||
| 3 | import com.badlogic.gdx.math.Rectangle; | |
| 4 | import com.badlogic.gdx.math.Vector2; | |
| 5 | ||
| 6 | public class DeanLogic { | |
| 7 | ||
| 8 | private final Vector2 position; | |
| 9 | private final Vector2 startPosition; | |
| 10 | private boolean repelled = false; | |
| 11 | private final float speed; | |
| 12 | ||
| 13 | public DeanLogic(float x, float y, float speed) { | |
| 14 | this.position = new Vector2(x, y); | |
| 15 | this.startPosition = new Vector2(x, y); | |
| 16 | this.speed = speed; | |
| 17 | } | |
| 18 | ||
| 19 | public void update(Vector2 playerPos, float delta, CellBlockChecker checker) { | |
| 20 | Vector2 direction = new Vector2(playerPos).sub(position).nor(); | |
| 21 | ||
| 22 |
3
1. update : Replaced float multiplication with division → SURVIVED 2. update : Replaced float multiplication with division → SURVIVED 3. update : Replaced float addition with subtraction → KILLED |
float newX = position.x + direction.x * speed * delta; |
| 23 |
3
1. update : Replaced float multiplication with division → SURVIVED 2. update : Replaced float addition with subtraction → SURVIVED 3. update : Replaced float multiplication with division → SURVIVED |
float newY = position.y + direction.y * speed * delta; |
| 24 | ||
| 25 |
1
1. update : negated conditional → KILLED |
if (!checker.isCellBlocked(newX, newY)) { |
| 26 | position.set(newX, newY); | |
| 27 | } | |
| 28 | } | |
| 29 | ||
| 30 | public boolean caughtPlayer(Vector2 playerPos) { | |
| 31 |
2
1. caughtPlayer : negated conditional → KILLED 2. caughtPlayer : replaced boolean return with true for io/github/some_example_name/DeanLogic::caughtPlayer → KILLED |
if (repelled) return false; |
| 32 | ||
| 33 | Rectangle deanRect = new Rectangle(position.x, position.y, 16, 16); | |
| 34 | Rectangle playerRect = new Rectangle(playerPos.x, playerPos.y, 16, 16); | |
| 35 |
2
1. caughtPlayer : replaced boolean return with true for io/github/some_example_name/DeanLogic::caughtPlayer → SURVIVED 2. caughtPlayer : replaced boolean return with false for io/github/some_example_name/DeanLogic::caughtPlayer → KILLED |
return deanRect.overlaps(playerRect); |
| 36 | } | |
| 37 | ||
| 38 | public void resetToStart() { | |
| 39 | position.set(startPosition); | |
| 40 | } | |
| 41 | ||
| 42 | public void setRepelled(boolean repelled) { | |
| 43 | this.repelled = repelled; | |
| 44 | } | |
| 45 | ||
| 46 | public Vector2 getPosition() { | |
| 47 |
1
1. getPosition : replaced return value with null for io/github/some_example_name/DeanLogic::getPosition → KILLED |
return position; |
| 48 | } | |
| 49 | } | |
Mutations | ||
| 22 |
1.1 2.2 3.3 |
|
| 23 |
1.1 2.2 3.3 |
|
| 25 |
1.1 |
|
| 31 |
1.1 2.2 |
|
| 35 |
1.1 2.2 |
|
| 47 |
1.1 |