Skip to content

Commit ff6d8e6

Browse files
authored
Merge pull request #66 from sdp24-2-CodingPing/develop
Merge/v1.1.2
2 parents 290f97a + e6be253 commit ff6d8e6

13 files changed

Lines changed: 399 additions & 133 deletions

File tree

.github/workflows/lint-on-pr.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint on PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
lint:
10+
name: Lint Code
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# 1. 코드 체크아웃
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
# 2. Java 환경 설정
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '21'
24+
25+
# 3. Gradle 캐시 활성화
26+
- name: Cache Gradle dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.gradle/caches
31+
~/.gradle/wrapper
32+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
33+
restore-keys: |
34+
${{ runner.os }}-gradle
35+
36+
# 4. Spotless
37+
- name: Run Spotless Check
38+
run: ./gradlew spotlessCheck

src/engine/Core.java

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ public static void main(final String[] args) throws IOException {
8989
AchievementManager achievementManager;
9090
Wallet wallet = Wallet.getWallet();
9191

92-
boolean isGotoMainMenu = false;
93-
9492
int returnCode = 1;
9593
do {
9694
MAX_LIVES = wallet.getLives_lv() + 2;
9795
GameState gameState = new GameState(1, 0, 0, BASE_SHIP, 0, 0, 0, 0, 0, 0, 0, 0);
9896
GameSettings gameSetting = new GameSettings(4, 4, 60, 2500);
9997
achievementManager = new AchievementManager();
98+
boolean isGotoMainMenu = false;
10099

101100
switch (returnCode) {
102101
case 1:
@@ -127,48 +126,29 @@ public static void main(final String[] args) throws IOException {
127126
frame.setScreen(currentScreen);
128127
LOGGER.info("Closing game screen.");
129128

130-
if (((GameScreen) currentScreen).getIsGotoMainMenu()) {
131-
if (!gameState.getPlayerShip().isDestroyed()) {
132-
isGotoMainMenu = true;
133-
break;
134-
}
129+
isGotoMainMenu = ((GameScreen) currentScreen).getIsGotoMainMenu();
130+
if (isGotoMainMenu) {
131+
break;
135132
}
136133

137134
gameState = ((GameScreen) currentScreen).getGameState();
138135

139-
// 게임 오버 시 ScoreScreen으로 전환
140-
if (!gameState.getPlayerShip().isDestroyed()) {
141-
// 다음 레벨 진행
142-
gameState = new GameState(gameState, gameState.getGameLevel() + 1);
143-
endTime = System.currentTimeMillis();
144-
achievementManager.updatePlaying(
145-
gameState.getMaxCombo(),
146-
(int) (endTime - startTime) / 1000,
147-
MAX_LIVES,
148-
gameState.getPlayerShip().getPlayerHP(),
149-
gameState.getGameLevel() - 1);
150-
} else {
151-
// ScoreScreen으로 전환하여 게임오버 화면 표시
152-
currentScreen =
153-
new ScoreScreen(
154-
GameSettingScreen.getName(),
155-
width,
156-
height,
157-
FPS,
158-
gameState,
159-
wallet,
160-
achievementManager,
161-
false);
162-
returnCode = frame.setScreen(currentScreen);
163-
LOGGER.info("Closing score screen.");
164-
break;
165-
}
136+
// 다음 레벨 진행
137+
gameState.setGameLevel(gameState.getGameLevel() + 1);
138+
endTime = System.currentTimeMillis();
139+
achievementManager.updatePlaying(
140+
gameState.getMaxCombo(),
141+
(int) (endTime - startTime) / 1000,
142+
MAX_LIVES,
143+
gameState.getPlayerShip().getPlayerHP(),
144+
gameState.getGameLevel() - 1);
166145
} while (!gameState.getPlayerShip().isDestroyed());
167146

168147
if (isGotoMainMenu) {
169148
returnCode = 1;
170149
break;
171150
}
151+
172152
achievementManager.updatePlayed(gameState.getAccuracy(), gameState.getScore());
173153
achievementManager.updateAllAchievements();
174154
LOGGER.info(

src/engine/DrawManager.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public class DrawManager {
7878
protected static BufferedImage img_coin;
7979
protected static BufferedImage img_coingain;
8080
protected static BufferedImage img_shotinterval;
81+
protected static BufferedImage img_movespeed;
82+
protected static BufferedImage img_attackdamage;
83+
protected static BufferedImage img_bulletscount;
8184

8285
/** Sprite types. */
8386
public static enum SpriteType {
@@ -186,15 +189,19 @@ protected DrawManager() {
186189
logger.warning("Font formating failed.");
187190
}
188191

189-
/** Shop image load */
192+
/** image load */
190193
try {
191194
img_additionallife = ImageIO.read(new File("res/image/additional life.jpg"));
192195
img_bulletspeed = ImageIO.read(new File("res/image/bullet speed.jpg"));
193196
img_coin = ImageIO.read(new File("res/image/coin.jpg"));
194197
img_coingain = ImageIO.read(new File("res/image/coin gain.jpg"));
195198
img_shotinterval = ImageIO.read(new File("res/image/shot interval.jpg"));
199+
img_movespeed = ImageIO.read(new File("res/image/card/move_speed.png"));
200+
img_attackdamage = ImageIO.read(new File("res/image/card/attack_damage.png"));
201+
img_bulletscount = ImageIO.read(new File("res/image/card/bullets_count.png"));
202+
196203
} catch (IOException e) {
197-
logger.info("Shop image loading failed");
204+
logger.info("Image loading failed");
198205
}
199206
}
200207

src/engine/SoundManager.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,13 @@ private void setVolume(int volume) {
187187
}
188188
// Apply to soundClips (including background music)
189189
for (Clip clip : soundClips.values()) {
190-
try {
191-
FloatControl volumeControl =
192-
(FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
193-
volumeControl.setValue(newVolume);
194-
} catch (IllegalArgumentException e) {
195-
logger.warning("Failed to set volume: " + e.getMessage());
196-
}
190+
try {
191+
FloatControl volumeControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
192+
volumeControl.setValue(newVolume);
193+
} catch (IllegalArgumentException e) {
194+
logger.warning("Failed to set volume: " + e.getMessage());
195+
}
197196
}
198-
199197
}
200198

201199
/**

src/engine/drawmanager/GameDrawManager.java

Lines changed: 64 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import engine.DrawManager;
55
import engine.Score;
66
import entity.Entity;
7-
import entity.ShipFactory;
7+
import entity.player.PlayerLevel;
88
import entity.player.PlayerShip;
99
import java.awt.*;
1010
import java.awt.geom.AffineTransform;
11+
import java.awt.image.BufferedImage;
1112
import java.util.List;
1213
import screen.Screen;
1314

@@ -36,20 +37,6 @@ public static void drawAlertMessage(final Screen screen, final String alertMessa
3637
alertMessage, (screen.getWidth() - fontRegularMetrics.stringWidth(alertMessage)) / 2, 65);
3738
}
3839

39-
/**
40-
* Draws number of remaining lives on screen.
41-
*
42-
* @param screen Screen to draw on.
43-
* @param lives Current lives.
44-
*/
45-
public void drawLives(final Screen screen, final int lives, final PlayerShip.ShipType shipType) {
46-
backBufferGraphics.setFont(fontRegular);
47-
backBufferGraphics.setColor(Color.WHITE);
48-
backBufferGraphics.drawString(Integer.toString(lives), 20, 25);
49-
PlayerShip dummyPlayerShip = ShipFactory.create(shipType, 0, 0);
50-
for (int i = 0; i < lives; i++) drawEntity(dummyPlayerShip, 40 + 35 * i, 10);
51-
}
52-
5340
/**
5441
* Draws level on screen.
5542
*
@@ -218,6 +205,21 @@ public static void drawHorizontalLine(final Screen screen, final int positionY)
218205
backBufferGraphics.drawLine(0, positionY + 1, screen.getWidth(), positionY + 1);
219206
}
220207

208+
/**
209+
* Draw a background box for HUD.
210+
*
211+
* @param screen Screen to draw on.
212+
* @param x X coordinate of the box.
213+
* @param y Y coordinate of the box.
214+
* @param w Width of the box.
215+
* @param h Height of the box.
216+
*/
217+
public static void drawHudPanel(
218+
final Screen screen, final int x, final int y, final int w, final int h) {
219+
backBufferGraphics.setColor(Color.BLACK);
220+
backBufferGraphics.fillRect(x, y, w, h);
221+
}
222+
221223
/**
222224
* Draws a horizontal bar composed of multiple box segments.
223225
*
@@ -234,15 +236,17 @@ public static void drawSegmentedBar(
234236
int basicWidth = w / maximumValue; // Basic width of each box
235237
int remainingWidth = w % maximumValue; // Remaining width to be distributed
236238

237-
// Draw filled and empty boxes
239+
int filledBoxes = (int) ((double) currentValue / maximumValue * w);
240+
238241
int startX = x; // Initial x coordinate for the first box
239242
for (int i = 0; i < maximumValue; i++) {
240243
int boxWidth = basicWidth;
244+
241245
if (i < remainingWidth) {
242246
boxWidth += 1; // Distribute the remaining width to the first few boxes
243247
}
244248

245-
if (i < currentValue) {
249+
if (startX < x + filledBoxes) {
246250
backBufferGraphics.setColor(color); // Color for filled boxes
247251
} else {
248252
backBufferGraphics.setColor(Color.GRAY); // Color for empty boxes
@@ -253,33 +257,50 @@ public static void drawSegmentedBar(
253257
}
254258
}
255259

256-
/**
257-
* Draws a thicker box outline by drawing two overlapping boxes.
258-
*
259-
* @param screen Screen to draw on.
260-
* @param x X coordinate of the upper-left corner of the inner box.
261-
* @param y Y coordinate of the upper-left corner of the inner box.
262-
* @param w Width of the inner box.
263-
* @param h Height of the inner box.
264-
* @param thickness Thickness of the outer box.
265-
*/
266-
public static void drawThickBox(
267-
final Screen screen,
268-
final int x,
269-
final int y,
270-
final int w,
271-
final int h,
272-
final int thickness) {
273-
// Ensure thickness is not greater than the width or height
274-
if (thickness * 2 > w || thickness * 2 > h) {
275-
throw new IllegalArgumentException("Thickness is too large for the given width or height");
276-
}
260+
/** Draws a stat value */
261+
public static void drawStat(final Screen screen, final int stat, int x, int y) {
262+
int BOX_WIDTH = 48;
263+
int BOX_HEIGHT = 48;
264+
backBufferGraphics.setColor(Color.WHITE);
265+
String statText = Integer.toString(stat);
277266

278-
backBufferGraphics.setColor(Color.GREEN);
279-
backBufferGraphics.fillRect(x, y, w, h); // Outer box
280-
backBufferGraphics.setColor(Color.BLACK);
281-
backBufferGraphics.fillRect(
282-
x + thickness, y + thickness, w - 2 * thickness, h - 2 * thickness); // Draw inner box
267+
FontMetrics metrics = backBufferGraphics.getFontMetrics(fontBig);
268+
int textWidth = metrics.stringWidth(statText);
269+
int textHeight = metrics.getHeight();
270+
271+
int drawX = x + (BOX_WIDTH - textWidth) / 2;
272+
int drawY = y + (BOX_HEIGHT + textHeight) / 2;
273+
274+
backBufferGraphics.drawString(statText, drawX, drawY);
275+
}
276+
277+
/** Draws a stat icon */
278+
public static void drawStatIcon(Screen screen, int num, int x, int y) {
279+
BufferedImage[] statImages =
280+
new BufferedImage[] {
281+
img_movespeed,
282+
img_bulletspeed,
283+
img_attackdamage,
284+
img_shotinterval,
285+
img_bulletscount,
286+
img_additionallife
287+
};
288+
backBufferGraphics.drawImage(statImages[num], x, y, 25, 18, null);
289+
}
290+
291+
/** Draws a player level */
292+
public static void drawPlayerLevel(final Screen screen, final PlayerLevel level, int x, int y) {
293+
backBufferGraphics.setFont(fontBig);
294+
backBufferGraphics.setColor(Color.WHITE);
295+
296+
int levelValue = level.getLevel();
297+
if (levelValue < 10) {
298+
String scoreString = String.format("lv.0%d", levelValue);
299+
backBufferGraphics.drawString(scoreString, x, y);
300+
} else {
301+
String scoreString = String.format("lv.%d", levelValue);
302+
backBufferGraphics.drawString(scoreString, x, y);
303+
}
283304
}
284305

285306
/**

src/entity/BulletPool.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ public static Bullet getBullet(
5151
public static void recycle(final Set<Bullet> bullet) {
5252
pool.addAll(bullet);
5353
}
54+
55+
public static boolean isPoolEmpty() {
56+
return pool.isEmpty();
57+
}
58+
59+
public static int getPoolSize() {
60+
return pool.size();
61+
}
62+
63+
public static void clearPool() {
64+
pool.clear();
65+
}
5466
}

src/entity/player/PlayerCardStatus.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,47 @@ public static void reset() {
2121
moveSpeedLevel = 0;
2222
}
2323

24-
public int getAttackDamageLevel() {
24+
public static int getAttackDamageLevel() {
2525
return attackDamage;
2626
}
2727

2828
public void attackDamageLevelUp() {
2929
attackDamage++;
3030
}
3131

32-
public int getIntervalLevel() {
32+
public static int getIntervalLevel() {
3333
return intervalLevel;
3434
}
3535

3636
public void intervalLevelUp() {
3737
intervalLevel++;
3838
}
3939

40-
public int getBulletsCountLevel() {
40+
public static int getBulletsCountLevel() {
4141
return bulletsCountLevel;
4242
}
4343

4444
public void bulletsCountLevelUp() {
4545
bulletsCountLevel++;
4646
}
4747

48-
public int getBulletsSpeedLevel() {
48+
public static int getBulletsSpeedLevel() {
4949
return bulletsSpeedLevel;
5050
}
5151

5252
public void bulletsSpeedLevelUp() {
5353
bulletsSpeedLevel++;
5454
}
5555

56-
public int getHpLevel() {
56+
public static int getHpLevel() {
5757
return hpLevel;
5858
}
5959

6060
public void hpLevelUp() {
61-
hpLevel += 5;
61+
hpLevel++;
6262
}
6363

64-
public int getMoveSpeedLevel() {
64+
public static int getMoveSpeedLevel() {
6565
return moveSpeedLevel;
6666
}
6767

0 commit comments

Comments
 (0)