Skip to content

Commit 6dc0482

Browse files
Refac
1 parent 9bfdde3 commit 6dc0482

File tree

16 files changed

+59
-72
lines changed

16 files changed

+59
-72
lines changed

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/rendering/ArcadeMsPacMan_GameRenderer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import static de.amr.pacmanfx.Globals.HTS;
2929
import static de.amr.pacmanfx.Globals.TS;
30-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
3130
import static de.amr.pacmanfx.ui._2d.ArcadePalette.*;
3231
import static java.util.Objects.requireNonNull;
3332
import static java.util.function.Predicate.not;
@@ -79,8 +78,8 @@ public void drawHUD(GameContext gameContext, HUD hud, Vector2f sceneSize, long t
7978
if (hud.isScoreVisible()) {
8079
ctx.setFont(assets().arcadeFont(scaled(8)));
8180
ctx.setFill(ARCADE_WHITE);
82-
drawScore(gameContext.theGame().score(), "SCORE", tiles_to_px(1), tiles_to_px(1));
83-
drawScore(gameContext.theGame().highScore(), "HIGH SCORE", tiles_to_px(14), tiles_to_px(1));
81+
drawScore(gameContext.theGame().score(), "SCORE", TS(1), TS(1));
82+
drawScore(gameContext.theGame().highScore(), "HIGH SCORE", TS(14), TS(1));
8483
}
8584

8685
if (hud.isLevelCounterVisible()) {
@@ -118,7 +117,7 @@ private void drawScore(Score score, String title, double x, double y) {
118117
fillTextAtScaledPosition(title, x, y);
119118
fillTextAtScaledPosition("%7s".formatted("%02d".formatted(score.points())), x, y + TS + 1);
120119
if (score.points() != 0) {
121-
fillTextAtScaledPosition("L" + score.levelNumber(), x + tiles_to_px(8), y + TS + 1);
120+
fillTextAtScaledPosition("L" + score.levelNumber(), x + TS(8), y + TS + 1);
122121
}
123122
}
124123

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/scenes/ArcadeMsPacMan_CutScene1.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel.*;
2323
import static de.amr.pacmanfx.arcade.ms_pacman.rendering.ArcadeMsPacMan_PacAnimationMap.PAC_MAN_MUNCHING;
2424
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
25-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2625
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_GHOST_NORMAL;
2726
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
2827

@@ -74,7 +73,7 @@ public void doInit() {
7473
pinky.setAnimations(config.createGhostAnimations(pinky));
7574

7675
clapperboard = new Clapperboard("1", "THEY MEET");
77-
clapperboard.setPosition(tiles_to_px(3), tiles_to_px(10));
76+
clapperboard.setPosition(TS(3), TS(10));
7877
clapperboard.setFont(scaledArcadeFont8());
7978
clapperboard.startAnimation();
8079

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/scenes/ArcadeMsPacMan_CutScene2.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel.createPacMan;
1919
import static de.amr.pacmanfx.arcade.ms_pacman.rendering.ArcadeMsPacMan_PacAnimationMap.PAC_MAN_MUNCHING;
2020
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
21-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2221
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
2322

2423
/**
@@ -53,7 +52,7 @@ public void doInit() {
5352
pacMan.setAnimations(ui.currentConfig().createPacAnimations(pacMan));
5453

5554
clapperboard = new Clapperboard("2", "THE CHASE");
56-
clapperboard.setPosition(tiles_to_px(3), tiles_to_px(10));
55+
clapperboard.setPosition(TS(3), TS(10));
5756
clapperboard.setFont(scaledArcadeFont8());
5857
clapperboard.startAnimation();
5958

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/scenes/ArcadeMsPacMan_CutScene3.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel.createPacMan;
2222
import static de.amr.pacmanfx.arcade.ms_pacman.rendering.ArcadeMsPacMan_PacAnimationMap.PAC_MAN_MUNCHING;
2323
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
24-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2524
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
2625

2726
/**
@@ -65,7 +64,7 @@ public void doInit() {
6564
pacMan.setAnimations(config.createPacAnimations(pacMan));
6665

6766
clapperboard = new Clapperboard("3", "JUNIOR");
68-
clapperboard.setPosition(tiles_to_px(3), tiles_to_px(10));
67+
clapperboard.setPosition(TS(3), TS(10));
6968
clapperboard.setFont(scaledArcadeFont8());
7069
clapperboard.startAnimation();
7170

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/scenes/ArcadeMsPacMan_IntroScene.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import static de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel.createGhost;
2626
import static de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel.createMsPacMan;
2727
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
28-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2928
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_GHOST_NORMAL;
3029
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
3130
import static de.amr.pacmanfx.ui.CommonGameActions.*;
@@ -139,15 +138,15 @@ public void drawSceneContent() {
139138
String ghostName = GHOST_NAMES[presentedGhostCharacter];
140139
Color ghostColor = GHOST_COLORS[presentedGhostCharacter];
141140
if (presentedGhostCharacter == RED_GHOST_SHADOW) {
142-
gameRenderer.fillTextAtScaledPosition("WITH", ARCADE_WHITE, TITLE_X, TOP_Y + tiles_to_px(3));
141+
gameRenderer.fillTextAtScaledPosition("WITH", ARCADE_WHITE, TITLE_X, TOP_Y + TS(3));
143142
}
144-
double x = TITLE_X + (ghostName.length() < 4 ? tiles_to_px(4) : tiles_to_px(3));
145-
double y = TOP_Y + tiles_to_px(6);
143+
double x = TITLE_X + (ghostName.length() < 4 ? TS(4) : TS(3));
144+
double y = TOP_Y + TS(6);
146145
gameRenderer.fillTextAtScaledPosition(ghostName, ghostColor, x, y);
147146
}
148147
case MS_PACMAN_MARCHING_IN, READY_TO_PLAY -> {
149-
gameRenderer.fillTextAtScaledPosition("STARRING", ARCADE_WHITE, TITLE_X, TOP_Y + tiles_to_px(3));
150-
gameRenderer.fillTextAtScaledPosition("MS PAC-MAN", ARCADE_YELLOW, TITLE_X, TOP_Y + tiles_to_px(6));
148+
gameRenderer.fillTextAtScaledPosition("STARRING", ARCADE_WHITE, TITLE_X, TOP_Y + TS(3));
149+
gameRenderer.fillTextAtScaledPosition("MS PAC-MAN", ARCADE_YELLOW, TITLE_X, TOP_Y + TS(6));
151150
}
152151
}
153152
gameRenderer.drawActor(midwayCopyright);

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/rendering/ArcadePacMan_GameRenderer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Optional;
2323

2424
import static de.amr.pacmanfx.Globals.TS;
25-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2625
import static de.amr.pacmanfx.ui._2d.ArcadePalette.ARCADE_WHITE;
2726
import static de.amr.pacmanfx.ui._2d.ArcadePalette.ARCADE_YELLOW;
2827
import static java.util.Objects.requireNonNull;
@@ -56,8 +55,8 @@ public void drawHUD(GameContext gameContext, HUD hud, Vector2f sceneSize, long t
5655
if (hud.isScoreVisible()) {
5756
ctx.setFont(assets().arcadeFont(scaled(8)));
5857
ctx.setFill((ARCADE_WHITE));
59-
drawScore(gameContext.theGame().score(), "SCORE", tiles_to_px(1), tiles_to_px(1));
60-
drawScore(gameContext.theGame().highScore(), "HIGH SCORE", tiles_to_px(14), tiles_to_px(1));
58+
drawScore(gameContext.theGame().score(), "SCORE", TS(1), TS(1));
59+
drawScore(gameContext.theGame().highScore(), "HIGH SCORE", TS(14), TS(1));
6160
}
6261

6362
if (hud.isLevelCounterVisible()) {
@@ -95,7 +94,7 @@ private void drawScore(Score score, String title, double x, double y) {
9594
fillTextAtScaledPosition(title, x, y);
9695
fillTextAtScaledPosition("%7s".formatted("%02d".formatted(score.points())), x, y + TS + 1);
9796
if (score.points() != 0) {
98-
fillTextAtScaledPosition("L" + score.levelNumber(), x + tiles_to_px(8), y + TS + 1);
97+
fillTextAtScaledPosition("L" + score.levelNumber(), x + TS(8), y + TS + 1);
9998
}
10099
}
101100

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/scenes/ArcadePacMan_BootScene2D.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static de.amr.pacmanfx.Globals.TS;
1818
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
1919
import static de.amr.pacmanfx.lib.UsefulFunctions.lerp;
20-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2120
import static de.amr.pacmanfx.ui._2d.ArcadePalette.ARCADE_WHITE;
2221

2322
/**
@@ -91,10 +90,10 @@ private void drawRandomHexDigits() {
9190
ctx().setFill(ARCADE_WHITE);
9291
ctx().setFont(scaledArcadeFont8());
9392
for (int row = 0; row < numRows; ++row) {
94-
double y = scaled(tiles_to_px(row + 1));
93+
double y = scaled(TS(row + 1));
9594
for (int col = 0; col < numCols; ++col) {
9695
int hexDigit = random.nextInt(16);
97-
ctx().fillText(Integer.toHexString(hexDigit), scaled(tiles_to_px(col)), y);
96+
ctx().fillText(Integer.toHexString(hexDigit), scaled(TS(col)), y);
9897
}
9998
}
10099
}

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/scenes/ArcadePacMan_CutScene1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import org.tinylog.Logger;
1414

1515
import static de.amr.pacmanfx.Globals.RED_GHOST_SHADOW;
16+
import static de.amr.pacmanfx.Globals.TS;
1617
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createGhost;
1718
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createPac;
1819
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ANIM_BIG_PAC_MAN;
1920
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.ARCADE_MAP_SIZE_IN_PIXELS;
20-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2121
import static de.amr.pacmanfx.model.actors.CommonAnimationID.*;
2222

2323
/**
@@ -112,6 +112,6 @@ public void drawSceneContent() {
112112
protected void drawDebugInfo() {
113113
super.drawDebugInfo();
114114
String text = frame < ANIMATION_START ? String.format("Wait %d", ANIMATION_START - frame) : String.format("Frame %d", frame);
115-
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, tiles_to_px(1), tiles_to_px(5));
115+
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, TS(1), TS(5));
116116
}
117117
}

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/scenes/ArcadePacMan_CutScene2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
import org.tinylog.Logger;
1717

1818
import static de.amr.pacmanfx.Globals.RED_GHOST_SHADOW;
19+
import static de.amr.pacmanfx.Globals.TS;
1920
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createGhost;
2021
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createPac;
2122
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.*;
22-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2323
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_GHOST_NORMAL;
2424
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
2525

@@ -132,14 +132,14 @@ public void update() {
132132
@Override
133133
public void drawSceneContent() {
134134
gameRenderer.drawSpriteScaled((RectShort) nailDressRaptureAnimation.currentSprite(),
135-
tiles_to_px(14), tiles_to_px(19) + 3);
135+
TS(14), TS(19) + 3);
136136
gameRenderer.drawActors(actorsInZOrder);
137137
}
138138

139139
@Override
140140
protected void drawDebugInfo() {
141141
super.drawDebugInfo();
142142
String text = frame < ANIMATION_START ? String.format("Wait %d", ANIMATION_START - frame) : String.format("Frame %d", frame);
143-
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, tiles_to_px(1), tiles_to_px(5));
143+
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, TS(1), TS(5));
144144
}
145145
}

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/scenes/ArcadePacMan_CutScene3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import org.tinylog.Logger;
1414

1515
import static de.amr.pacmanfx.Globals.RED_GHOST_SHADOW;
16+
import static de.amr.pacmanfx.Globals.TS;
1617
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createGhost;
1718
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel.createPac;
1819
import static de.amr.pacmanfx.arcade.pacman.ArcadePacMan_UIConfig.*;
19-
import static de.amr.pacmanfx.lib.UsefulFunctions.tiles_to_px;
2020
import static de.amr.pacmanfx.model.actors.CommonAnimationID.ANIM_PAC_MUNCHING;
2121

2222
/**
@@ -104,6 +104,6 @@ public void drawSceneContent() {
104104
protected void drawDebugInfo() {
105105
super.drawDebugInfo();
106106
String text = frame < ANIMATION_START ? String.format("Wait %d", ANIMATION_START - frame) : String.format("Frame %d", frame);
107-
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, tiles_to_px(1), tiles_to_px(5));
107+
gameRenderer.fillTextAtScaledPosition(text, debugTextFill, debugTextFont, TS(1), TS(5));
108108
}
109109
}

0 commit comments

Comments
 (0)