private synchronized void render(Graphics g) { if (level != null) { int xScroll = (int) (player.pos.x - screen.w / 2); int yScroll = (int) (player.pos.y - (screen.h - 24) / 2); soundPlayer.setListenerPosition((float) player.pos.x, (float) player.pos.y); level.render(screen, xScroll, yScroll); } if (!menuStack.isEmpty()) { menuStack.peek().render(screen); } Font.draw(screen, "FPS: " + fps, 10, 10); // for (int p = 0; p < players.length; p++) { // if (players[p] != null) { // String msg = "P" + (p + 1) + ": " + players[p].getScore(); // Font.draw(screen, msg, 320, screen.h - 24 + p * 8); // } // } if (player != null && menuStack.size() == 0) { Font.draw(screen, player.health + " / 10", 340, screen.h - 19); Font.draw(screen, "" + player.score, 340, screen.h - 33); } g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); g.translate((getWidth() - GAME_WIDTH * SCALE) / 2, (getHeight() - GAME_HEIGHT * SCALE) / 2); g.clipRect(0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE); if (!menuStack.isEmpty() || level != null) { // render mouse renderMouse(screen, mouseButtons); g.drawImage(screen.image, 0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE, null); } // String msg = "FPS: " + fps; // g.setColor(Color.LIGHT_GRAY); // g.drawString(msg, 11, 11); // g.setColor(Color.WHITE); // g.drawString(msg, 10, 10); }
private void addHealthBar(Screen screen) { int maxIndex = Art.panel_healthBar[0].length - 1; int index = maxIndex - Math.round(player.health * maxIndex / player.maxHealth); if (index < 0) index = 0; else if (index > maxIndex) index = maxIndex; screen.blit(Art.panel_healthBar[0][index], 311, screen.h - 17); screen.blit(Art.panel_heart, 314, screen.h - 24); Font font = Font.defaultFont(); font.draw(screen, texts.health(player.health, player.maxHealth), 335, screen.h - 21); }
private void addXpBar(Screen screen) { int xpSinceLastLevelUp = (int) (player.xpSinceLastLevelUp()); int xpNeededForNextLevel = (int) (player.nettoXpNeededForLevel(player.plevel + 1)); int maxIndex = Art.panel_xpBar[0].length - 1; int index = maxIndex - Math.round(xpSinceLastLevelUp * maxIndex / xpNeededForNextLevel); if (index < 0) index = 0; else if (index > maxIndex) index = maxIndex; screen.blit(Art.panel_xpBar[0][index], 311, screen.h - 32); screen.blit(Art.panel_star, 314, screen.h - 40); Font font = Font.defaultFont(); font.draw(screen, texts.playerLevel(player.plevel + 1), 335, screen.h - 36); }
private synchronized void render(Graphics g) { if (level != null) { int xScroll = (int) (player.pos.x - screen.w / 2); int yScroll = (int) (player.pos.y - (screen.h - 24) / 2); soundPlayer.setListenerPosition((float) player.pos.x, (float) player.pos.y); level.render(screen, xScroll, yScroll); } if (!menuStack.isEmpty()) { menuStack.peek().render(screen); } if (Options.getAsBoolean(Options.DRAW_FPS, Options.VALUE_FALSE)) { Font.defaultFont().draw(screen, texts.FPS(fps), 10, 10); } if (player != null && menuStack.size() == 0) { addHealthBar(screen); addXpBar(screen); addScore(screen); Font font = Font.defaultFont(); if (isMultiplayer) { font.draw(screen, texts.latency(latencyCacheReady() ? "" + avgLatency() : "-"), 10, 20); } } if (isMultiplayer && menuStack.isEmpty()) { chat.render(screen); } g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); g.translate((getWidth() - GAME_WIDTH * SCALE) / 2, (getHeight() - GAME_HEIGHT * SCALE) / 2); g.clipRect(0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE); if (!menuStack.isEmpty() || level != null) { // render mouse renderMouse(screen, mouseButtons); g.drawImage(screen.image, 0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE, null); } }
private synchronized void render(Graphics g) { if (level != null) { int xScroll = (int) (player.pos.x - screen.w / 2); int yScroll = (int) (player.pos.y - (screen.h - 24) / 2); soundPlayer.setListenerPosition((float) player.pos.x, (float) player.pos.y); level.render(screen, xScroll, yScroll); } if (!menuStack.isEmpty()) { menuStack.peek().render(screen); } boolean drawFPS = Options.get("drawFPS") != null && Options.get("drawFPS").equals("true"); if (drawFPS) { Font.draw(screen, texts.FPS(fps), 10, 10); } if (player != null && menuStack.size() == 0) { Font.draw(screen, texts.health(player.health, player.maxHealth), 340, screen.h - 16); Font.draw(screen, texts.money(player.score), 340, screen.h - 27); Font.draw(screen, texts.nextLevel((int) player.getNextLevel()), 340, screen.h - 38); Font.draw(screen, texts.playerExp((int) player.pexp), 340, screen.h - 49); Font.draw(screen, texts.playerLevel(player.plevel), 340, screen.h - 60); } g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); g.translate((getWidth() - GAME_WIDTH * SCALE) / 2, (getHeight() - GAME_HEIGHT * SCALE) / 2); g.clipRect(0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE); if (!menuStack.isEmpty() || level != null) { // render mouse renderMouse(screen, mouseButtons); g.drawImage(screen.image, 0, 0, GAME_WIDTH * SCALE, GAME_HEIGHT * SCALE, null); } }
private void addScore(Screen screen) { screen.blit(Art.panel_coin, 314, screen.h - 55); Font font = Font.defaultFont(); font.draw(screen, texts.money(player.score), 335, screen.h - 52); }