10
10
import com .badlogic .gdx .graphics .g2d .SpriteBatch ;
11
11
import com .badlogic .gdx .graphics .glutils .ShapeRenderer ;
12
12
import com .badlogic .gdx .math .Rectangle ;
13
- import com .badlogic .gdx .Input ;
14
13
import com .badlogic .gdx .utils .ScreenUtils ;
15
- import java .util .ArrayList ;
16
- import java .util .List ;
17
- import java .util .Random ;
18
14
19
- import static jdk . internal . org . jline . terminal . spi . TerminalProvider . Stream . Input ;
15
+ import java . util .* ;
20
16
21
17
/**
22
18
* Plan:
@@ -50,22 +46,39 @@ public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
50
46
51
47
Bird bird ;
52
48
49
+ enum Difficulty {
50
+ EASY , MEDIUM , HARD
51
+ };
52
+ private record Settings (
53
+ String name ,
54
+ float pipeGap ,
55
+ float pipeSpawnFreq ,
56
+ float pipeMoveFactor
57
+ ) {}
58
+ Map <Difficulty , Settings > difficultySettingsMap = Map .of (
59
+ Difficulty .EASY , new Settings ("Easy" ,85f , 4f , 120f ),
60
+ Difficulty .MEDIUM , new Settings ("Medium" ,85f , 4f , 120f ),
61
+ Difficulty .HARD , new Settings ("Hard" ,85f , 1f , 240f )
62
+ );
63
+
64
+ Difficulty difficulty = Difficulty .EASY ;
53
65
54
66
ArrayList <Rectangle > deathBoxes = new ArrayList <>();
55
67
ArrayList <Float > floorOffsets = new ArrayList <>();
56
68
ArrayList <Float > bgOffsets = new ArrayList <>();
57
69
ArrayList <Float []> pipeOffsets = new ArrayList <>();
58
70
float pipeSpawnTimer = 0 ;
59
- float pipeSpawnTimerMax = 4 ;
60
- float pipeGapSize = 85f ;
61
- float pipeMovementConst = 120f ;
71
+ float pipeSpawnTimerMax = difficultySettingsMap . get ( difficulty ). pipeSpawnFreq ;
72
+ float pipeGapSize = difficultySettingsMap . get ( difficulty ). pipeGap ;
73
+ float pipeMovementConst = difficultySettingsMap . get ( difficulty ). pipeMoveFactor ;
62
74
63
75
Sprite player ;
64
76
float playerMovementConst = 75f ;
65
77
float playerVelocity = 0 ;
66
78
float getPlayerVelocityFactor = 980 ;
67
79
float playerJumpStrength = 250 ;
68
80
boolean playerDead = false ;
81
+ int playerScore = 0 ;
69
82
70
83
71
84
boolean cheat_freemove = false ; // disables gravity, enables WASD movement
@@ -82,6 +95,8 @@ public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
82
95
// UI stuff
83
96
BitmapFont font ;
84
97
98
+
99
+
85
100
@ Override
86
101
public void create () {
87
102
Gdx .input .setInputProcessor (this );
0 commit comments