本文整理汇总了Python中panda3d.core.WindowProperties类的典型用法代码示例。如果您正苦于以下问题:Python WindowProperties类的具体用法?Python WindowProperties怎么用?Python WindowProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindowProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.base = ShowBase()
# graphics
# window
props = WindowProperties()
self.win_size = 600
props.setSize(self.win_size, self.win_size)
self.base.win.requestProperties(props)
# set up key
self.accept("c", self.move_center)
self.accept("b", self.plot_bananas)
self.accept("space", self.change_both)
self.num_bananas = 10
# total area is 100 (not true of the game, but just scales.
# was easier to make everything 1/2 size for this size window)
high_area = 0.25 * 0.33 * 100
middle_area = 0.25 * 100
self.high_radius = sqrt(high_area / pi)
self.middle_radius = sqrt(middle_area / pi)
self.high_reward = 6
self.middle_reward = 4
self.low_reward = 2
#print self.high_radius
#print self.middle_radius
self.weight_center = (random.uniform(-5, 5), random.uniform(-5, 5))
#print('weight center', self.weight_center)
self.banana_model = []
self.center_model = None
self.high_node = None
self.high_circle = None
self.middle_node = None
self.middle_circle = None
self.plot_border()
self.plot_bananas()
self.plot_circles()
示例2: __init__
def __init__(self):
DirectObject.__init__(self)
self.base = ShowBase()
resolution = (1024, 768)
wp = WindowProperties()
wp.setSize(int(resolution[0]), int(resolution[1]))
wp.setOrigin(0, 0)
self.base.win.requestProperties(wp)
# depth completely doesn't matter for this, since just 2d, and no layers
self.depth = 0
self.base.setBackgroundColor(115 / 255, 115 / 255, 115 / 255)
# set up a 2d camera
camera = self.base.camList[0]
lens = OrthographicLens()
lens.setFilmSize(int(resolution[0]), int(resolution[1]))
lens.setNearFar(-100, 100)
camera.node().setLens(lens)
camera.reparentTo(self.base.render)
self.accept("escape", sys.exit)
# spread out some positions
self.positions = [(-200, 0, -200),
(0, 0, -200),
(200, 0, -200),
(-200, 0, 0),
(0, 0, 0),
(200, 0, 0),
(-200, 0, 200),
(0, 0, 200),
(200, 0, 200)]
self.all_smiles()
示例3: setMouseModeRelative
def setMouseModeRelative(self, state):
props = WindowProperties()
if not state:
props.setMouseMode(WindowProperties.MAbsolute)
else:
props.setMouseMode(WindowProperties.MRelative)
self.targetWin.requestProperties(props)
示例4: exitGameOver
def exitGameOver(self):
base.taskMgr.remove("menu")
properties = WindowProperties()
properties.setCursorHidden(True)
base.win.requestProperties(properties)
self.gm.destroy()
示例5: __init__
def __init__(self):
DirectObject.__init__(self)
self.close=lambda:None
#create main window
base=ShowBase()
__builtin__.base=base
props = WindowProperties()
#props.setTitle(ConfigVariableString('win-title').getValue())
props.setFullscreen(ConfigVariableBool('fullscreen').getValue())
props.setSize(ConfigVariableInt('win-width').getValue(),ConfigVariableInt('win-height').getValue())
base.win.requestProperties(props)
self.width=base.win.getXSize()
self.height=base.win.getYSize()
print 'size=',self.width,'x',self.height
self.accept('window-event',self.on_resize)
base.disableMouse()
#set fps limit
globalClock=ClockObject.getGlobalClock()
globalClock.setMode(ClockObject.MLimited)
globalClock.setFrameRate(ConfigVariableDouble('clock-frame-rate').getValue())
__builtin__.screen=self
__builtin__.gui=pixel2d.attachNewNode('Screen.gui')
#gui is the node for 2d rendering, scaled to the screen resolution,
#with origin at bottom-left, and max at top-right
gui.setZ(gui,-self.height)
__builtin__.console=Console(print_messenger_events=False)
__builtin__.out=console.out
console.request('Open')
__builtin__.mouse=base.pointerWatcherNodes[0]
#is used as a stack. stores frames showed to the user (top at the front of the screen)
self.frames=[]
示例6: __init__
def __init__(self):
# INIT Needed things.
# Inst. for Player Class playership.
initPlayerShip = PlayerShip()
self.playershipOB = initPlayerShip.playerShip
### SETUP CONTROL MAPS ###
self.controlMap = {"left": 0, "right": 0, "forward": 0, "backward": 0, "wheel-in": 0, "wheel-out": 0}
self.mousebtn = [0, 0, 0]
### SETUP KEYBOARD ###
# Setup the control [KEYS] for movement w,a,s,d. | This is basic will have to adjust for advance controls.
self.accept("escape", sys.exit)
self.accept("w", self.setControl, ["forward", 1])
self.accept("a", self.setControl, ["left", 1])
self.accept("s", self.setControl, ["backward", 1])
self.accept("d", self.setControl, ["right", 1])
self.accept("w-up", self.setControl, ["forward", 0])
self.accept("a-up", self.setControl, ["left", 0])
self.accept("s-up", self.setControl, ["backward", 0])
self.accept("d-up", self.setControl, ["right", 0])
# Setup mouse [ZOOM].
self.accept("wheel_up", self.setControl, ["wheel-in", 1])
self.accept("wheel_down", self.setControl, ["wheel-out", 1])
# Add the "moveTask"
taskMgr.add(self.move, "moveTask")
# Game State Variable.
self.IsMoving = False
###>
### SETUP CAMERA ###
# Reparent the -main- Camera to PlayerShip.
base.camera.reparentTo(self.playershipOB)
# The vertical offset. To view over ship.
self.cameraHeight = 0.05
# Camera Distance from playerShip. On Start.
self.cameraDistance = 0.23
# Camera Pitch.
self.cameraPitch = 0.04
# Disable the basic camera controls.
base.disableMouse()
# This should be used together with a right click function, for the camera rotate. Like in wow.
WinProps = WindowProperties()
# Hide the cursor. | This will change with the rightClick function.
# Giving us the cursor when not rotating. If the player wants to rotate basic [KEYS] left/right can turn while cursor is active.
WinProps.setCursorHidden(True)
base.win.requestProperties(WinProps)
示例7: __init__
def __init__(self, parent, pos):
self.parent = parent
self.node = render.attachNewNode('PlayerNode')
self.node.setPos(pos[0]*TILE_SIZE,pos[1]*TILE_SIZE,TILE_SIZE*ASPECT/1.5)
taskMgr.add(self.updatePlayer, 'UpdatePlayerTask')
taskMgr.add(self.updateBullets, 'UpdateBulletsTask')
self.centerx = base.win.getProperties().getXSize()/2
self.centery = base.win.getProperties().getYSize()/2
self.speed = TILE_SIZE - 4
self.sprint_speed = self.speed * 1.8
self.can_move = True
self.camera = True
self.mouse_owner = True
self.max_health = 100
self.health = self.max_health
self.max_bullets = 10
self.bullets = 4
self.bullet_objects = []
self.sprint = False
self.moving = False
self.gunshot_at = None
props = WindowProperties()
props.setCursorHidden(True)
base.win.requestProperties(props)
# Create player flashlight
self.slight = Spotlight('slight')
self.slight.setColor(VBase4(1, 1, 0.6, 1))
#self.lens = PerspectiveLens()
#self.slight.setLens(self.lens)
self.slnp = self.node.attachNewNode(self.slight)
self.slnp.node().getLens().setFov(88)
self.slnp.node().getLens().setNearFar(1, 70)
self.slight.setExponent(10)
self.slight.setAttenuation(Point3(0.737, 0.134, 0.001))
render.setLight(self.slnp)
self.flashlight = True
self.shoot_sound = base.loader.loadSfx("audio/GUN_FIRE-GoodSoundForYou-820112263.wav")
self.gun_click_sound = base.loader.loadSfx("audio/Dry Fire Gun-SoundBible.com-2053652037.wav")
self.heart_sound = base.loader.loadSfx("audio/Slow_HeartBeat-Mike_Koenig-1853475164.wav")
self.heart_sound.setLoop(True)
self.heart_sound.setVolume(0.6)
self.heart_sound.play()
self.scratches = loadImageAsPlane('models/scr.png')
self.scratches.setTransparency(TransparencyAttrib.MAlpha)
self.damage_anim = Parallel()
self.keys = {}
self.keys['forward'] = 0
self.keys['back'] = 0
self.keys['strafe_left'] = 0
self.keys['strafe_right'] = 0
self.keys['sprint'] = 0
self.setKeyEvents()
self.pause = False
示例8: createBuffer
def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1):
""" Low-level buffer creation. Not intended for public use. """
winprops = WindowProperties()
winprops.setSize(xsize, ysize)
props = FrameBufferProperties(FrameBufferProperties.getDefault())
props.setBackBuffers(0)
props.setRgbColor(1)
props.setDepthBits(depthbits)
props.setStereo(self.win.isStereo())
depthtex, colortex, auxtex0, auxtex1 = texgroup
if (auxtex0 != None):
props.setAuxRgba(1)
if (auxtex1 != None):
props.setAuxRgba(2)
buffer=base.graphicsEngine.makeOutput(
self.win.getPipe(), name, -1,
props, winprops, GraphicsPipe.BFRefuseWindow | GraphicsPipe.BFResizeable,
self.win.getGsg(), self.win)
if (buffer == None):
return buffer
if (depthtex):
buffer.addRenderTexture(depthtex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth)
if (colortex):
buffer.addRenderTexture(colortex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)
if (auxtex0):
buffer.addRenderTexture(auxtex0, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0)
if (auxtex1):
buffer.addRenderTexture(auxtex1, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1)
buffer.setSort(self.nextsort)
buffer.disableClears()
self.nextsort += 1
return buffer
示例9: __init__
def __init__(self):
ShowBase.__init__(self)
wp = WindowProperties()
wp.setSize(850, 480)
wp.setTitle("GAME")
base.win.requestProperties(wp)
bgg = BlockGeometryGenerator()
blocks = []
for x in xrange(1):
for y in xrange(512):
for z in xrange(64):
bid = random.randint(0, 255)
blocks.append(bid)
bgg.GenerateBlockGeometry(x, y, z, Block(bid), [0])
#blocks[x * 512 * 64 + y * 64 + z] = 1
print x
ambientLight = AmbientLight('ambientLight')
ambientLight.setColor(Vec4(0.2, 0.2, 0.2, 1))
ambientLightNP = render.attachNewNode(ambientLight)
render.setLight(ambientLightNP)
示例10: __init__
def __init__(self, parentChar, keyMap):
assert isinstance(parentChar, Character)
base.disableMouse()
self.char = parentChar
self.keyMap = keyMap
print 'keymap is',keyMap
parentChar.node.rotationallyImmune = True
self.floater = NodePath('floater')
self.floater.reparentTo(parentChar.node)
self.floater.setPos(1,0,2)
base.camera.reparentTo(self.floater)
base.camera.setPos(0,-5,0)
base.camera.setH(0)
print base.camera.getPos(render)
props = WindowProperties()
props.setCursorHidden(True)
base.win.requestProperties(props)
taskMgr.add(self.controlCamera, 'camera-task')
self.h = parentChar.node.getH()
self.p = parentChar.node.getP()
示例11: main
def main():
# Handles CLI arguments
p = OptionParser()
p.add_option('-m', '--nomusic', action="store_false", dest="music", default = True, help = u"Disable music")
p.add_option('-e', '--editor-mode', action="store_true", dest="editor", default = False, help = u"Editor mode")
options, args = p.parse_args()
levelname = 'level1'
if args:
levelname = args[0]
# Instantiate the ShowBase
base = ShowBase()
# Toggle events verbosity :
#base.messenger.toggleVerbose()
# Set window properties:
# - Hide mouse cursor
# - move the window (because of the pekwm bug)
curProps = base.win.getProperties()
props = WindowProperties()
props.setOrigin(curProps.getXOrigin() + 1, curProps.getYOrigin() + 1)
props.setCursorHidden(True)
base.win.requestProperties(props)
# Now instantiate Gate's own stuff
fps = FPS(base, levelname, options)
osd = OSD(base, fps)
mplayer = MusicPlayer(base, osd)
if options.music:
mplayer.play_random_track()
player = Player(base, fps, osd)
# And run the ShowBase
base.run()
示例12: catchCursor
def catchCursor(self):
# center the mouse in the middle of the window
base.win.movePointer(0, self.win_width_half, self.win_height_half)
# Set mouse mode to relative which should work best for our purpose
wp = WindowProperties()
wp.setMouseMode(WindowProperties.M_relative)
base.win.requestProperties(wp)
示例13: __clearWindowProperties
def __clearWindowProperties(self):
""" Clears the windowPrc file that was created in a previous
call to setupWindow(), if any. """
if self.windowPrc:
unloadPrcFile(self.windowPrc)
self.windowPrc = None
WindowProperties.clearDefault()
示例14: setCursor
def setCursor(self):
base.win.clearRejectedProperties()
props = WindowProperties()
if sys.platform.startswith('linux'):
props.setCursorFilename("./assets/cursor.x11")
else:
props.setCursorFilename("./assets/cursor.ico")
base.win.requestProperties(props)
示例15: toggle_fullscreen
def toggle_fullscreen(self):
wp = WindowProperties()
self.isFullScreen = not self.isFullScreen
wp.setFullscreen(self.isFullScreen)
wp.setSize(1024, 768)
base.openMainWindow()
base.win.requestProperties(wp)
base.graphicsEngine.openWindows()