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


Python arena.Arena类代码示例

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


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

示例1: test_add_player

    def test_add_player(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        player = Player((0, 0), arena)
        arena.add_player(player)

        self.assertEqual(len(arena.players), 1)
开发者ID:minh0722,项目名称:Bomberman,代码行数:7,代码来源:test.py

示例2: HelloWorld

class HelloWorld(cocos.layer.Layer):
    is_event_handler = True

    def __init__(self):
        super(HelloWorld, self).__init__()
        self.arena = Arena()
        self.add(self.arena)
        self.score = cocos.text.Label('30',
                                      font_name='Times New Roman',
                                      font_size=24,
                                      color=define.GOLD)
        self.score.position = 20, 440
        self.add(self.score, 99999)

        self.gameover = Gameover()
        self.add(self.gameover, 100000)

    def update_score(self):
        self.score.element.text = str(self.arena.snake.score)

    def end_game(self):
        self.gameover.visible = True
        self.gameover.score.element.text = str(self.arena.snake.score)

    def on_mouse_press(self, x, y, buttons, modifiers):
        if self.gameover.visible:
            self.gameover.visible = False
            self.arena.unschedule(self.arena.update)
            self.remove(self.arena)
            self.arena = Arena()
            self.add(self.arena)
            self.update_score()
开发者ID:forswj,项目名称:practise-python,代码行数:32,代码来源:gluttonous.py

示例3: test_down_tiles_can_be_exploded

    def test_down_tiles_can_be_exploded(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        arena.arena_matrix = self.get_default_arena()

        self.assertEqual(
            arena.down_tiles_can_be_exploded((1, 1)), ARENA_HEIGHT - 3)
开发者ID:minh0722,项目名称:Bomberman,代码行数:7,代码来源:test.py

示例4: __init__

 def __init__(self, arena: Arena, x: int, y: int):
     self._x, self._y = x, y
     self._arena = arena
     arena.add_character(self)
     self._turn = 0
     self._dx = 2 * (y % 2) - 1  # -1 if y is even, +1 if odd
     self._size = Boat.DEF_SIZE
开发者ID:Pio1962,项目名称:fondinfo,代码行数:7,代码来源:frogger.py

示例5: test_get_non_destructible_walls

    def test_get_non_destructible_walls(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        non_destructible_walls = arena.non_destructible_walls

        self.assertEqual(
            arena.get_non_destructible_walls(), non_destructible_walls)
开发者ID:minh0722,项目名称:Bomberman,代码行数:7,代码来源:test.py

示例6: test_can_place_bomb

    def test_can_place_bomb(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        arena.arena_matrix = self.get_default_arena()

        self.assertEqual(arena._can_place_bomb(1, 1), True)
        self.assertEqual(arena._can_place_bomb(2, 2), False)
        self.assertEqual(arena._can_place_bomb(5, 1), True)
开发者ID:minh0722,项目名称:Bomberman,代码行数:8,代码来源:test.py

示例7: test_snapshot_with_dude

 def test_snapshot_with_dude(self):
     pc = Pc()
     arena = Arena(1, 1)
     arena.get_location(Point(0, 0)).additem(pc)
     snapshot = Snapshot(WorldSnapshot(arena), pc.id, [])
     stringed = snapshot_to_string(snapshot)
     expected = "###\n#\u263A#\n###\nHP: 100, Strength: 10"
     self.assertEqual(expected, stringed)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:8,代码来源:test_snapshotToString.py

示例8: test_update_matrix_explosion_up

    def test_update_matrix_explosion_up(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        arena.arena_matrix = self.get_default_arena()
        bomb = Bomb((112, 90), 2, arena)

        arena._update_matrix_explosion_up(bomb, TileType.FLAME)

        self.assertEqual(arena.arena_matrix[1][3], TileType.FLAME)
开发者ID:minh0722,项目名称:Bomberman,代码行数:9,代码来源:test.py

示例9: test_snapshot_with_cat

 def test_snapshot_with_cat(self):
     arena = Arena(1, 1)
     location = arena.get_location(Point(0, 0))
     cat = Cat()
     location.additem(cat)
     snapshot = Snapshot(WorldSnapshot(arena), cat.id, [])
     stringed = snapshot_to_string(snapshot)
     expected = "###\n#x#\n###\nHP: 10, Strength: 2"
     self.assertEqual(expected, stringed)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:9,代码来源:test_snapshotToString.py

示例10: test_snapshot_with_log

 def test_snapshot_with_log(self):
     arena = Arena(1, 1)
     location = arena.get_location(Point(0, 0))
     cat = Cat()
     location.additem(cat)
     log = ["loglog", "log2"]
     snapshot = Snapshot(WorldSnapshot(arena), cat.id, log)
     stringed = snapshot_to_string(snapshot)
     expected = "###\n#x#\n###\n" + "\n".join(log) + "\nHP: 10, Strength: 2"
     self.assertEqual(expected, stringed)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:10,代码来源:test_snapshotToString.py

示例11: test_update_explosion_in_matrix

    def test_update_explosion_in_matrix(self):
        game_display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        arena = Arena()
        arena.arena_matrix = self.get_default_arena()
        bomb = Bomb((22, 0), 2, arena)
        bomb.state = BombState.EXPLODING

        arena.update_explosion_in_matrix(bomb)
        matrix = arena.get_arena()

        self.assertEqual(matrix[1][1], TileType.FLAME)
开发者ID:minh0722,项目名称:Bomberman,代码行数:11,代码来源:test.py

示例12: ArenaTests

class ArenaTests(unittest.TestCase):

    def setUp(self):
        self._arena = Arena(8, 8)

    def testCorner0(self):
        p = self._arena.corner_location(0)
        util.assertEqual(Point(0,0), p)

    def testCorner1(self):
        p = self._arena.corner_location(1)
        util.assertEqual(Point(0,8), p)

    def testCorner2(self):
        p = self._arena.corner_location(2)
        util.assertEqual(Point(8,8), p)

    def testCorner3(self):
        p = self._arena.corner_location(3)
        util.assertEqual(Point(8,0), p)


    def test_limits_origin(self):
        p = Point(0,0)
        valid = self._arena.position_valid(p)
        util.assertTrue(valid)

    def test_limits_max(self):
        p = Point(8, 8)
        valid = self._arena.position_valid(p)
        util.assertTrue(valid)

    def test_limits_neg(self):
        p = Point(8, -8)
        valid = self._arena.position_valid(p)
        util.assertFalse(valid)

    def test_limits_pos(self):
        p = Point(8, 16)
        valid = self._arena.position_valid(p)
        util.assertFalse(valid)

    def test_limits_neg2(self):
        p = Point(-8, 0)
        valid = self._arena.position_valid(p)
        util.assertFalse(valid)

    def test_limits_pos2(self):
        p = Point(16, 0)
        valid = self._arena.position_valid(p)
        util.assertFalse(valid)
开发者ID:PeterJCLaw,项目名称:game-modeller,代码行数:51,代码来源:arenatests.py

示例13: __init__

    def __init__(self, file1=None, file2=None):
        pygame.mixer.pre_init(44100, -16, 2, 2048)
        pygame.init()
        self.fps = pygame.time.Clock()
        flag = DOUBLEBUF

        self.board = pygame.display.set_mode(screenRect, flag)
        pygame.display.set_caption('[ --- Pong --- ]')

        self.state = 1  # 1 - run, 0 - exit

        self.track = Tracking(file1, file2)

        self.sound = Sound()
        self.p1 = Paddle(self.board, (200,100,100),screenRect)
        self.p1.setInitialPostition(0,screenHeight/2)
        self.p2 = Paddle(self.board, (100,200,100),screenRect)
        self.p2.setInitialPostition(screenWidth-self.p2.get()['width'],screenHeight/2)
        self.ball = Ball(self.board, (50,50,250), screenRect, self.sound)
        self.ball.setInitialPostition(screenWidth/2,screenHeight/2)
        self.arena = Arena(self.board, screenRect)
        self.referee = Referee(self.ball, self.p1, self.p2, screenRect, self.sound)

        

        self.t = Thread(target=self.track.run)
        #self.track.run()
        self.t.start()

        self.p1_pos = 0
        self.p2_pos = 0

        self.loop()
开发者ID:piotut,项目名称:Pong,代码行数:33,代码来源:pong.py

示例14: Model

class Model(object):
    """
    Asteroids float in space
    """
    def __init__(self, width, height, n_asteroids, min_mass=800, max_mass=1000):
        self.min_mass = min_mass
        self.max_mass = max_mass
        self.schedule = Schedule('move', 'random', 'collision_check', 'collision_response')
        Asteroid.activate(self.schedule)
        Ship.activate(self.schedule)
        Bullet.activate(self.schedule)
        CollisionChecker.activate(self.schedule)
        self._tick = 0
        self.logger = logging.getLogger("Model")
        self.arena = Arena(width, height)
        for i in range(n_asteroids):
            self.add_asteroid()
        centre = [self.arena.width / 2, self.arena.height / 2]
        self.ship = Ship(centre, 1500, 150, 1500, self.arena)

    def add_asteroid(self):
        position = (random() * self.arena.width, random() * self.arena.height)
        mass = random() * (self.max_mass - self.min_mass) + self.min_mass
        velocity = [0, 0]
        density = MAX_DENSITY * 0.1 + random() * MAX_DENSITY * 0.9
        a = Asteroid(position, mass, velocity, density, self.arena)
        a.apply_force(10000 * (random() - 0.5), 10000 * (random() - 0.5))

    def tick(self):
        self._tick += 1
        self.schedule.execute(self.arena.agents())
开发者ID:ggstuart,项目名称:pyasteroids,代码行数:31,代码来源:model.py

示例15: __init__

 def __init__(self):
     """ Constructeur """
     # Arena de largeur 5 et de hauteur 2. L'initialisation du contenu de l'Arena
     # (ses Components) est directement effectuée dans l'init de la classe Arena.
     # TRODO : d'ailleurs c'est mal. Mais provisoire.
     self.arena = Arena((5, 2))
     self.arenaDisplayer = ArenaDisplayer(self.arena)
开发者ID:darkrecher,项目名称:GMarble,代码行数:7,代码来源:ctrlaren.py


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