split DinoWorld between simple and advanced example

# Conflicts:
#	src/main/java/example/JumpingDino.java
This commit is contained in:
2020-03-05 12:06:41 +01:00
parent 9b54b72a25
commit e67f40ad65
4 changed files with 83 additions and 77 deletions
@@ -0,0 +1,26 @@
package evironment.jumpingDino;
import core.State;
import java.awt.*;
public class DinoWorldAdvanced extends DinoWorld{
public DinoWorldAdvanced(){
super();
}
@Override
protected State generateReturnState() {
return new DinoStateWithSpeed(getDistanceToObstacle(), dino.isInJump(), getCurrentObstacle().getDx());
}
@Override
protected void spawnNewObstacle() {
int dx;
int xSpawn;
dx = -(int)((Math.random() + 0.5) * Config.OBSTACLE_SPEED);
// randomly spawning more right outside of the screen
xSpawn = (int)(Math.random() + 0.5 * Config.FRAME_WIDTH + Config.FRAME_WIDTH + Config.OBSTACLE_SIZE);
currentObstacle = new Obstacle(Config.OBSTACLE_SIZE, xSpawn, Config.FRAME_HEIGHT - Config.GROUND_Y - Config.OBSTACLE_SIZE, dx, 0, Color.BLACK);
}
}