mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-01-18 10:23:58 +08:00
Remove unused properties from moving obstacles on backend
This commit is contained in:
parent
3bcc7f2198
commit
4de7fc4b62
@ -1,12 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.libertybikes.game.core;
|
||||
|
||||
public class MovingObstacle extends Obstacle {
|
||||
|
||||
public int xDir, yDir, oldX, oldY, moveDelay, currentDelay = 0;
|
||||
public boolean hasMoved = false;
|
||||
private int xDir, yDir, moveDelay, currentDelay = 0;
|
||||
|
||||
public MovingObstacle(int w, int h, int x, int y) {
|
||||
super(w, h, x, y);
|
||||
@ -62,14 +58,10 @@ public class MovingObstacle extends Obstacle {
|
||||
|
||||
if (++currentDelay < moveDelay) {
|
||||
// don't move yet
|
||||
hasMoved = false;
|
||||
return;
|
||||
}
|
||||
|
||||
hasMoved = true;
|
||||
currentDelay = 0;
|
||||
oldX = x;
|
||||
oldY = y;
|
||||
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.libertybikes.game.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -74,7 +71,7 @@ public class JsonDataTest {
|
||||
jsonb.toJson(board));
|
||||
|
||||
board.addObstacle(new MovingObstacle(11, 12, 13, 14, -1, 2, 50));
|
||||
assertEquals("{\"movingObstacles\":[{\"height\":12,\"width\":11,\"x\":13,\"y\":14,\"currentDelay\":0,\"hasMoved\":false,\"moveDelay\":50,\"oldX\":0,\"oldY\":0,\"xDir\":-1,\"yDir\":2}],\"obstacles\":["
|
||||
assertEquals("{\"movingObstacles\":[{\"height\":12,\"width\":11,\"x\":13,\"y\":14}],\"obstacles\":["
|
||||
+ obstacleJson + "],\"players\":[" + bobJson + "]}",
|
||||
jsonb.toJson(board));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user