Skip to content

Commit b727afe

Browse files
upped to java 16, new difficulty configuration
1 parent 873b75f commit b727afe

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ allprojects {
2020
apply plugin: "eclipse"
2121

2222
version = '1.0'
23+
2324
ext {
2425
appName = "FlappyBird"
2526
gdxVersion = '1.12.1'
@@ -39,6 +40,11 @@ allprojects {
3940
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
4041
maven { url "https://jitpack.io" }
4142
}
43+
44+
tasks.withType(JavaCompile) {
45+
sourceCompatibility = '16'
46+
targetCompatibility = '16'
47+
}
4248
}
4349

4450
project(":desktop") {
@@ -73,7 +79,6 @@ project(":html") {
7379
project(":core") {
7480
apply plugin: "java-library"
7581

76-
7782
dependencies {
7883
api "com.badlogicgames.gdx:gdx:$gdxVersion"
7984

core/src/com/ninjaghost/flappy/MyGdxGame.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@
1010
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
1111
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
1212
import com.badlogic.gdx.math.Rectangle;
13-
import com.badlogic.gdx.Input;
1413
import com.badlogic.gdx.utils.ScreenUtils;
15-
import java.util.ArrayList;
16-
import java.util.List;
17-
import java.util.Random;
1814

19-
import static jdk.internal.org.jline.terminal.spi.TerminalProvider.Stream.Input;
15+
import java.util.*;
2016

2117
/**
2218
* Plan:
@@ -50,22 +46,39 @@ public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
5046

5147
Bird bird;
5248

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;
5365

5466
ArrayList<Rectangle> deathBoxes = new ArrayList<>();
5567
ArrayList<Float> floorOffsets = new ArrayList<>();
5668
ArrayList<Float> bgOffsets = new ArrayList<>();
5769
ArrayList<Float[]> pipeOffsets = new ArrayList<>();
5870
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;
6274

6375
Sprite player;
6476
float playerMovementConst = 75f;
6577
float playerVelocity = 0;
6678
float getPlayerVelocityFactor = 980;
6779
float playerJumpStrength = 250;
6880
boolean playerDead = false;
81+
int playerScore = 0;
6982

7083

7184
boolean cheat_freemove = false; // disables gravity, enables WASD movement
@@ -82,6 +95,8 @@ public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
8295
// UI stuff
8396
BitmapFont font;
8497

98+
99+
85100
@Override
86101
public void create () {
87102
Gdx.input.setInputProcessor(this);

0 commit comments

Comments
 (0)