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


Python Group.copy方法代码示例

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


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

示例1: run_game

# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import copy [as 别名]
def run_game():
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Alien Invasion")
    # make a ship
    ship = Ship(ai_settings, screen)
    bullets = Group()
    aliens = Group()
    alien = Alien(ai_settings, screen)
    gf.create_fleet(ai_settings, screen, aliens)


    while True:
        gf.check_events(ai_settings, screen, ship, bullets)
        ship.update()
        gf.update_bullets(bullets)
        gf.update_screen(ai_settings, screen, ship, aliens, bullets)
        bullets.update()

        # Get rid of bullets that have disappeared.
        for bullet in bullets.copy():
            if bullet.rect.bottom <= 0:
                bullets.remove(bullet)
        print(len(bullets))
开发者ID:painandmemesery,项目名称:alien_invasion,代码行数:27,代码来源:alien+invasion.py

示例2: run_game

# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import copy [as 别名]
def run_game():
    pygame.init()

    ai_settings = Settings()

    """ Screen settings and such"""
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))

    pygame.display.set_caption("Alien Invasion")
    stats = GameStats(ai_settings)

    bg_color = (230, 230, 230)
    """background screen color; grey"""

    ship = Ship(ai_settings, screen)
    bullets = Group()
    aliens = Group()
    gf.create_fleet(ai_settings, screen, ship, aliens)

    while True:
        gf.check_events(ai_settings, screen, ship, bullets)
        ship.update()
        gf.update_bullets(ai_settings, screen, ship, aliens, bullets)
        gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
        gf.update_screen(ai_settings, screen, ship, aliens, bullets)

        for bullet in bullets.copy():
            if bullet.rect.bottom <= 0:
                bullets.remove(bullet)
        print(len(bullets))
开发者ID:MasonWhite000,项目名称:AlienInvasion,代码行数:33,代码来源:Alien_Invasion.py

示例3: run_game

# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import copy [as 别名]
def run_game():

	# Initialize game and create a screen object.

	pygame.init()
	ai_settings = Settings()
	screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
	
	pygame.display.set_caption("Zombie Tower Ultimate Sonic The Next Generation Super EX")
	play_button = Button(ai_settings, screen, "Play")
	# Set the background color
	ship = Ship(screen, ai_settings)
	bullets = Group()
	bomb = Group()
	lasercheat = Group()
	nuke = Nuke(ai_settings, screen, ship)
	block = Block(ai_settings, screen, nuke)
	wall = Wall(ai_settings, screen, ship)
	lift = Lift(ai_settings, screen, nuke)
	aliens = Group()
	alien = Alien(ai_settings, screen)
	# Start the main loop for the game.
	stats = GameStats(ai_settings, bomb, aliens, bullets)
	sb = Scoreboard(ai_settings, screen, stats)
	gf.create_fleet(ai_settings, screen, ship, aliens)

	while True:

		# Watch for keyboard and mouse events.
		gf.check_events(ai_settings, screen, stats, ship, bullets, lasercheat, aliens, nuke, play_button, bomb, wall, lift)
		if stats.game_active:
			ship.update()
			gf.update_aliens(ai_settings, stats, screen, ship, aliens, bomb, wall)
			ai_settings.counterpnts -= 1
			if ai_settings.counterpnts <=0:
				ai_settings.counterpnts = 60
				stats.score += 1
				sb.prep_score()
			bullets.update()
			bomb.update(aliens, ai_settings, screen)
		gf.update_screen(ai_settings, screen, stats, sb, ship, bullets, lasercheat, aliens, nuke, play_button, wall, bomb, lift, block)
		# Get rid of bullets that have disappeared.

		for bullet in bullets.copy():
			if bullet.rect.right >= 1200:
				bullets.remove(bullet)
		print(len(bullets))
开发者ID:InspectionXpert-Interns,项目名称:Brett,代码行数:49,代码来源:alien_invades.py

示例4: WvmSpritesList

# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import copy [as 别名]
class WvmSpritesList():
    """A class listing all the Sprites of the game."""

    def __init__(self, config, screen):
        """Initialize the sprite list."""
        self.config = config
        self.screen = screen

        #initialize the sprites
        self.wiz = Wizard(config, self)
        self.monsters = Group()
        self.missiles = Group()

    def update_all(self):
        """Update the positions of all sprites."""
        self.update_missiles()
        self.wiz.update()
        self.monsters.update()

    def update_missiles(self):
        """update magic missiles positions"""
        self.missiles.update()
        # remove the missiles that have left the screen
        for mi in self.missiles.copy():
            if mi.rect.left >= self.screen.get_rect().right:
                self.missiles.remove(mi)

    def draw(self):
        self.screen.fill(self.config.bg_color)
        for mi in self.missiles:
            mi.draw_missile()
        self.wiz.blitme()
        for mo in self.monsters:
            mo.blitme()

    def fire_missile(self):
        """Fire a missile if limit not reached yet."""
        if len(self.missiles) < self.wiz.magic_missile_allowed:
            self.missiles.add(MagicMissile(self.config, self))

    def create_monster(self):
        """Create a new monster and place it randomly at the right."""
        monster=Monster(self.config, self)
        #TODO move the monster
        self.monsters.add(monster)
开发者ID:BenObiWan,项目名称:wizard_vs_monster,代码行数:47,代码来源:wvm_sprites_list.py

示例5: run_game

# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import copy [as 别名]
def run_game():
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Alien Invasion")
    ship = Ship(ai_settings, screen)
    bullets = Group()
    while True:
        gf.check_events(ai_settings, screen, ship, bullets)
        ship.update()
        bullets.update()
        gf.update_screen(ai_settings, screen, ship, bullets)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
        screen.fill(ai_settings.bg_color)
        ship.blitme()
        pygame.display.flip()
        bullets.update()
        for bullet in bullets.copy():
            if bullet.rect.bottom <= 0:
                bullets.remove(bullet)
        print(len(bullets))
开发者ID:MarvelousJudson12,项目名称:alienInvasion,代码行数:25,代码来源:alien_invasion.py


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