public void presentRunning(Graphics g) { boolean[][] gameArea = arena.gameArea; for (int i = 0; i < gameArea.length; i++) { for (int j = 0; j < gameArea[i].length; j++) { if (gameArea[i][j]) g.drawPixmap( Assets.block, j * AppConst.BLOCK_WIDTH, i * AppConst.BLOCK_HEIGHT, AppConst.ORIGIN_X, AppConst.ORIGIN_Y, AppConst.BLOCK_WIDTH, AppConst.BLOCK_HEIGHT); } } int[][] shapePosition = arena.shape.coordinate; for (int i = 0; i < shapePosition.length; i++) { g.drawPixmap( Assets.block, shapePosition[i][0] * AppConst.BLOCK_WIDTH, shapePosition[i][1] * AppConst.BLOCK_HEIGHT, AppConst.ORIGIN_X, AppConst.ORIGIN_Y + arena.shape.colour * (AppConst.ATLASING_OFFSET + AppConst.BLOCK_HEIGHT), AppConst.BLOCK_WIDTH, AppConst.BLOCK_HEIGHT); } commonPresent(g); }
public void presentStopped(Graphics g) { g.drawPixmap(Assets.grey_background, AppConst.ORIGIN_X, AppConst.ORIGIN_Y); g.drawPixmap(Assets.text_your_score, ScreenConst.YOUR_SCORE_X, ScreenConst.YOUR_SCORE_Y); // Score of current Game String score = Integer.toString(arena.score); for (int i = 0; i < score.length(); i++) { g.drawPixmap( Assets.digits, ScreenConst.YOUR_SCORE_VALUE_X + i * AppConst.DIGIT_WIDTH, ScreenConst.YOUR_SCORE_VALUE_Y, AppConst.ORIGIN_X, ((score.charAt(i) - '0') + 1) * (AppConst.DIGIT_HEIGHT + AppConst.DIGIT_OFFSET), AppConst.DIGIT_WIDTH, AppConst.DIGIT_HEIGHT); } g.drawPixmap(Assets.text_high_score, ScreenConst.HIGH_SCORE_X, ScreenConst.HIGH_SCORE_Y); // HighScore String highscore = Integer.toString(Settings.HighScore); for (int i = 0; i < highscore.length(); i++) { g.drawPixmap( Assets.digits, ScreenConst.HIGH_SCORE_VALUE_X + i * AppConst.DIGIT_WIDTH, ScreenConst.HIGH_SCORE_VALUE_Y, AppConst.ORIGIN_X, ((highscore.charAt(i) - '0') + 1) * (AppConst.DIGIT_HEIGHT + AppConst.DIGIT_OFFSET), AppConst.DIGIT_WIDTH, AppConst.DIGIT_HEIGHT); } g.drawPixmap(Assets.text_retry, ScreenConst.RETRY_X, ScreenConst.RETRY_Y); g.drawPixmap(Assets.text_back_to_menu, ScreenConst.BACK_TO_MENU_X, ScreenConst.BACK_TO_MENU_Y); }
@Override public void present(float deltaTime) { Graphics g = game.getGraphics(); // No Need to do it in multiple present methods g.drawPixmap(Assets.background, AppConst.ORIGIN_X, AppConst.ORIGIN_Y); if (state == GameState.START) presentStart(g); else if (state == GameState.RUNNING) presentRunning(g); else if (state == GameState.PAUSED) presentPaused(g); else presentStopped(g); }
public void presentStart(Graphics g) { commonPresent(g); g.drawPixmap(Assets.text_tap_to_start, ScreenConst.TAP_TO_START_X, ScreenConst.TAP_TO_START_Y); }
void commonPresent(Graphics g) { // Filing the lower base for (int i = 0; i <= ((AppConst.FRAMEBUFFER_HEIGHT - (AppConst.ARENA_GRID_HEIGHT * AppConst.BLOCK_HEIGHT)) / FileName.FILING_BLOCK_HOR_HT); i++) { for (int j = 0; j < ((AppConst.ARENA_GRID_WIDTH * AppConst.BLOCK_WIDTH) / FileName.FILING_BLOCK_HOR_WH); j++) { g.drawPixmap( Assets.filing_block_hor, AppConst.ORIGIN_X + (j * FileName.FILING_BLOCK_HOR_WH), AppConst.HORIZONTAL_LINE_Y + (i * FileName.FILING_BLOCK_HOR_HT)); } } for (int i = 0; i < AppConst.FRAMEBUFFER_HEIGHT; i += FileName.FILING_BLOCK_VER_HT) { g.drawPixmap(Assets.filing_block_ver, AppConst.VERTICAL_LINE_X, i); } // Shape in the Next Box int[][] nsCoordinate = arena.getNextShapeCoordinate(); for (int i = 0; i < nsCoordinate.length; i++) { g.drawPixmap( Assets.block, nsCoordinate[i][0], nsCoordinate[i][1], AppConst.ORIGIN_X, AppConst.ORIGIN_Y + arena.nextShape.colour * (AppConst.ATLASING_OFFSET + AppConst.BLOCK_HEIGHT), AppConst.BLOCK_WIDTH, AppConst.BLOCK_HEIGHT); } // Score Update String score = Integer.toString(arena.score); int startX = ScreenConst.SCORE_VALUE_X + ((FileName.TEXT_SCORE_WH / 2) - ((score.length() * AppConst.SMALL_DIGIT_WIDTH) / 2)); for (int i = 0; i < score.length(); i++) { g.drawPixmap( Assets.small_digits, startX + (i * AppConst.SMALL_DIGIT_WIDTH), ScreenConst.SCORE_VALUE_Y, AppConst.ORIGIN_X, ((score.charAt(i) - '0') + 1) * (AppConst.SMALL_DIGIT_HEIGHT + AppConst.SMALL_DIGIT_OFFSET), AppConst.SMALL_DIGIT_WIDTH, AppConst.SMALL_DIGIT_HEIGHT); } // level update String level = Integer.toString(arena.level); int levelStartX = ScreenConst.LEVEL_VALUE_X + ((FileName.TEXT_LEVEL_WH / 2) - ((level.length() * AppConst.SMALL_DIGIT_WIDTH) / 2)); for (int i = 0; i < level.length(); i++) { g.drawPixmap( Assets.small_digits, levelStartX + (i * AppConst.SMALL_DIGIT_WIDTH), ScreenConst.LEVEL_VALUE_Y, AppConst.ORIGIN_X, ((level.charAt(i) - '0') + 1) * (AppConst.SMALL_DIGIT_HEIGHT + AppConst.SMALL_DIGIT_OFFSET), AppConst.SMALL_DIGIT_WIDTH, AppConst.SMALL_DIGIT_HEIGHT); } // Lines update String lines = Integer.toString(arena.lines); int linesStartX = ScreenConst.LINES_VALUE_X + ((FileName.TEXT_LINES_WH / 2) - ((lines.length() * AppConst.SMALL_DIGIT_WIDTH) / 2)); for (int i = 0; i < lines.length(); i++) { g.drawPixmap( Assets.small_digits, linesStartX + (i * AppConst.SMALL_DIGIT_WIDTH), ScreenConst.LINES_VALUE_Y, AppConst.ORIGIN_X, ((lines.charAt(i) - '0') + 1) * (AppConst.SMALL_DIGIT_HEIGHT + AppConst.SMALL_DIGIT_OFFSET), AppConst.SMALL_DIGIT_WIDTH, AppConst.SMALL_DIGIT_HEIGHT); } g.drawPixmap(Assets.text_next, ScreenConst.NEXT_X, ScreenConst.NEXT_Y); g.drawPixmap(Assets.text_level, ScreenConst.LEVEL_X, ScreenConst.LEVEL_Y); g.drawPixmap(Assets.text_score, ScreenConst.SCORE_X, ScreenConst.SCORE_Y); g.drawPixmap(Assets.text_lines, ScreenConst.LINES_X, ScreenConst.LINES_Y); }
public void presentPaused(Graphics g) { presentRunning(g); g.drawPixmap(Assets.text_resume, ScreenConst.RESUME_X, ScreenConst.RESUME_Y); g.drawPixmap(Assets.text_quit, ScreenConst.QUIT_X, ScreenConst.QUIT_Y); }