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


Python Level.load_level方法代码示例

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


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

示例1: __init__

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import load_level [as 别名]
    def __init__(self, level):
        super(Game, self).__init__()
        self.level = Level.load_level(level)
        self.background = Sprite(source='img/background.PNG')
        self.size = self.background.size
        self.player = None
        self.boxes = []

        # Initiate the game by creating tiles
        Tile.make_tiles(self.size, self.level)

        # Add bg widget first to not cover other sprites
        self.add_widget(self.background)

        # Add proper widgets for every non-empty tile in the Tile.List
        for tile in Tile.List:
            if tile.type != 'empty':
                if Tile.get_tile(tile.number - Tile.V).walkable:
                    self.add_widget(Sprite(
                        source=Tile.image_files[tile.type],
                        pos=(tile.x, tile.y)), index=2)
                else:
                    self.add_widget(Sprite(
                        source=Tile.image_files[tile.type + '_edge'],
                        pos=(tile.x, tile.y - SPRITE_EDGE_OFFSET)))

        for tile in self.level.boxspawn:
            self.boxes.append(Box(tile, self))

        self.player = Player(self.level.playerspawn, self)

        self.fps_lab = Label(
            text='FPS: ' + str(Clock.get_rfps()),
            pos=(2, self.height - 110),
            font_name=APP_FONT,
            font_size=18,
            color=(240, 240, 240, 0.8))

        self.add_widget(self.fps_lab)

        self.add_widget(Label(
            text="Level {}".format(self.level.level),
            pos=(0, self.height - 80),
            font_name=APP_FONT,
            font_size=18,
            color=(240, 240, 240, 0.8)))

        # Schedule an interval for the game update function
        Clock.schedule_interval(self.update, 1.0/60.0)
开发者ID:Catagen,项目名称:boxo,代码行数:51,代码来源:main.py

示例2: load_music

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import load_level [as 别名]
                if pig.life <= 0:
                    pigs_to_remove.append(pig)
    for pig in pigs_to_remove:
        space.remove(pig.shape, pig.shape.body)
        pigs.remove(pig)


# bird and pigs
space.add_collision_handler(0, 1, post_solve=post_solve_bird_pig)
# bird and wood
space.add_collision_handler(0, 2, post_solve=post_solve_bird_wood)
# pig and wood
space.add_collision_handler(1, 2, post_solve=post_solve_pig_wood)
load_music()
level = Level(pigs, columns, beams, space)
level.load_level()

while running:
    # Input handling
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            running = False
        elif event.type == pygame.KEYDOWN and event.key == pygame.K_w:
            # Toggle wall
            if wall:
                space.remove(static_lines1)
                wall = False
            else:
                space.add(static_lines1)
开发者ID:Chuncbs,项目名称:angrybirds,代码行数:33,代码来源:zz_deprecated_main.py

示例3: Player

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import load_level [as 别名]
# Initialize PyGame
pygame.init()

# Initialize constants
from constants import Constants as C
C.init_constants()

# Setup the screen
SCREEN = pygame.display.set_mode((C.SCREEN_WIDTH,C.SCREEN_HEIGHT))

# Load resources
resourceLoader.load_resources()

# Load level
Level.load_level("tatooine_1.json")

# Create background
BackgroundSprite(resourceLoader.get_image("backgrounds\\tatooine.png"))

# Create player
player = Player()
player.set_position(300, 0)

# Create camera
camera = Camera((0, 0), (Level.level_width*C.TILE_SIZE - C.SCREEN_WIDTH, Level.level_height*C.TILE_SIZE))

# Test Animation-----------------------------------------------
# anim = Animation()
# anim.frames = resourceLoader.get_image("characters\\stormTrooper.png")[1:5]
# anim.speed = 0.15
开发者ID:KarlMoellerDev,项目名称:StarWarsPlatformer,代码行数:32,代码来源:main.py

示例4: getMaxScore

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import load_level [as 别名]
class AngryBirdsGame:
    show = False

    def getMaxScore(self):
        max_score = 10000*len(self.level.pigs) + 10000*len(self.level.number_of_birds-1) + 5000*(len(self.level.beams) + len(self.level.columns))
        return max_score

    def getScore(self):
        return self.score

    def getNumberRemainingBirds(self):
        return self.level.number_of_birds + len(self.birds)

    def getBirds(self):
        # Returns a list of Bird objects
        return self.birds

    def getBirdPositions(self):
        return [bird.getPosition() for bird in self.getBirds()]

    def getBirdRadii(self):
        return [bird.getRadius() for bird in self.getBirds()]

    def getBirdPositionsAndRadius(self):
        return [(bird.getPosition(), bird.getRadius()) for bird in self.getBirds()]

    def getPigs(self):
        # Returns a list of Pig objects
        return self.level.pigs

    def getPigPositions(self): # TODO note (LR): this is currently inconsistent to other getters, but useful...
        return [(pig.getPosition()[0], pig.getPosition()[1]) for pig in self.getPigs()]

    def getPigRadii(self):
        return [pig.getRadius() for pig in self.getPigs()]

    def getPigPositionsAndRadius(self):
        return [(pig.getPosition(), pig.getRadius()) for pig in self.getPigs()]

    def getPolys(self):
        #Some useful methods: poly.shape
        return self.beams + self.columns

    def getPolyFeatures(self):
        return [(poly.getPosition(), poly.getVertices(), poly.getRadius()) for poly in self.getPolys()]

    def getLines(self):
        return self.static_lines1

    def getScore(self):
        return self.score

    def runFrames(self,nFrames,show=False):
        #Runs the Angry Birds Emulator for nFrames number of frames
        self.show=show
        for _ in range(nFrames):
            self.run()

    def runUntilStatic(self, show=False):
        """
        Runs the game (i.e. n frames) until it has become static again. Useful to wait for the successor state of an action
        """
        self.show=show
        while (not self.isStatic() and not self.game_state==4):
            self.run()


    def isStatic(self):
        """
        Checks that every bird, polygon and pig are static.

        """
         # TODO - polys and pigs may have velocity zero but because of breaking point. This is unlikely but would like to check.

        if len(self.getBirds())>0:
            return False
        for pig in self.getPigs():
            if pig.getVelocity()>8:
                return False
        for poly in self.getPolys():
            if poly.getVelocity()>8:
                return False
        return True

    def humanPlay(self):
        #Allows a human player to play the game
        self.show = True
        self.humanPlaying = True
        while self.running:
            self.run()

    def restartGame(self):
        self.restart()
        self.level.load_level()
        self.game_state = 0
        self.bird_path = []
        self.score = 0

    def performAction(self,angle,distance):
        # Given an angle and some distance, performs the given action on the game.
#.........这里部分代码省略.........
开发者ID:Chuncbs,项目名称:angrybirds,代码行数:103,代码来源:AngryBirds.py


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