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


Python Scene.update方法代码示例

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


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

示例1: update

# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import update [as 别名]
    def update(self, time):
        
        if self.gameOver:
            mainMenu = MainMenu.MainMenu(self.director)
            self.director.setScene(mainMenu)
            return
        
        if self.danger:
            self.dangerLevel = 210
            self.danger = False

        if self.collisionBg != None:
            self.player.update(time, self)
            for group in self.groups:
                group.update(time, self)

        self.camera.update(self.player)
        
        Scene.update(self, time)
        
        if self.gameOver:
            game_over_scene = MessageScene(self.director, self)
            game_over_scene.set_message("Has Muerto.")
            self.director.setScene(game_over_scene)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:26,代码来源:Level.py

示例2: update

# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import update [as 别名]
 def update(self):
     Scene.update(self)
开发者ID:choiseungil29,项目名称:CLogic,代码行数:4,代码来源:TestScene.py

示例3: GameEngine

# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import update [as 别名]

#.........这里部分代码省略.........
        """
        self.__run_event = True
        self._event_loop()

    def _draw(self, tick_time):
        """
        Draws all elements in draw callback to the screen

        @param tick_time:       The amount of time passed since last
                                draw cycle. (should be produced by
                                pygamme.clock.tick method)
        """
        screen = self.screen

        # If console is active, we want to draw console, pausing
        # game drawing (events are still being fired, just no
        # draw updates.
        if self.__version:
            if self.console.active:
                self.console.draw()
                pygame.display.flip()
            else:
                for fnc in self.__draw_lst:
                    start = time()
                    fnc()
                    self.__draw_time[str(fnc)] += time() - start
                    self.__draw_calls[str(fnc)] += 1
                # Print Frame Rate
                if self.__showfps:
                    self.__fps.changeText('FPS: %d' % self.clock.get_fps(),
                                                      (255, 255, 255))
                else:
                    self.__fps.changeText('')
                self.__scene.update(tick_time)
                pygame.display.update(self.__scene.draw(screen))
        else:
            if self.console.active:
                self.console.draw()
                pygame.display.flip()
            else:
                for fnc in self.__draw_lst:
                    start = time()
                    fnc(screen, tick_time)
                    self.__draw_time[str(fnc)] += time() - start
                    self.__draw_calls[str(fnc)] += 1
                # Print Frame Rate
                if self.__showfps:
                    text = self.__font.render('FPS: %d' % \
                           self.clock.get_fps(), False, (255, 255, 255),
                           (159, 182, 205))
                    screen.blit(text, (0, 0))
                pygame.display.flip()

    def _event_loop(self):
        """
        The main event loop.
        """
        while self.__run_event:

            event = pygame.event.poll()

            # Handle Game Quit Message
            if event.type == pygame.QUIT:
                self.__run_event = False

            # No-Op sent, draw if set to always draw
开发者ID:sugarlabs,项目名称:Lemonade,代码行数:70,代码来源:GameEngine.py

示例4: App

# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import update [as 别名]
class App(object):

    def __init__(self):
        self.render_asap = False;
        self.app_should_exit = False
        self.root = Tk()
        self.scene = None
        self.lastUpdateMoment = 0
        self.renderingTechniq = RENDER_ON_MAINLOOP
        
    def setAppExit(self):
        self.app_should_exit = TRUE

    def initialize(self):
        speller = GazeSpeller()
        tracker = self._ckeckAvailableTracker()
        canvas = self._initializeCanvas()
        
        if isinstance(tracker,MouseTracker):
            canvas.bind('<Motion>',tracker.onMotion) # use this to let the tracker get updates from the mouse event without actual get knowledge of the GUIs
            # it's named "inversion of control"

        self.scene = Scene(canvas, tracker, speller)
        self.scene.initialize(1)
    
    def startRendering(self):
        if self.renderingTechniq == RENDER_ON_MAINLOOP:
            self.runOnTkInterMainLoop()
        if self.renderingTechniq == RENDER_ON_TIMER_TICK:
            self.runOnExpectedFixedFramerate()
        
        sys.exit(0)
    
    def _ckeckAvailableTracker(self):
        #TODO check if tracker available if not use mouse
        return MouseTracker(self.root)

    def _initializeCanvas(self):
        self.root.attributes("-fullscreen", True)
        self.root.protocol("WM_DELETE_WINDOW", self.setAppExit)
        canvas = Canvas(self.root)
        canvas.pack(fill=BOTH, expand=YES)
        return canvas
    
    def _processRenderLoop(self, deltaTime, CallTkUpdates = False):
        self.scene.update(deltaTime)
        self.scene.render()
        if CallTkUpdates:
            self.root.update_idletasks() # render / drawing
            self.root.update() # perform processing of key events etc
    
    def _estimateFrameTime(self):
        currentMoment = time()
        deltaTime = currentMoment - self.lastUpdateMoment
        self.lastUpdateMoment = currentMoment
        return deltaTime

    # example rendering A
    def runOnExpectedFixedFramerate(self):
        self.lastUpdateMoment = time()
        while not self.app_should_exit:
            deltaTime = self._estimateFrameTime()
            self._processRenderLoop(deltaTime, CallTkUpdates = True)
            if not self.render_asap:
                sleep(self.scene.getExpectedUpdateTime())

    #example rendering B
    def runOnTkInterMainLoop(self):
        self._callUpdatingOnAfterCall();
        self.root.mainloop()
        
    def _callUpdatingOnAfterCall(self):
        deltaTime = self._estimateFrameTime()
        self._processRenderLoop(deltaTime)
        # uses a scheduler from tkinter GUI Mainloop - test
        # self.scene.getExpectedUpdateTime()
        self.root.after(1, self._callUpdatingOnAfterCall)
开发者ID:xfleckx,项目名称:pyAppDesignStudys,代码行数:79,代码来源:GS_Explained.py


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