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


Python Fog.setMode方法代码示例

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


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

示例1: gameLoop

# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setMode [as 别名]
    def gameLoop(self, task):

        #Compensate for inconsistent update intervals

        dt = globalClock.getDt()

        if self.GAME_MODE == MAIN_MENU:

            if not self.mode_initialized:

                self.buildMainMenu()

                self.mode_initialized = True

        if self.GAME_MODE == IN_GAME_MENU:

            if not self.mode_initialized:

                #Fog out background

                inGameMenuFogColor = (50, 150, 50)

                inGameMenuFog = Fog("inGameMenuFog")

                inGameMenuFog.setMode(Fog.MExponential)
                inGameMenuFog.setColor(*inGameMenuFogColor)
                inGameMenuFog.setExpDensity(.01)

                render.setFog(inGameMenuFog)

                self.buildInGameMenu()

                self.mode_initialized = True

        if self.GAME_MODE == PLAY:

            if not self.mode_initialized:

                props = WindowProperties()
                props.setCursorHidden(True) 
                base.win.requestProperties(props)

                self.last_mouse_x = self.win.getPointer(0).getX()
                self.last_mouse_y = self.win.getPointer(0).getY()

                self.mode_initialized = True

            if self.play_mode == TERRAIN:

                self.maintainTurrets()
                self.avatar.move(dt)

            elif self.play_mode == SPACE:

                self.asteroidManager.maintainAsteroidField(self.avatar.objectNP.getPos(), 
                                                           self.avatar.speed, dt)

            #Handle keyboard input

            self.avatar.handleKeys(self.keys, self.play_mode)

            ########## Mouse-based viewpoint rotation ##########

            mouse_pos = self.win.getPointer(0)

            current_mouse_x = mouse_pos.getX()
            current_mouse_y = mouse_pos.getY()

            #Side to side

            if self.play_mode == TERRAIN:

                mouse_shift_x = current_mouse_x - self.last_mouse_x
                self.last_mouse_x = current_mouse_x

                if current_mouse_x < 5 or current_mouse_x >= (self.win_center_x * 1.5):

                    base.win.movePointer(0, self.win_center_x, current_mouse_y)
                    self.last_mouse_x = self.win_center_x

                yaw_shift = -((mouse_shift_x) * Camera.ROT_RATE[0])

                self.avatar.yawRot += yaw_shift

                self.avatar.objectNP.setH(self.avatar.yawRot)

            #Up and down

            mouse_shift_y = current_mouse_y - self.last_mouse_y
            self.last_mouse_y = current_mouse_y

            if current_mouse_y < 5 or current_mouse_y >= (self.win_center_y * 1.5):

                base.win.movePointer(0, current_mouse_x, self.win_center_y)
                self.last_mouse_y = self.win_center_y

            pitch_shift = -((mouse_shift_y) * Camera.ROT_RATE[1])

            self.mainCamera.pitchRot += pitch_shift

#.........这里部分代码省略.........
开发者ID:zking773,项目名称:ManhattanProject,代码行数:103,代码来源:main2.py

示例2: gameLoop

# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setMode [as 别名]
    def gameLoop(self, task):

        #Compensate for inconsistent update intervals

        dt = globalClock.getDt()

        if self.GAME_MODE == MAIN_MENU:

            if not self.mode_initialized:

                self.buildMainMenu()

                self.mode_initialized = True

        if self.GAME_MODE == IN_GAME_MENU:

            if not self.mode_initialized:

                inGameMenuFogColor = (50, 150, 50)

                inGameMenuFog = Fog("inGameMenuFog")

                inGameMenuFog.setMode(Fog.MExponential)
                inGameMenuFog.setColor(*inGameMenuFogColor)
                inGameMenuFog.setExpDensity(.01)

                render.setFog(inGameMenuFog)

                self.buildInGameMenu()

                self.mode_initialized = True

        if self.GAME_MODE == NORMAL:

            if not self.mode_initialized:

                props = WindowProperties()
                props.setCursorHidden(True) 
                base.win.requestProperties(props)

                self.last_mouse_x = self.win.getPointer(0).getX()
                self.last_mouse_y = self.win.getPointer(0).getY()

                self.mode_initialized = True

            #Handle keyboard input

            self.avatar.handleKeys(self.keys)
            self.avatar.move(dt)

            #Mouse-based viewpoint rotation

            mouse_pos = self.win.getPointer(0)

            current_mouse_x = mouse_pos.getX()
            current_mouse_y = mouse_pos.getY()

            mouse_shift_x = current_mouse_x - self.last_mouse_x
            mouse_shift_y = current_mouse_y - self.last_mouse_y

            self.last_mouse_x = current_mouse_x
            self.last_mouse_y = current_mouse_y

            if current_mouse_x < 5 or current_mouse_x >= (self.win_center_x * 1.5):

                base.win.movePointer(0, self.win_center_x, current_mouse_y)
                self.last_mouse_x = self.win_center_x

            if current_mouse_y < 5 or current_mouse_y >= (self.win_center_y * 1.5):

                base.win.movePointer(0, current_mouse_x, self.win_center_y)
                self.last_mouse_y = self.win_center_y

            yaw_shift = -((mouse_shift_x) * Camera.ROT_RATE[0])
            pitch_shift = -((mouse_shift_y) * Camera.ROT_RATE[1])

            self.avatar.yawRot += yaw_shift
            self.mainCamera.pitchRot += pitch_shift

            if self.mainCamera.pitchRot > Camera.MAX_PITCH_ROT:

                self.mainCamera.pitchRot = Camera.MAX_PITCH_ROT

            elif self.mainCamera.pitchRot < Camera.MIN_PITCH_ROT:

                self.mainCamera.pitchRot = Camera.MIN_PITCH_ROT

            self.avatar.objectNP.setH(self.avatar.yawRot)

            self.mainCamera.camObject.setH(self.avatar.yawRot)
            self.mainCamera.camObject.setP(self.mainCamera.pitchRot)

            if self.NAVIGATION_MODE == TERRAIN:

                xy_plane_cam_dist = Camera.AVATAR_DIST

                cam_z_adjust = Camera.ELEVATION

            elif self.NAVIGATION_MODE == SPACE:

#.........这里部分代码省略.........
开发者ID:zking773,项目名称:ManhattanProject,代码行数:103,代码来源:first1.py


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