1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| public void render() { frames++; frame_count++; long start = System.nanoTime();
Graphics2D g = tmp.createGraphics(); g.setColor(Color.black); g.fillRect(0, 0, WIDTH, HEIGHT); level.draw_edge_persepctive(g, SpriteType.ranger, x, y, pixel_x, pixel_y, 13, 9); for(Entity e : entities) { e.render(g, level.p_screen_x, level.p_screen_y); } Font.printString(tmp, "Rogu3", 4, 4, 5, 0x65DE31, 0x454545); Font.printString(tmp, "Power: " + score, 4, Font.h * 2 + 4, 24, 0xFA1122, 0x911122); Font.printString(tmp, "Entities: " + Level.ent_count, 4, Game.HEIGHT - (Font.h * 2) - 4, 24, 0xFFFFFF, 0x000000); Font.printString(tmp, "FPS: " + fps, 800 - 80 - 16, 4, 50, 0xABABAB, 0x232323); announce(g); g.drawImage(Art.border, 0, 0, 8, 8, 0, 0, 8, 8, null); g.drawImage(Art.border, Game.WIDTH - 8, 0, Game.WIDTH, 8, 24, 0, 32, 8, null); g.drawImage(Art.border, 0, Game.HEIGHT - 8, 8, Game.HEIGHT, 0, 24, 8, 32, null); g.drawImage(Art.border, Game.WIDTH - 8, Game.HEIGHT - 8, Game.WIDTH, Game.HEIGHT, 24, 24, 32, 32, null); for(int ix = 0; ix <= 50; ix ++) { g.drawImage(Art.border, 8 + (ix * 16), 0, 8 + (ix * 16) + 16, 8, 8, 0, 24, 8, null); } for(int ix = 0; ix <= 50; ix ++) { g.drawImage(Art.border, 8 + (ix * 16), Game.HEIGHT - 8, 8 + (ix * 16) + 16, Game.HEIGHT, 8, 24, 24, 32, null); } for(int iy = 0; iy <= 34; iy ++) { g.drawImage(Art.border, 0, 8 + (iy * 16), 8, 8 + (iy * 16) + 16, 0, 8, 8, 24, null); } for(int iy = 0; iy <= 34; iy ++) { g.drawImage(Art.border, Game.WIDTH - 8, 8 + (iy * 16), Game.WIDTH, 8 + (iy * 16) + 16, 24, 8, 32, 24, null); }
g.dispose(); g = getGraphics(); if(g != null) { g.drawImage(tmp, 0, 0, null); g.dispose(); flip(); } render_time = System.nanoTime() - start; if (System.nanoTime() > next_frame_count) { next_frame_count = System.nanoTime() + 1000000000; fps = frame_count; frame_count = 0; System.out.println("FPS: " + fps + ", Process Time: " + process_time / 60 + " Render Time: " + render_time); process_time = 0; } } |