def rand_entities():
    empty_map = gen_map.gen_empty_entities(Game.map_size)
    for x in range(Game.map_size):
        for y in range(Game.map_size):
            if x % 2 and y % 2 and x != 0 and y != 0 and y != Game.map_size-1 and x != Game.map_size -1:
                empty_map[x][y].append(random.choice(en)(x, y))
    return empty_map
Exemple #2
0
 def setUp(self):
     s_mock = SerializerMock()
     self.w = World(s_mock, block_seed=0)
     # Cartesian product
     locs = itertools.product([1,0,-1], [1,0,-1])
     flat_map = gen_flat_map(Game.map_size)
     for loc in locs:
         self.w.blocks[loc] = Block(*loc, world=self.w,
                                   tiles=gen_flat_map(Game.map_size),
                                   entities=gen_map.gen_empty_entities(Game.map_size))
def test_set_tile_open(benchmark):
    game = Game()
    w = World(None)
    locs = itertools.product([1,0,-1], [1,0,-1])
    flat_map = gen_flat_map(Game.map_size)
    for loc in locs:
        w.blocks[loc] = Block(*loc, world=w,
                                  tiles=gen_flat_map(Game.map_size),
                                  entities=gen_map.gen_empty_entities(Game.map_size))
    blk = w[(0,0)]
    benchmark.pedantic(blk.set_tile, args=(Game.game_width//2, Game.game_height//2, Id.wall), rounds=1)