private void render() { BufferStrategy bs = getBufferStrategy(); if (bs == null) { createBufferStrategy(4); // Too Slow? make this 3 return; } // Optional clearing goes below screen.clear(); // Rendering goes below: screen.fillBackRoundSolidColor(0x456654); int xScroll = player.getX() - screen.width / 2; int yScroll = player.getY() - screen.height / 2; screen.fillBackRoundImage("/Levels/TestBckgrnd.png", screen); level.render(xScroll, yScroll, screen); player.render(screen); for (int i = 0; i < pixels.length; i++) { // Sets the pixels array in MainGame to the pixel array in the Screen class pixels[i] = screen.pixels[i]; } // Displaying goes below: Graphics g = bs.getDrawGraphics(); g.drawImage(image, 0, 0, getWidth(), getHeight(), null); // Draws the buffered image (pixels[]) // FrameRate Display if (Fframes >= 60) g.setColor(Color.white); else if (Fframes >= 55) g.setColor(Color.YELLOW); else if (Fframes > 65) g.setColor(Color.GREEN); else g.setColor(Color.red); g.setFont(new Font("Verdana", 0, 10)); String err = ""; if (Fframes <= 20 || Fframes > 65) err = "| CHECK FRAMERATE |"; g.drawString( "(" + Fframes + ")" + " " + df.format(framePerc) + "% " + err, 10, HEIGHT * SCALE - 10); g.setColor(Color.white); g.drawString( "Version: " + PrefixVers + " " + NumberVers, WIDTH * SCALE - 150, HEIGHT * SCALE - 10); // End of FrameRateDisplay // g.drawRect(0, 141 * SCALE, 300 * SCALE + 8 , 70); g.dispose(); // Disposes the graphics bs.show(); // Shows the next buffer }
private void tick() { input.tick(); player.tick(); }