Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] Korean comment #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/engine/Cooldown.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,34 @@

/**
* Imposes a cooldown period between two actions.
*
* 두 행동 사이에 재사용 대기시간을 부과합니다.
*
* @author <a href="mailto:[email protected]">Roberto Izquierdo Amo</a>
*
*
*/
public class Cooldown {

/** Cooldown duration. */
/** Cooldown duration.
* 재사용 대기시간. */
private int milliseconds;
/** Maximum difference between durations. */
/** Maximum difference between durations.
* duration들 간의 최대 차이입니다. */
private int variance;
/** Duration of this run, varies between runs if variance > 0. */
/** Duration of this run, varies between runs if variance > 0.
* 이 실행 duration은 (variance > 0)인 경우 실행 간에 다릅니다. */
private int duration;
/** Beginning time. */
/** Beginning time.
* 시작 시간입니다. */
private long time;

/**
* Constructor, established the time until the action can be performed
* again.
*
* 생성자, 작업을 다시 수행할 수 있을 때까지의 시간을 설정합니다.
*
* @param milliseconds
* Time until cooldown period is finished.
* 재사용 대기 시간이 끝날 때까지의 시간입니다.
*/
protected Cooldown(final int milliseconds) {
this.milliseconds = milliseconds;
Expand All @@ -34,11 +41,14 @@ protected Cooldown(final int milliseconds) {
/**
* Constructor, established the time until the action can be performed
* again, with a variation of +/- variance.
*
* 생성자는 +/- variation의 변형으로 작업을 다시 수행할 수 있을 때까지의 시간을 설정합니다.
*
* @param milliseconds
* Time until cooldown period is finished.
* 재사용 대기 시간이 끝날 때까지의 시간입니다.
* @param variance
* Variance in the cooldown period.
* 재사용 대기 시간의 variance.
*/
protected Cooldown(final int milliseconds, final int variance) {
this.milliseconds = milliseconds;
Expand All @@ -48,7 +58,8 @@ protected Cooldown(final int milliseconds, final int variance) {

/**
* Checks if the cooldown is finished.
*
* 쿨다운이 완료되었는지 확인합니다.
*
* @return Cooldown state.
*/
public final boolean checkFinished() {
Expand All @@ -60,12 +71,13 @@ public final boolean checkFinished() {

/**
* Restarts the cooldown.
* 재사용 대기시간을 다시 시작합니다.
*/
public final void reset() {
this.time = System.currentTimeMillis();
if (this.variance != 0)
this.duration = (this.milliseconds - this.variance)
+ (int) (Math.random()
* (this.milliseconds + this.variance));
* (this.milliseconds + this.variance));
}
}
183 changes: 104 additions & 79 deletions src/engine/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,34 @@

/**
* Implements core game logic.
*
* 핵심 게임 로직을 구현합니다.
*
* @author <a href="mailto:[email protected]">Roberto Izquierdo Amo</a>
*
*
*/
public final class Core {

/** Width of current screen. */
/** Width of current screen.
* 현재 화면의 너비입니다. */
private static final int WIDTH = 448;
/** Height of current screen. */
/** Height of current screen.
* 현재 화면의 높이입니다. */
private static final int HEIGHT = 520;
/** Max fps of current screen. */
/** Max fps of current screen.
* 현재 화면의 최대 fps. */
private static final int FPS = 60;

/** Max lives. */
/** Max lives.
* 최대 목숨 개수 */
private static final int MAX_LIVES = 3;
/** Levels between extra life. */
/** Levels between extra life.
* 레벨 사이의 추가 목숨 */
private static final int EXTRA_LIFE_FRECUENCY = 3;
/** Total number of levels. */
/** Total number of levels.
* 총 레벨 수. */
private static final int NUM_LEVELS = 7;


/* 레벨들의 난이도 설정 */
/** Difficulty settings for level 1. */
private static final GameSettings SETTINGS_LEVEL_1 =
new GameSettings(5, 4, 60, 2000);
Expand All @@ -57,27 +65,35 @@ public final class Core {
/** Difficulty settings for level 7. */
private static final GameSettings SETTINGS_LEVEL_7 =
new GameSettings(8, 7, 2, 500);

/** Frame to draw the screen on. */

/** Frame to draw the screen on.
* 화면을 그릴 Frame 입니다. */
private static Frame frame;
/** Screen currently shown. */
/** Screen currently shown.
* 현재 보여지는 화면. */
private static Screen currentScreen;
/** Difficulty settings list. */
/** Difficulty settings list.
* 난이도 설정 목록. */
private static List<GameSettings> gameSettings;
/** Application logger. */
/** Application logger.
* 애플리케이션 로거. */
private static final Logger LOGGER = Logger.getLogger(Core.class
.getSimpleName());
/** Logger handler for printing to disk. */
/** Logger handler for printing to disk.
* 디스크에 프린팅하기 위한 로거 핸들러 */
private static Handler fileHandler;
/** Logger handler for printing to console. */
/** Logger handler for printing to console.
* 콘솔에 프린팅하기 위한 로거 핸들러 */
private static ConsoleHandler consoleHandler;


/**
* Test implementation.
*
* 테스트 구현.
*
* @param args
* Program args, ignored.
* 프로그램 인수, 무시됨.
*/
public static void main(final String[] args) {
try {
Expand Down Expand Up @@ -111,69 +127,69 @@ public static void main(final String[] args) {
gameSettings.add(SETTINGS_LEVEL_5);
gameSettings.add(SETTINGS_LEVEL_6);
gameSettings.add(SETTINGS_LEVEL_7);

GameState gameState;

int returnCode = 1;
do {
gameState = new GameState(1, 0, MAX_LIVES, 0, 0);

switch (returnCode) {
case 1:
// Main menu.
currentScreen = new TitleScreen(width, height, FPS);
LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " title screen at " + FPS + " fps.");
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing title screen.");
break;
case 2:
// Game & score.
do {
// One extra live every few levels.
boolean bonusLife = gameState.getLevel()
% EXTRA_LIFE_FRECUENCY == 0
&& gameState.getLivesRemaining() < MAX_LIVES;

currentScreen = new GameScreen(gameState,
gameSettings.get(gameState.getLevel() - 1),
bonusLife, width, height, FPS);
case 1:
// Main menu.
currentScreen = new TitleScreen(width, height, FPS);
LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " title screen at " + FPS + " fps.");
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing title screen.");
break;
case 2:
// Game & score.
do {
// One extra live every few levels.
boolean bonusLife = gameState.getLevel()
% EXTRA_LIFE_FRECUENCY == 0
&& gameState.getLivesRemaining() < MAX_LIVES;

currentScreen = new GameScreen(gameState,
gameSettings.get(gameState.getLevel() - 1),
bonusLife, width, height, FPS);
LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " game screen at " + FPS + " fps.");
frame.setScreen(currentScreen);
LOGGER.info("Closing game screen.");

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

gameState = new GameState(gameState.getLevel() + 1,
gameState.getScore(),
gameState.getLivesRemaining(),
gameState.getBulletsShot(),
gameState.getShipsDestroyed());

} while (gameState.getLivesRemaining() > 0
&& gameState.getLevel() <= NUM_LEVELS);

LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " score screen at " + FPS + " fps, with a score of "
+ gameState.getScore() + ", "
+ gameState.getLivesRemaining() + " lives remaining, "
+ gameState.getBulletsShot() + " bullets shot and "
+ gameState.getShipsDestroyed() + " ships destroyed.");
currentScreen = new ScoreScreen(width, height, FPS, gameState);
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing score screen.");
break;
case 3:
// High scores.
currentScreen = new HighScoreScreen(width, height, FPS);
LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " game screen at " + FPS + " fps.");
frame.setScreen(currentScreen);
LOGGER.info("Closing game screen.");

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

gameState = new GameState(gameState.getLevel() + 1,
gameState.getScore(),
gameState.getLivesRemaining(),
gameState.getBulletsShot(),
gameState.getShipsDestroyed());

} while (gameState.getLivesRemaining() > 0
&& gameState.getLevel() <= NUM_LEVELS);

LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " score screen at " + FPS + " fps, with a score of "
+ gameState.getScore() + ", "
+ gameState.getLivesRemaining() + " lives remaining, "
+ gameState.getBulletsShot() + " bullets shot and "
+ gameState.getShipsDestroyed() + " ships destroyed.");
currentScreen = new ScoreScreen(width, height, FPS, gameState);
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing score screen.");
break;
case 3:
// High scores.
currentScreen = new HighScoreScreen(width, height, FPS);
LOGGER.info("Starting " + WIDTH + "x" + HEIGHT
+ " high score screen at " + FPS + " fps.");
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing high score screen.");
break;
default:
break;
+ " high score screen at " + FPS + " fps.");
returnCode = frame.setScreen(currentScreen);
LOGGER.info("Closing high score screen.");
break;
default:
break;
}

} while (returnCode != 0);
Expand All @@ -185,14 +201,16 @@ public static void main(final String[] args) {

/**
* Constructor, not called.
* 호출되지 않은 생성자.
*/
private Core() {

}

/**
* Controls access to the logger.
*
* logger에 대한 액세스를 제어합니다.
*
* @return Application logger.
*/
public static Logger getLogger() {
Expand All @@ -201,7 +219,8 @@ public static Logger getLogger() {

/**
* Controls access to the drawing manager.
*
* drawing manager에 대한 액세스를 제어합니다.
*
* @return Application draw manager.
*/
public static DrawManager getDrawManager() {
Expand All @@ -210,7 +229,8 @@ public static DrawManager getDrawManager() {

/**
* Controls access to the input manager.
*
* input manager에 대한 액세스를 제어합니다.
*
* @return Application input manager.
*/
public static InputManager getInputManager() {
Expand All @@ -219,7 +239,8 @@ public static InputManager getInputManager() {

/**
* Controls access to the file manager.
*
* input manager에 대한 액세스를 제어합니다.
*
* @return Application file manager.
*/
public static FileManager getFileManager() {
Expand All @@ -228,7 +249,8 @@ public static FileManager getFileManager() {

/**
* Controls creation of new cooldowns.
*
* 새로운 재사용 대기시간 생성을 제어합니다.
*
* @param milliseconds
* Duration of the cooldown.
* @return A new cooldown.
Expand All @@ -239,15 +261,18 @@ public static Cooldown getCooldown(final int milliseconds) {

/**
* Controls creation of new cooldowns with variance.
*
* variance가 있는 새로운 재사용 대기시간 생성을 제어합니다.
*
* @param milliseconds
* Duration of the cooldown.
* 재사용 대기시간.
* @param variance
* Variation in the cooldown duration.
* 재사용 대기시간의 variance.
* @return A new cooldown with variance.
*/
public static Cooldown getVariableCooldown(final int milliseconds,
final int variance) {
final int variance) {
return new Cooldown(milliseconds, variance);
}
}
Loading