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


Python Scene.Scene类代码示例

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


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

示例1: processEvent

    def processEvent(self, event):
        if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            m = MessageScene(self.director, self)
            self.director.setScene(m)

        self.player.controller.processEvent(event)
        Scene.processEvent(self, event)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:7,代码来源:Level.py

示例2: DanceCV

class DanceCV():
    def __init__(self, song, speed):

        self.input = Input()
        self.resource = Resource()
        self.audio = Audio()
        self.audio.pre_open()
        pygame.init()
        self.audio.open()
        if song != None:
            self.song = loadSong(self.resource, song)
        else:
            self.song = loadSong(self.resource, "gangnam")
        self.clock = pygame.time.Clock()
        pygame.display.set_mode((Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))
        pygame.display.set_caption("DanceCV")
        screen = pygame.display.get_surface()
        if speed != None:
            self.scene = Scene(self.resource, self.song, screen, self.input, speed)
        else:
            self.scene = Scene(self.resource, self.song, screen, self.input, 2)

        
        
    def run(self):
        while True:
            for events in pygame.event.get():
                if events.type == QUIT:
                    sys.exit(0)
            self.input.run()
            self.scene.run()
            pygame.display.update()
            self.clock.tick(30)
开发者ID:guru81,项目名称:DanceCV,代码行数:33,代码来源:DanceCV.py

示例3: render

 def render(self, visibility, topMost):
   if self.gameStarted:
     return
   if self.items == []:
     return
   Scene.render(self, visibility, topMost)
   self.engine.view.setOrthogonalProjection(normalize = True)
   self.engine.view.setViewport(1,0)
   w, h = self.engine.view.geometry[2:4]
   
   if self.img_background:
     self.engine.drawImage(self.img_background, scale = (1.0, -1.0), coord = (w/2,h/2), stretched = 3)
   
   try:
     if self.mode == 0:
       self.renderSetlist(visibility, topMost)
       if self.moreInfoTime > 0:
         self.engine.theme.setlist.renderMoreInfo(self)
       if self.miniLobbyTime > 0:
         self.engine.theme.setlist.renderMiniLobby(self)
     # I am unsure how I want to handle this for now. Perhaps as dialogs, perhaps in SCS.
     elif self.mode == 1:
       self.renderSpeedSelect(visibility, topMost)
     elif self.mode == 2:
       self.renderTimeSelect(visibility, topMost)
   finally:
     self.engine.view.resetProjection()
开发者ID:cherbib,项目名称:fofix,代码行数:27,代码来源:SongChoosingScene.py

示例4: draw

 def draw(self, screen):
     s = pygame.Surface((SCREEN_W, SCREEN_H))
     self.pausedScene.draw(s)
     self.bluredBackground = self.blur(s, self.b)
     if self.b < 10:
         self.b = self.b + 0.1
     screen.blit(self.bluredBackground, (0, 0))
     Scene.draw(self, screen)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:8,代码来源:MessageScene.py

示例5: parseScenes

    def parseScenes(self, storyPath):
        dom = xml.dom.minidom.parse(storyPath)
        scenes = dom.getElementsByTagName("scene")
        for x in scenes:
            idscene = x.getAttribute("id")
            fondo = x.getElementsByTagName("background")[0]
            background = fondo.getAttribute("value")
            if len(x.getElementsByTagName("escena_opcion1")) != 0:
                escena_opcion1 = x.getElementsByTagName("escena_opcion1")[0].getAttribute("value")
            if len(x.getElementsByTagName("escena_opcion2")) != 0:
                escena_opcion2 = x.getElementsByTagName("escena_opcion2")[0].getAttribute("value")
            if len(x.getElementsByTagName("escena_opcion3")) != 0:
                escena_opcion3 = x.getElementsByTagName("escena_opcion3")[0].getAttribute("value")
                 
            audio = x.getElementsByTagName("audio")[0].getAttribute("value")
            relato = x.getElementsByTagName("relato")[0].getAttribute("value")
            opciones = x.getElementsByTagName("option")
            parsedOptions = []
            for opcion in opciones:
                print "parsing option"
                optionId = opcion.getAttribute("id")
                optionImage = opcion.getElementsByTagName("image")[0].getAttribute("value")
                optionPosX = opcion.getElementsByTagName("position")[0].getAttribute("x")
                optionPosY = opcion.getElementsByTagName("position")[0].getAttribute("y")
                action_verb = opcion.getElementsByTagName("action")[0].getAttribute("verb")
                action_resource = opcion.getElementsByTagName("action")[0].getAttribute("resource")
                action_x = opcion.getElementsByTagName("action")[0].getAttribute("x")
                action_y = opcion.getElementsByTagName("action")[0].getAttribute("y")
                action_speed = opcion.getElementsByTagName("action")[0].getAttribute("x")
                personajeId = opcion.getElementsByTagName("character")[0].getAttribute("charid")
                act = Action(action_verb,action_resource,action_x,action_y,action_speed)

                newOpt = Option(optionId,optionImage,optionPosX, optionPosY,act,personajeId)
                parsedOptions.append(newOpt)
            scene = Scene(self._surf_display, background, escena_opcion1 , escena_opcion2, escena_opcion3, audio, relato, parsedOptions)
            characters_xml = x.getElementsByTagName("scene_character")
            print "personajes " + str(len(characters_xml))
            for charxml in characters_xml:
                charid = charxml.getAttribute("id")
                print "IdEscena= " + idscene + ". Personaje " + charid
                charx = charxml.getElementsByTagName("position")[0].getAttribute("x")
                chary = charxml.getElementsByTagName("position")[0].getAttribute("y")
                if charid != "guzman":
                    toAdd = Character(charid, self.character_sprites[charid], charx, chary)
                    scene.addCharacter(toAdd)
                    print "[Main] se agrego un personaje a la escena. Personaje " + charid

            print "se creo escena con" + str(len(parsedOptions)) + " opciones"
            self.scenes[idscene] = scene
            self.scenes[self.current_scene].setearDatos(self._surf_display, self.current_scene)
            self.imprimir.setearDatos(self._surf_display)
开发者ID:nexo-developers,项目名称:nexo,代码行数:51,代码来源:Main.py

示例6: draw

    def draw(self, screen):
        screen.fill(0x000000)

        if self.bg:
            screen.blit(self.bg, self.camera.state)

        if Constants.DEBUG:
            self.drawRaytracing(screen)
        self.player.draw(screen, self.camera)
        for group in self.groups:
            group.draw(screen, self.camera)
        self.drawDanger(screen);
        
        # TODO: move maps and characters to its own layer
        Scene.draw(self, screen)  # draws rest of layers
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:15,代码来源:Level.py

示例7: setUp

   def setUp(self):
       '''
       Create a scene with a camera placed at [0, 0, 4] and looking at the
       world origin. 
       '''
       scene = Scene()
       self.scene = scene
 
       #Camera
       camera = Camera({'from':np.array([1.,4.,-2.]), 
                        'to':np.array([1.,-2.,4]), 
                        'up':GT.normalize(np.array([-1.,1.,0.])), 
                        'fov':45, 
                        'width':10001, 'height':10001}) # choose very high dimension to avoid rounding error
       render = Render({'camera':camera})
       scene.render = render
开发者ID:slflmm,项目名称:RayTracer,代码行数:16,代码来源:TestCreateRay.py

示例8: __init__

 def __init__(self, filename):
     print('Parsing ' + filename)
     self.Materials = dict() # used for storing ref to materials
     self.Nodes = dict()     # used for storing ref to nodes
     self.NodeStack = []
     self.scene = Scene()
     xml = minidom.parse(filename)
     self.parse(xml)
     print('parsing done.')
开发者ID:danhp,项目名称:socs,代码行数:9,代码来源:SceneParser.py

示例9: run

    def run(self, ticks):
        if self.cmdPlay:
            self.startGame()
            return
        if len(self.engine.world.songQueue) > 0 and self.queued:
            self.startGame(fromQueue=True)
            return
        if self.gameStarted or self.items == []:
            return

        Scene.run(self, ticks)
        if self.queued:
            self.queued = False
        if self.scrolling:
            self.scrollTime -= ticks
            if self.scrollTime < 0:
                self.scrollTime = self.scrollRate
                self.scroller[self.scrolling]()

        if self.mode == 0:
            if self.previewDelay > 0 and self.autoPreview:
                self.previewDelay -= ticks
                if self.previewDelay < 0:
                    self.previewDelay = 0
            if not self.previewLoaded and self.previewDelay == 0:
                self.previewSong()

            d = self.cameraOffset - self.selectedOffset
            self.cameraOffset -= d * ticks / 192.0
            for i in range(len(self.itemRenderAngles)):
                if i == self.selectedIndex:
                    self.itemRenderAngles[i] = min(90, self.itemRenderAngles[i] + ticks / 2.0)
                else:
                    self.itemRenderAngles[i] = max(0, self.itemRenderAngles[i] - ticks / 2.0)

            if self.moreInfo:
                self.moreInfoTime += ticks
            elif self.moreInfoTime > 0:
                self.moreInfoTime -= ticks
                if self.moreInfoTime < 0:
                    self.moreInfoTime = 0

        self.engine.theme.setlist.run(ticks)
开发者ID:paulhayes,项目名称:fofix,代码行数:43,代码来源:SongChoosingScene.py

示例10: __init__

 def __init__(self, director, pausedScene, title='Warning!', message='Message', tooltip='Press here to continue'):
     Scene.__init__(self, director)
     self.bluredBackground = None
     self.b = 1
     self.pausedScene = pausedScene
     layer = Layer(director)
     backgroundImage = Resources.load_image("message_box.png")
     buttonImage = Resources.load_image("message_box_button.png")
     buttonWidth = 372
     style = MessageBox.createMessageBoxStyle(
         backgroundImage, buttonImage, buttonWidth)
     self.messageBox = MessageBox.MessageBox(
         self.director, (SCREEN_W / 2 - style['bg'].get_width() / 2, SCREEN_H / 2 - style['bg'].get_height() / 2), style, True)
     self.messageBox.button.onMouseDown = lambda: self.popScene()
     self.messageBox.title = title
     self.messageBox.message = message
     self.messageBox.tooltip = tooltip
     layer.append(self.messageBox)
     self.layers.append(layer)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:19,代码来源:MessageScene.py

示例11: __init__

    def __init__(self, song, speed):

        self.input = Input()
        self.resource = Resource()
        self.audio = Audio()
        self.audio.pre_open()
        pygame.init()
        self.audio.open()
        if song != None:
            self.song = loadSong(self.resource, song)
        else:
            self.song = loadSong(self.resource, "gangnam")
        self.clock = pygame.time.Clock()
        pygame.display.set_mode((Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))
        pygame.display.set_caption("DanceCV")
        screen = pygame.display.get_surface()
        if speed != None:
            self.scene = Scene(self.resource, self.song, screen, self.input, speed)
        else:
            self.scene = Scene(self.resource, self.song, screen, self.input, 2)
开发者ID:guru81,项目名称:DanceCV,代码行数:20,代码来源:DanceCV.py

示例12: initialize

    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)
开发者ID:xfleckx,项目名称:pyAppDesignStudys,代码行数:11,代码来源:GS_Explained.py

示例13: __init__

    def __init__(self, width, height):
        # create pyglet window
        self.window = pyglet.window.Window(resizable=True)
        self.window.on_draw = self.on_draw
        self.window.on_key_press = self.on_key_press
        self.window.on_key_release = self.on_key_release
        self.window.on_mouse_press = self.on_mouse_press
        self.window.on_mouse_release = self.on_mouse_release
        self.window.on_mouse_drag = self.on_mouse_drag
        self.window.width = width
        self.window.height = height
        self.menu_window = False
        self.gen_entity = 'SQUARE'
        self.gen_size = 50
        self.gen_mass = 500
        self.key_pressed = []
        self.clicked_object = None
        self.clicked_dx = 0
        self.clicked_dy = 0

        # create fps display 
        self.fps_display = pyglet.clock.ClockDisplay()
        self.clock = 0

        # sync clock
        pyglet.clock.schedule_interval(self.tick, 1.0/60.0)   
        pyglet.clock.set_fps_limit(60)

        # create world
        world_width = 3000
        world_height = 3000
        self.world = World(world_width, world_height)

        # create scene- match dimensions of the app window
        self.scene = Scene(width=width, height=height, background_width=world_width, background_height=world_height)

        #self.demo_1(world_width, world_height)
        #self.demo_2(world_width, world_height)
        #self.demo_3(world_width, world_height)

        # initialize background music
        self.music = Music()
        self.music.play_bg()

        # Making the player here (testing)
        mag = 40000
        offset = 400
        player_type = Triangle(size=20, position=Vector2(x=offset, y=offset))
        self.scene.entities.append(player_type)
        self.player = Player(entity=player_type, mass=100)
        self.world.add_body(self.player)
开发者ID:bm1362,项目名称:atlas-py,代码行数:51,代码来源:Simulation.py

示例14: __init__

    def __init__(self, director, player):
        Scene.__init__(self, director)
        self.player = player
        self.enemyGroup = EntityGroup([])
        self.bulletGroup = EntityGroup([])
        self.groups = []
        self.groups.append(self.enemyGroup)
        self.groups.append(self.bulletGroup)

        self.bg = None
        self.collisionBg = None
        self.camera = Camera()

        self.HUD = HUD(self.director, (0, 467), True, player)
        hudLayer = Layer(self.director)
        hudLayer.append(self.HUD)
        self.layers.append(hudLayer)
        self.mouseHoveringHUD = False
        
        self.danger = False
        self.dangerLevel = 0
        
        self.gameOver = False
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:23,代码来源:Level.py

示例15: update

    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,代码行数:24,代码来源:Level.py


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