当前位置: 首页>>代码示例>>Python>>正文


Python BufferedImage.toString方法代码示例

本文整理汇总了Python中java.awt.image.BufferedImage.toString方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedImage.toString方法的具体用法?Python BufferedImage.toString怎么用?Python BufferedImage.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GameBase

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import toString [as 别名]

#.........这里部分代码省略.........
            self.prev_stats_time = time_now
            self.stats_interval = 0


    def game_update(self):
        self.gelapsed_after = System.nanoTime()
        
        self.game_time.elapsed_game_time.set_span(self.gelapsed_before, self.gelapsed_after)
        self.game_time.elapsed_real_time.set_span(self.gelapsed_before, self.gelapsed_after)
        
        self.game_time.total_game_time.set_span(self.game_start_time, self.gelapsed_after)
        self.game_time.total_real_time.set_span(self.game_start_time, self.gelapsed_after)
        
        self.gelapsed_before = System.nanoTime()
        
        if self.running and self.is_paused is not True and self.game_over is not True:
            for item in self.components.getComponents():
                item.update(self.game_time)
            self.updates += 1


    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 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 start_game(self):
        if self.running:
            return
        self.thread = Thread(self)
        self.thread.start()
        self.running = True


    def stop_game(self):
        if self.running is None:
            return
        self.thread.stop()
        self.running = False


    def set_preferred_fps(self, fps):
        self.period = 1000/fps


    def reset_elapsed_time(self):
        self.game_time.elapsed_game_time.set_span(0)
        self.game_time.elapsed_real_time.set_span(0)


    def add_component(self, game_component):
        game_component.initialize()
        game_component.load_content()
        self.components.add(game_component)


    def remove_component(self, game_component):
        game_component.unload_content()
        self.components.remove(game_component)


    def resume_game(self):
        self.is_paused = False


    def pause_game(self):
        self.is_paused = True


    def print_stats(self):
        System.out.println("Frame Count/Loss: %s / %s" % (self.frame_count, self.total_frames_skipped))
        System.out.println("Average FPS: %s" % self.df.format(self.average_fps))
        System.out.println("Average UPS: %s" % self.df.format(self.average_ups))
        System.out.println("TIme Spend: %s secs" % self.time_spend_in_game)
        System.out.println("Total Updates: %s" % self.updates)
        System.out.println("dbImage: %s" % self.db_image.toString())
开发者ID:TimHarrison,项目名称:DeadMarsLibrary-Jython,代码行数:104,代码来源:game_base.py


注:本文中的java.awt.image.BufferedImage.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。