當前位置: 首頁>>代碼示例>>Python>>正文


Python Group.draw方法代碼示例

本文整理匯總了Python中pygame.sprite.Group.draw方法的典型用法代碼示例。如果您正苦於以下問題:Python Group.draw方法的具體用法?Python Group.draw怎麽用?Python Group.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pygame.sprite.Group的用法示例。


在下文中一共展示了Group.draw方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Player

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Player(Sprite):

    def __init__(self, game):
        Sprite.__init__(self)
        self.game = game
        self.image = game.get_tile_surface('rot.hoch')
        self.mask = mask.from_surface(self.image)
        self.g = Group(self)
        self.pos = Vector(300, 510)
        self.speed = 4
        self.direction = RIGHT

    def set_direction(self, direction):
        if direction in [LEFT, RIGHT]:
            self.direction = direction

    def get_shot(self):
        return Shot(self.game, (self.pos.x, self.pos.y - 16), UP)

    def move(self):
        self.pos += self.direction * self.speed
        if self.pos.x < MIN_X:
            self.pos.x = MIN_X
        elif self.pos.x > MAX_X:
            self.pos.x = MAX_X

    def draw(self):
        self.rect = Rect(self.pos.x, self.pos.y, 32, 32)
        self.g.draw(self.game.screen.display)
開發者ID:krother,項目名稱:tilegamelib,代碼行數:31,代碼來源:invaders.py

示例2: start

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
  def start( self ):

    Game.started = True

    level       = gamelevel.levels[ str( Game.game_level ) ]
    xmax, ymax  = self.surface.get_size()
    self.stopped_balls = 0

    # Starter ball
    starter = ball.StarterBall( 30, pygame.Color( 255, 0, 0 ) )
    starter_group = Group( starter )
    starter_group.draw( self.surface )

    # All balls
    sprites = [
      ball.GameBall( i, level[ 'ball_size' ], level[ 'ball_speed' ] , level[ 'expanded_ball_size' ], xmax, ymax )
        for i in range( level[ 'number_of_balls' ] )
    ]

    # Group
    group  = Group( sprites )

    # Draw
    group.draw( self.surface )

    # Set instance variables
    self.sprites, self.group, self.starter, self.starter_group = sprites, group, starter, starter_group


    # blank stuff
    self.blank = pygame.Surface(( level[ 'ball_size'] * 2 , level[ 'ball_size' ] * 2) )
    self.blank = self.blank.convert_alpha()
開發者ID:gvenkat,項目名稱:chain-reaction,代碼行數:34,代碼來源:game.py

示例3: Level

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Level(object):

    def __init__(self):
        self.bounds = Rect((0,0), LEVEL_SIZE)
        print "self.bounds = ", self.bounds

        self.ceilingCoord = 0
        self.floorCoord = self.bounds.height - 40
        self.leftWall = 0
        self.rightWall = self.bounds.width - 40
        
        # make rects for level
        self.blocks = Group(Block(0,0,40,self.bounds.height), # left wall
                            Block(self.bounds.width - 40, 0, 40, self.bounds.height), # right wall
                            Block(0, self.bounds.height - 40, self.bounds.width, 40), # floor
                            Block(200,self.floorCoord-80, 20, 80), # extra bit
                            Spike(350, self.floorCoord, 40), # DEATH SPIKE
                            NinjaStar(350, self.floorCoord - 130) # ninja star 
                            )

        
        
        # render
        self.render_background()

    def render_background(self):
        self.background = Surface(self.bounds.size)
        self.background.fill((80,80,80))
        self.blocks.draw(self.background)
開發者ID:habahut,項目名稱:CS112-Spring2012,代碼行數:31,代碼來源:level.py

示例4: ExplorableScreen

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class ExplorableScreen(GameScreen):

    def __init__(self, config, model):
        super(ExplorableScreen, self).__init__(config, model)

    def setup(self):
        super(ExplorableScreen, self).setup()
        pastel_flowers = Image(os.path.join("sample_sprites", "tiles", "png", "pastel_flowers.png"))
        grass = Image(os.path.join("sample_sprites", "tiles", "png", "grass.png"))
        images = (pastel_flowers, grass)

        # XXX Just a demo, do not try this at home: this (rightly!) assumes that
        # pastel_flowers and grass have the same dimensions
        visible_width = int(self.screen_dimensions[GameConfig.WIDTH_INDEX] / pastel_flowers.width)
        visible_height = int(self.screen_dimensions[GameConfig.HEIGHT_INDEX] / pastel_flowers.height)
        area_tile_size = (visible_width + 2) * (visible_height + 2)
        self.tiles = Group()
        
        for i in range(area_tile_size):
            img = random.choice(images)
            img_xpos = img.width * (i % visible_width)
            img_ypos = img.height * (i % visible_height)

            self.tiles.add(PyRoSprite(img.clone((img_xpos, img_ypos))))

    def draw_screen(self, window):
        self.tiles.draw(window)
        self.tiles.update()
開發者ID:skytreader,項目名稱:PyGame-Objects,代碼行數:30,代碼來源:explorable.py

示例5: Scoreboard

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Scoreboard():
    def __init__(self, ai_setting, screen, stats):
        self.screen = screen
        self.screen_rect = screen.get_rect()
        self.ai_setting = ai_setting
        self.stats = stats

        self.text_color = (30, 30, 30)
        self.font = pygame.font.SysFont(None, 48)

        self.prep_score()
        self.prep_high_score()
        self.prep_level()
        self.prep_ships()

    def prep_score(self):
        # -1 means multi 10
        rounded_score = int(round(self.stats.score, -1))
        score_str = "{:,}".format(rounded_score)

        self.score_image = self.font.render(score_str, True, self.text_color, self.ai_setting.bg_color)

        self.score_rect = self.score_image.get_rect()
        self.score_rect.right = self.screen_rect.right - 20
        self.score_rect.top = 20

    def prep_high_score(self):
        high_score = int(round(self.stats.high_score, -1))
        high_score_str = "{:,}".format(high_score)
        self.high_score_image = self.font.render(high_score_str, True, self.text_color, self.ai_setting.bg_color)

        self.high_score_rect = self.high_score_image.get_rect()
        self.high_score_rect.centerx = self.screen_rect.centerx
        self.high_score_rect.top = self.score_rect.top

    def prep_level(self):
        self.level_image = self.font.render(str(self.stats.level), True, self.text_color, self.ai_setting.bg_color)
        self.level_rect = self.level_image.get_rect()
        self.level_rect.right = self.score_rect.right
        self.level_rect.top = self.score_rect.bottom + 10

    def prep_ships(self):
        self.ships = Group()
        for ship_number in range(self.stats.ships_left):
            ship = Ship(self.ai_setting, self.screen)
            ship.rect.x = 10 + ship_number * ship.rect.width
            ship.rect.y = 10
            self.ships.add(ship)

    def show_score(self):
        self.screen.blit(self.score_image, self.score_rect)
        self.screen.blit(self.high_score_image, self.high_score_rect)
        self.screen.blit(self.level_image, self.level_rect)

        # draw ships
        self.ships.draw(self.screen)
開發者ID:shucommon,項目名稱:little-routine,代碼行數:58,代碼來源:scoreboard.py

示例6: CollectCoinMicrogame

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class CollectCoinMicrogame(Microgame):
    def __init__(self):
        # TODO: Initialization code here
        Microgame.__init__(self)
        self.coins = coin(0) #coin(locals.HEIGHT + 70)]
        self.ironman = ironman()
        self.sprites = Group(self.ironman, self.coins)
        self.time = pygame.time.get_ticks()

    def start(self):
        # TODO: Startup code here
        music.load(os.path.join("games", "catching", "super_mario_levels.wav"))
        music.play()

    def stop(self):
        # TODO: Clean-up code here
        music.stop()
        self.lose()

    def update(self, events):
        # TODO: Update code here
        self.sprites.update()
        ctrls = pygame.key.get_pressed()
        if ctrls[K_q]:
            self.win()
        elif ctrls[K_a] or ctrls[K_LEFT]:
            self.ironman.rect.x = max(self.ironman.rect.x - 30, 0)
        elif ctrls[K_d] or ctrls[K_RIGHT]:
            self.ironman.rect.x = min(locals.WIDTH - 68, self.ironman.rect.x + 30)
        if self.coins.rect.colliderect(self.ironman):
            # self.time = pygame.time.get_ticks()
            # self.sprites.remove(self.coins)
            # print str(self.time) + " " + str(pygame.time.get_ticks())
            # if self.time + 3000 <= pygame.time.get_ticks():
            # self.coins = coin(0)
                # self.sprites.add(self.coins)
            self.coins.rect.y = 0
            self.coins.velocity = 0
            self.coins.rect.left = randint(0, locals.WIDTH - COIN_WIDTH)
                # self.sprites.update()
        elif self.coins.rect.top > locals.HEIGHT:
            self.lose()

    def render(self, surface):
        # TODO: Rendering code here
        surface.fill(Color(0, 0, 0))
        imgpath = os.path.join("games", "catching", "8bitsky.jpg")
        test_image = pygame.image.load(imgpath)
        surface.blit(test_image,(0,0))
        self.sprites.draw(surface)

    def get_timelimit(self ):
        # TODO: Return the time limit of this game (in seconds)
        return 15
        
開發者ID:thenathanyang,項目名稱:SAAST_2014,代碼行數:56,代碼來源:game.py

示例7: __init__

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Panel:
	def __init__(self, world_map):
		self.world_map = world_map
		self.group = Group()
		self.energy_bar = EnergyBar(world_map.main_character, 15, 10, self.group)
		self.energy_bar.put(75, 13)
		self.energy_bar = LifeBar(world_map.main_character, 15, 10, self.group)
		self.energy_bar.put(75, 30)
		
		self.rect = Rect(0, 0, SCREEN_W, 40)
		self.background = data.load_image('panel.png')
		font = Font(data.filepath('fonts', 'vera.ttf'), 12)
		#font.set_bold(True)
		self.twister_text = font.render("Twister:", True, (0,0,0))
		self.life_text = font.render("Life:", True, (0,0,0))
		self.world_text = font.render("World: %s" % world_map.name, True, (0,0,0))
		
		class TimeText(Sprite):
			def __init__(self, world_map, *groups):
				Sprite.__init__(self, *groups)
				self.world_map = world_map
			def update(self, *args):
				time = self.world_map.time
				time_str = self.world_map.get_time()
				if time < 60:
					color = (170, 0, 0)
				elif time < 120:
					color = (255, 100, 0)
				else:
					color = (0, 0, 0) 
				self.image = font.render("Time: %s"% time_str , True, color)
				self.rect = self.image.get_rect()
				self.rect.move_ip(500, 0)
				
		TimeText(world_map, self.group)
		self.key = KeyItem(world_map)
		self.key.put(620, 20)
		self.key.remove(self.key.groups())
		
		
	def draw(self, screen):
		if self.world_map.got_key:
			self.key.add(self.group)
		screen.set_clip(self.rect)
		self.group.clear(screen, self.background)
		self.group.update()
		self.group.draw(screen)
		
	def draw_background(self, screen):
		screen.blit(self.background, (0,0))
		screen.blit(self.twister_text, (10, 0))
		screen.blit(self.life_text, (10, 17))
		screen.blit(self.world_text, (500, 17))
開發者ID:ceronman,項目名稱:twsitemall,代碼行數:55,代碼來源:panel.py

示例8: __init__

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Options:
    "Permite conocer y alterar las opciones del juego."

    def __init__(self, world):
        self.world = world
        self.sprites = Group()
        self.background = load_image("options.png", "scenes")
        options = [
                ("Actual mode: window", "Actual mode: fullscreen", 
                    self.on_change_fs, common.options.fullscreen),
                ("Audio: disable", "Audio: enable", 
                    self.on_change_audio, common.audio.enabled),
                ("Sound Volume:", common.options.sound_volume, 
                    self.on_change_sound_volume),
                ("Music Volume:", common.options.music_volume, 
                    self.on_change_music_volume),
                ("Exit", self.on_return_to_main_menu),
                ]
        self.menu = menu.Menu(230, 250, self.sprites, world.font, options)

    def update(self):
        self.menu.update()

    def draw(self, screen):
        screen.blit(self.background, (0, 0))
        self.sprites.draw(screen)
        pygame.display.flip()

    def on_return_to_main_menu(self):
        import scenes
        self.world.change_state(scenes.mainmenu.MainMenu(self.world))

    def on_change_fs(self):
        result = pygame.display.toggle_fullscreen()
        return result

    def on_change_audio(self):
        new_state = not common.audio.enabled
        common.audio.set_enabled(new_state)
        return 1

    def on_change_sound_volume(self):
        common.audio.set_sound_volume(0.5)

    def on_change_music_volume(self):
        common.audio.set_music_volume(0.5)

    def handle_event(self, event):
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                self.on_return_to_main_menu()

        self.menu.update_control(event)
開發者ID:HieuLsw,項目名稱:sbfury,代碼行數:55,代碼來源:options.py

示例9: VerticalToolbar

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class VerticalToolbar(pygame.sprite.Sprite):
  def __init__(self, editor_level, font_manager):
    pygame.sprite.Sprite.__init__(self)

    self.editor_level = editor_level

    self.selected = None
    self.position = Point(constants.HORIZONTAL_TILES, 0)
    self.width = editor_constants.RIGHT_BAR_RATIO
    self.height = constants.VERTICAL_TILES

    self.options = Group()
    self.hotkeys = {}
    top = editor_constants.RIGHT_BAR_ITEM_SPACING
    for (name, data) in editor_constants.ENTITY_DATA:
      option = ToolbarOption(top, name, data, font_manager)
      if self.selected is None:
        self.select(option)
      self.options.add(option)
      top += editor_constants.RIGHT_BAR_ITEM_RATIO + editor_constants.RIGHT_BAR_ITEM_SPACING
      self.hotkeys[data.hotkey] = option

    self.update_graphics()

  def hotkey(self, hotkey):
    if hotkey in self.hotkeys:
      self.select(self.hotkeys[hotkey])

  def select(self, option):
    if self.selected is not None:
      self.selected.toggle_select()
    self.selected = option
    self.selected.toggle_select()

    self.editor_level.entity_to_create = option.name

  def left_click(self, position, pressed):
    for option in self.options:
      rect = pygame.Rect(option.position.scale(constants.TILE_SIZE), (constants.TILE_SIZE * option.size, constants.TILE_SIZE * option.size))
      if rect.collidepoint(position.scale(constants.TILE_SIZE)):
        self.select(option)

  def update_graphics(self):
    width = int(round(self.width * constants.TILE_SIZE))
    height = int(round(self.height * constants.TILE_SIZE))
    self.image = pygame.Surface([width, height])
    self.image.fill(editor_constants.TOOLBAR_COLOR)
    self.rect = self.image.get_rect(topleft=self.position.scale(constants.TILE_SIZE))

  def draw(self, screen):
    self.options.draw(screen)
開發者ID:jasharpe,項目名稱:tanks,代碼行數:53,代碼來源:editor_level.py

示例10: __init__

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Logo:
    "Escena que muestra el logotipo del grupo losersjuegos."

    def __init__(self, world):
        self.world = world
        self.sprites = Group()
        self._create_sprites()
        self._reset_timer()

    def _reset_timer(self):
        self.time_out = 50

    def update(self):
        key = pygame.key.get_pressed()

        if key[pygame.K_ESCAPE]:
            self.world.state = Logo(self.world)
            self._reset_timer()
            return
        else:
            self.sprites.update()

        if self.time_out < 1 or key[pygame.K_RETURN]:
            self.world.change_state(scenes.mainmenu.MainMenu(self.world))

        self.time_out -= 1

    def draw(self, screen):
        screen.fill((92, 123, 94))
        self.sprites.draw(screen)
        pygame.display.flip()

    def _create_sprites(self):
        steps = [0, 0, 0, 1, 2, 3, 4]
        losers = SimpleAnimation('logo', 'losers_5.png', steps, 2)
        sprite_losers = LogoSpriteAnimated(losers, LEFT, 190, 190)

        steps2 = [0, 0, 0, 1, 2, 3, 4]
        juegos = SimpleAnimation('logo', 'juegos_5.png', steps2, 2)
        sprite_juegos = LogoSpriteAnimated(juegos, RIGHT, 390, 190)

        steps3 = [0, 0, 0, 1, 1, 2, 3]
        ceferino = SimpleAnimation('logo', 'ceferino_4.png', steps3, 2)
        sprite_ceferino = LogoSpriteAnimated(ceferino, RIGHT, 40, 160)

        self.sprites.add([sprite_juegos, sprite_losers, sprite_ceferino])

    def handle_event(self, event):
        pass
開發者ID:HieuLsw,項目名稱:sbfury,代碼行數:51,代碼來源:logo.py

示例11: game

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
def game():
    # init
    pygame.init()
    screen = pygame.display.set_mode(SCREEN_SIZE)
    clock = pygame.time.Clock()
    dude = PlayerShip(260, 500, screen.get_rect())
    dude_grp = GroupSingle(dude)
    enemies = Group()
    enemies.add(Burger(200, 200, screen.get_rect()))
    enemies.add(Hotdog(100, 100, screen.get_rect()))

    #loop
    while True:
        # input
        for evt in pygame.event.get():
            if evt.type == QUIT:
                return
            elif evt.type == KEYDOWN and evt.key == K_ESCAPE:
                return
            elif evt.type == KEYDOWN and evt.key == K_a:
                dude.dx = -10
            elif evt.type == KEYDOWN and evt.key == K_d:
                dude.dx = 10
            elif evt.type == KEYUP and evt.key == K_a and dude.dx == -10:
                dude.dx = 0
            elif evt.type == KEYUP and evt.key == K_d and dude.dx == 10:
                dude.dx = 0
            elif evt.type == KEYDOWN and evt.key == K_SPACE and dude.alive():
                dude.shoot()
                
        # update
        clock.tick(FPS)
        dude.update()
        enemies.update()
        dude.bullets.update()

        pygame.sprite.groupcollide(enemies, dude.bullets, 1, 1)
        pygame.sprite.groupcollide(dude_grp, enemies, 1, 0)

        # draw
        screen.fill(BLACK)
        dude_grp.draw(screen)
        enemies.draw(screen)
        dude.bullets.draw(screen)
        pygame.display.flip()
開發者ID:Werefriend,項目名稱:CS112-Spring2012,代碼行數:47,代碼來源:shmup.py

示例12: KoalaKross

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class KoalaKross(Microgame):
    
    
    def __init__(self):
        Microgame.__init__(self)
        self.rect= Rect(0,0, locals.WIDTH, locals.HEIGHT)
##        surface=pygame.display.set_mode((1024,768))
##        surface.fill(Color(0,0,250))
        koala=Koala(self)
        self.panda1=Panda(200,100,0,2)
        self.panda2=Panda(500,100,0,2)
        self.bread=Bread(self)
        self.sprites=Group((koala,self.panda1,self.panda2,self.panda3))
        self.clock=pygame.time.Clock()

    def start():
        pass

    def stop():
        pass 

    def update(self):
        time=pygame.time.get_ticks()
        self.sprites.update()
        for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key==K_DOWN:
                    koala.velocity=(0,-3)
                elif event.key==K_UP:
                    koala.velocity=(3,0)
                elif event.key == K_Right:
                    koala.velocity=(3,0)
                elif event.key == K_Left:
                    koala.velocity=(-3,0)
                elif event.key == K_q:
                    self.lose()
            elif event.type == KEYUP:
                koala.velocity=(0,0)

    def render (self, surface):
##        Surface=display.set_mode((1024,768))
        surface.fill.Color(0,0,0)
        self.sprites.draw(surface)
開發者ID:madhavsekar,項目名稱:Sekar_MITMakerPortfolio,代碼行數:45,代碼來源:firstmicrogame.py

示例13: evade

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class evade(Microgame):
    def __init__(self):
        Microgame.__init__(self)
        self.e_icicles = [e_icicle(0), e_icicle(locals.HEIGHT + 70),e_icicle(locals.HEIGHT+100),e_icicle(locals.HEIGHT+10),e_icicle(100),

        e_icicle(100),e_icicle(700),e_icicle(300),e_icicle(500)]
        self.e_eskimo = eskimo()
        self.sprites = Group(self.e_eskimo, *self.e_icicles)

    def start(self):
        music.load(os.path.join("games", "evadeFull", "alt_song.wav"))
        music.play()

    def stop(self):
        music.stop()
        self.lose()

    def update(self, events):
        self.sprites.update()
        keys = pygame.key.get_pressed()
        if keys[K_q]:
            self.win()
        elif (keys[K_RIGHT] or keys[K_d]) and (keys[K_LEFT] or keys[K_a]):
            pass
        elif keys[K_LEFT] or keys[K_a]:
            self.e_eskimo.rect.x = max(self.e_eskimo.rect.x - 15, 0)
        elif keys[K_RIGHT] or keys[K_d]:
            self.e_eskimo.rect.x = min(locals.WIDTH -57, self.e_eskimo.rect.x + 15)
        for icicle in self.e_icicles:
            if self.e_eskimo.rect.colliderect(icicle.rect):
                music.stop()
                self.lose()

    def render(self, surface):
        surface.fill((0, 0, 0))
        imgpathh = os.path.join("games", "evadeFull", "tile.png")
        test_image = pygame.image.load(imgpathh) 
        surface.blit(test_image,(0,0))
        self.sprites.draw(surface)

    def get_timelimit(self):
        return 15
開發者ID:oneski,項目名稱:SAAST-Summer-Program-Project,代碼行數:44,代碼來源:game.py

示例14: __init__

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class Board:
    def __init__(self, width: int, height: int):
        super().__init__()
        self.width = width
        self.height = height
        self.players = Group()
        self.walls = Group()
        for w in range(width >> 1):
            for h in range(height >> 1):
                wall = Wall()
                wall.rect.x = PPM * (2 * w + 1)
                wall.rect.y = PPM * (2 * h + 1)
                self.walls.add(wall)

    def draw(self, canvas):
        self.walls.draw(canvas)
        self.players.draw(canvas)

    def update(self, dt):
        self.players.update(dt)
開發者ID:asmodeii,項目名稱:Bomberman,代碼行數:22,代碼來源:gamestate.py

示例15: __init__

# 需要導入模塊: from pygame.sprite import Group [as 別名]
# 或者: from pygame.sprite.Group import draw [as 別名]
class MainMenu:
    "Escena del menú principal."

    def __init__(self, world):
        self.world = world
        self.sprites = Group()
        self.background = load_image("mainmenu.png", "scenes")
        options = [
                ("Start a new game", self.on_start_new_game),
                ("Options", self.on_options),
                ("About this game", self.on_about),
                ("Exit", self.on_exit),
                ]
        self.menu = menu.Menu(330, 300, self.sprites, world.font, options)

    def update(self):
        self.menu.update()

    def draw(self, screen):
        screen.blit(self.background, (0, 0))
        self.sprites.draw(screen)
        pygame.display.flip()

    def on_exit(self):
        sys.exit(0)

    def on_start_new_game(self):
        import game
        self.world.change_state(game.Game(self.world))

    def on_about(self):
        from scenes.about import About
        self.world.change_state(About(self.world))

    def on_options(self):
        from scenes.options import Options
        self.world.change_state(Options(self.world))

    def handle_event(self, event):
        self.menu.update_control(event)
開發者ID:HieuLsw,項目名稱:sbfury,代碼行數:42,代碼來源:mainmenu.py


注:本文中的pygame.sprite.Group.draw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。