def paint_screen(self): bs = Canvas.getBufferStrategy() if bs is None: Canvas.createBufferStrategy(3) g = bs.getDrawGraphics() g.drawImage(self.db_image, 0, 0, Component.getWidth(), Component.getHeight(), None) g.dispose() bs.show()
def get_render(self): if self.db_image is None or self.size_changed: size = Dimension(Component.getWidth(), Component.getHeight()) self.set_size(size) Component.setPreferredSize(size) Component.setMinimumSize(size) Component.setMaximumSize(size) self.size_changed = False try: self.db_image = BufferedImage(Component.getWidth(), Component.getHeight(), BufferedImage.TYPE_INT_RGB) except JavaException as e: self.db_image = None System.out.println("Render Error: %s" % e) System.out.println("Render Error: Buffer not initialized properly") System.out.println("Render Error: Resolving...")
def __init__(self, size, fps): self.set_size(size) Component.setPreferredSize(size) Component.setMinimumSize(size) Component.setMaximumSize(size) Component.setBackground(Color.white) Component.setFocusable(True) Component.requestFocus() db_image = BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB) self.fps_store = self.NUM_FPS self.ups_store = self.NUM_FPS i = 0 if i < self.NUM_FPS: self.fps_store[i] = 0 self.ups_store[i] = 0 i += 1