def setFutureTile(self):

        # princess move inside of the box, just east and west
        # set the new tile target, where she is going to
        if self.direction == 'e':

            future_tile_number = self.get_number() + Tile.H

            if future_tile_number in range(1, Tile.total_tiles + 1):
            
                future_tile = Tile.get_tile(future_tile_number)
                if future_tile.walkable: # if player can move for that direction(future tile), we set the target with that tile
                                         # and the method will take cara of how to move the player smothly - on object-classes.py
                    self.set_target(future_tile)
                    self.rotate('e')

                else:
                    self.direction = 'w'
                    #print('w')

        elif self.direction == 'w':

            future_tile_number = self.get_number() - Tile.H
            #print('Position ',self.get_number())

            if future_tile_number in range(1, Tile.total_tiles + 1):
                
                future_tile = Tile.get_tile(future_tile_number)
                if future_tile.walkable: 
                    self.set_target(future_tile)
                    self.rotate('w')

                    #print(future_tile_number)
                elif future_tile_number <= 32*15:
                    self.direction = 'e'
Beispiel #2
0
    async def discard_tile(self):
        dm = self.disc.dm_channel
        hand_picture = player_image(self, False, False)
        hand = discord.File(hand_picture, filename="hand.png")
        if not dm:
            dm = await self.disc.create_dm()
        await dm.send('your hand', file=hand)

        discard = Tile('8', 'z')

        query = "What tile do you want to discard?\n" + str(self.hand)

        while discard not in self.hand.tiles:
            try:
                discard = await self.user_input(query)
                discard = Tile(discard[0], discard[1])
            except asyncio.exceptions.TimeoutError:
                discard = random.choice(self.hand.tiles)
            except ValueError:
                discard = Tile('8', 'z')
            except IndexError:
                discard = Tile('8', 'z')
            query = "Invalid discard, please try again."

        self.temp_furiten = False

        self.hand.remove_tiles(discard)

        hand_picture = player_image(self, True, True, str(discard))

        return discard, hand_picture
Beispiel #3
0
    async def riichi(self, draw, game):

        #this *should* check the hand to make sure its closed
        opened = [meld for meld in self.melds.melds if meld.opened]

        if opened:
            return False

        #determine what tiles are discardable to be in tenpai

        shanten = shanten_calculator(str(self.hand) + str(draw))
        if (shanten == 0 or shanten
                == -1) and self.points >= 1000 and not self.in_riichi:
            riichi_tiles = []
            temp_hand = Tiles()
            temp_hand.tiles = self.hand.tiles[:]
            temp_hand.add_tiles(draw)
            for tile in temp_hand.tiles:
                temp = Tiles()
                temp.tiles = temp_hand.tiles[:]
                temp.remove_tiles(tile)
                if winning_tiles(str(temp)) and tile not in riichi_tiles:
                    riichi_tiles.append(tile)

            if riichi_tiles:
                try:
                    reach = await self.user_input('Would you like to riichi?')
                except asyncio.exceptions.TimeoutError:
                    reach = 'n'
                if reach != 'y' and reach != 'yes':
                    return False
            else:
                return False

            discard = Tile('8', 'z')
            while discard not in self.hand.tiles and discard != draw:
                try:
                    query = "Which tile would you like to riichi on? Type cancel to cancel riichi.\n" + ' '.join(
                        map(str, riichi_tiles))
                    discard = await self.user_input(query)
                    discard = Tile(discard[0], discard[1])
                except asyncio.exceptions.TimeoutError:
                    return False
                except ValueError:
                    discard = Tile('8', 'z')
                except IndexError:
                    discard = Tile('8', 'z')

            #self.discard_tile(choice)
            if game.tenhou and game.wall.remaining > 65:
                self.double_riichi = True
            self.in_riichi = True
            self.ippatsu = True
            self.points -= 1000
            game.riichi += 1
            return discard
        else:
            return False
        '''
Beispiel #4
0
    def resetMaze(self):

        Maze.timeExecuted = 1
        widthMaze = 0
        Maze.heightMaze = 0
        Maze.yPos = 0
        Maze.xPos = 0
        Maze.size_maze = 0
        Maze.tilesMaze.clear()
        Tile.reset()
    def test_end_of_path(self):
        paths = [('s1', 'e2'), ('s2', 'w1'), ('e1', 'n2'), ('n1', 'w2')]
        tile = Tile(paths)

        self.assertAlmostEqual(tile.end_of_path('s1'), 'e2')
        self.assertAlmostEqual(tile.end_of_path('e2'), 's1')

        hand_tile = HandTile(paths)
        self.assertAlmostEqual(hand_tile.end_of_path('e1'), 'n2')
        self.assertAlmostEqual(hand_tile.end_of_path('n2'), 'e1')
Beispiel #6
0
def construct_tile(tile_dict):
    '''
	:param tile_dict: dict containing tile obj
	:return: constructed tile obj
	'''
    tile = Tile(tile_dict['idx'], None)
    if not tile_dict['position'] == None:
        tile.position = (tile_dict['position'][0], tile_dict['position'][1])
    tile.list_of_path = tile_dict['list_of_path']

    return tile
    def spawn(total_frames, FPS):

        if total_frames % (FPS * FruitsBonus.bonusTimeGeneration) == 0 and total_frames >0: 

            # have to put the music

            randTile = randint(1,601) # get a randow number tile, we have 600 tiles in the screen

            while(not Tile.isTileFree(randTile)):  # check if actually, that tile is free, or other words, it's an empty path
                randTile = randint(1,601) # get a randow number tile, we have 600 tiles in the screen

            tile = Tile.get_tile(randTile) # get the tile, randTile is just the tile number
            FruitsBonus(tile.x, tile.y)  # have to get the x and y from the tile number now
Beispiel #8
0
 def setup(self):
     """STEP 2: Sets up the two dimentional list of tiles"""
     print("Generating tiles...")
     # List of calculated spaces and the rooms
     self.spacelist = []
     self.roomlist = []
     self.corridorlist = []
     self.wall_image = pg.image.load("images/wall2.png").convert_alpha()
     self.wall_image = pg.transform.scale(self.wall_image, (TILESIZE, TILESIZE))
     self.floor_image = pg.image.load("images/floor2.png").convert_alpha()
     self.floor_image = pg.transform.scale(self.floor_image, (TILESIZE, TILESIZE))
     self.hordoor = pg.image.load("images/hor_door.png").convert_alpha()
     self.hordoor = pg.transform.scale(self.hordoor, (TILESIZE, TILESIZE))
     self.vertdoor = pg.image.load("images/vert_door.png").convert_alpha()
     self.vertdoor = pg.transform.scale(self.vertdoor, (TILESIZE, TILESIZE))
     self.rockimage = pg.image.load("images/rock.png").convert_alpha()
     self.rockimage = pg.transform.scale(self.rockimage, (TILESIZE, TILESIZE))
     self.enterimage = pg.image.load("images/enter.png").convert_alpha()
     self.enterimage = pg.transform.scale(self.enterimage, (TILESIZE, TILESIZE))
     self.exitimage = pg.image.load("images/exit.png").convert_alpha()
     self.exitimage = pg.transform.scale(self.exitimage, (TILESIZE, TILESIZE))
     self.playerimage = pg.image.load("images/alfa.png").convert_alpha()
     self.playerimage = pg.transform.scale(self.playerimage, (TILESIZE, TILESIZE))
     self.map = [[Tile(w*TILESIZE, h*TILESIZE, 0, self.rockimage, self.wall_image, self.floor_image, self.vertdoor, self.hordoor, self.enterimage, self.exitimage, self.playerimage) for h in range(self.height_tiles)] for w in range(self.width_tiles)]
     self.playerx = 0
     self.playery = 0
     self.new_level_x = 0
     self.new_level_y = 0
     print("Done")
Beispiel #9
0
    def construct_bag(self):
        """ adds tile objects to bag object """
        testing = self._are_we_testing()

        alphabet = self.config['test']['bag']['word'].lower() if testing \
            else self.config['bag']['letters'].keys()

        for letter in alphabet:
            bag_amount = self.config['test']['bag']['letters'][letter]['bag_amount'] if testing \
                else self.config['bag']['letters'][letter]['bag_amount']
            point_val = self.config['test']['bag']['letters'][letter]['point_val'] if testing \
                else self.config['bag']['letters'][letter]['point_val']
            count = 0

            while count < bag_amount:
                tile = Tile(letter=letter.upper(),
                            point_val=point_val,
                            id=count + 1,
                            bag_amount=bag_amount)
                self.contents.append(tile)
                count += 1

        # check tile amount
        tile_count = len(self.contents)
        if tile_count < 100 and not testing:
            raise ValueError(
                "Letter bag only contains {} tiles.  Must contain a total of 100."
                .format(tile_count))

        return None
    def spawn(total_frames, FPS):

        if total_frames % (FPS * LifeBonus.bonusTimeGeneration) == 0 and total_frames >0: 

            luckBonus = randint(1,4) # in other words, player has 33.33% of gain a heart life, each 30 seconds

            if luckBonus == 1:  # new heart will show up if the rand luck bonus is 1
                # have to put the music

                randTile = randint(1,601) # get a randow number tile, we have 600 tiles in the screen

                while(not Tile.isTileFree(randTile)):  # check if actually, that tile is free, or other words, it's an empty path
                    randTile = randint(1,601) # get a randow number tile, we have 600 tiles in the screen

                tile = Tile.get_tile(randTile) # get the tile, randTile is just the tile number
                LifeBonus(tile.x, tile.y)  # have to get the x and y from the tile number now
Beispiel #11
0
 def load(self, filename, world):
     for y, line in enumerate(open(filename, 'r')):
         for x, column in enumerate(line):
             if column not in TileType.__dict__:
                 continue
             t = Tile(getattr(TileType, column), world, x=x, y=y)
             self.tiles[(x, y)] = t
Beispiel #12
0
    def spawn():
        for tile_num in Zombie.zombies:
            if tile_num not in Tile.invalidsSideWalls and tile_num not in Tile.invalidsCenterWalls:

                spawn_node = Tile.get_tile(
                    tile_num)  # get the tile that represents that tile
                Zombie(spawn_node.x, spawn_node.y)
    def __init__(self, columns=COLUMNS, rows=ROWS, demo=False,
                 fadeColor=(100, 100, 100)):
        self.tileBatch = pyglet.graphics.Batch()
        self.tokenBatch = pyglet.graphics.Batch()

        self.tiles = []
        self.tokens = []
        self.people = []

        self.playerBoxes = []

        self.dragTile = False

        self.moving = False
        self.movingTiles = []

        self.columns = columns
        self.rows = rows

        self.ourTurn = False

        # make the colour dimmer if we're not running in a real game
        self.started = False
        self.demo = demo
        self.color = (255, 255, 255)
        self.fadeColor = fadeColor

        self.settings = settings.GameSettings()

        # XXX - fix me with something dynamic

        offset_x = OFFSET_X
        if columns == 7:
            offset_x = BOARD_OFFSET_X

        offset_y = OFFSET_Y
        if rows == 7:
            offset_y = BOARD_OFFSET_Y

        for y in range(rows):
            for x in range(columns):
                self.tiles.append(Tile(x * 81 + offset_x,
                                         768 - (y * 81) - offset_y,
                                         x, y,
                                         color=self.color,
                                         tileType=random.randint(1, 3),
                                         tileRotation=random.randint(0, 3),
                                         batch=self.tileBatch))


        self.floatingTile = Tile(-100, -100, -1, -1,
                                 color=self.color,
                                 tileType=random.randint(1, 3),
                                 tileRotation=random.randint(0, 3),
                                 batch=self.tileBatch)

        events.addListener(self)

        pyglet.clock.schedule(self.update)
Beispiel #14
0
def construct_obj(res):
    '''

    :param res: response received from client
    :return: constructed tile, and avatar object received from client
    '''
    tile_dict = res[0]
    avatar_dict = res[1]
    tile = Tile(tile_dict['idx'], None)
    if not tile_dict['position'] == None:
        tile.position = (tile_dict['position'][0], tile_dict['position'][1])
    tile.list_of_path = tile_dict['list_of_path']
    avatar = Avatar(avatar_dict['color'], None)
    if not avatar_dict['position'] == None:
        pos = avatar_dict['position'][0]
        port = avatar_dict['position'][1]
        avatar.position = ((pos[0], pos[1]), port)
    return tile, avatar
Beispiel #15
0
 def create_landscape_sprite(self, tile: tiles.Tile) -> None:
     '''
     Creates four arcade.Sprite for landscape element of tile.
     '''
     if tile.entity != None:
         tile.calculate_view()
         sprite_alignment = self.sprite_alignment.get(tile.view['entity'])
         sprites = []
         for i in range(4):
             sprite = TileSprite(self.get_landscape_texture_file(tile, i),
                                 tile, SPRITE_SCALING)
             sprite_y, sprite_x = self.map_sprite_coordinate(
                 tile.y, tile.x, i)
             sprite.left = sprite_x
             sprite.bottom = sprite_y
             self.landscape_sprite_list.append(sprite)
             sprites.append(sprite)
         self.landscape_sprite_map[(tile.y, tile.x)] = sprites
Beispiel #16
0
	def _loadTilestacks(self):
		ret = []
		for y in xrange(self.heightInTiles):
			for x in xrange(self.widthInTiles):
				ts = Tilestack()
				ts.addBaseTile(Tile(self.tileFactory, self.baseTile))
				ret.append(ts)
				
		return ret
Beispiel #17
0
def idx_to_tiles(list_idx):
    '''
		@param: list_idx	list of index
		@return: list of tile obejcts
	'''
    tiles = []
    for i in list_idx:
        tiles.append(Tile(i % 35, None))
    return tiles
Beispiel #18
0
 def defend(self, damage):
     if random.randint(1, 20) > self.defense:
         self.health -= damage
         self.health = max(0, self.health)
         if self.health <= 0:
             self.level.floor.add(
                 Tile("images/monsters/grave.gif",
                      (self.rect.x - 15, self.rect.y - 25)))
             self.image = pygame.image.load("images/terrain/bones.gif")
             self.alive = False
Beispiel #19
0
 def createTileList(self, filename):
     layout = numpy.loadtxt(filename, dtype=str)
     col, row = layout.shape
     for i in range(row):
         for j in range(col):
             value = layout[j][i]
             if (value == '0'):
                 pos = (i*self.width, j*self.height)
                 self.tilelist.append(Tile((self.width, self.height), pos))
     return self.tilelist
 def defend(self, damage):
     if random.randint(1, 20) > self.defense:
         self.health -= damage
         self.heath = max(0, self.heath)
         self.level.messages.add(movingMessage("--{}".format(damage), self.rect.topleft, (255, 0, 0)))
     if self.heath <= 0:
         self.level.message.add(Message("rip", self.ract.center))
         self.level.floor.add(Tile("images/monsters/grave.gif", (self.rect.x-15, self.rect.y-25)))
         self.image = pygame.image.load("images/terrain/bones.glf")
         self.alive= False
Beispiel #21
0
    def load(self, filename):
        f = open(filename, "rb")

        data = f.read(struct.calcsize("<i"))
        data = struct.unpack("<i", data)
        self.tiles = []
        for i in range(0, data[0]):
            self.tiles.append(Tile.load(f))

        f.close()

        self.update_neighbors()
    def boardToSprites(self):
        gameBoard = self.settings.board

        self.rows = gameBoard.rows
        self.columns = gameBoard.columns

        # is this going to gc correctly?
        self.tiles = []
        self.tokens = []

        for y in range(gameBoard.rows):
            for x in range(gameBoard.columns):
                tile = gameBoard.board[y][x]
                self.tiles.append(
                    Tile(x * 81 + BOARD_OFFSET_X,
                         768 - (y * 81) - BOARD_OFFSET_Y,
                         x, y,
                         color=(255, 255, 255),
                         tileType=tile.tileType,
                         tileRotation=tile.tileRotation,
                         batch=self.tileBatch))

                if tile.boardItem and not tile.boardItem.found:
                    self.tokens.append(
                        Token(int(tile.boardItem.itemNumber),
                              self.tiles[-1].x,
                              self.tiles[-1].y,
                              x, y,
                              batch=self.tokenBatch))

        self.floatingTile = \
            Tile(FLOATINGTILE_LOCATION_X,
                 FLOATINGTILE_LOCATION_Y,
                 -1, -1,
                 color=(255, 255, 255),
                 tileType=gameBoard.floatingTile.tileType,
                 tileRotation=gameBoard.floatingTile.tileRotation,
                 batch=self.tileBatch)

        for player in self.settings.board.players:
            column, row = player.getLocation()
            playerSprite = character.Character(column, row)
            tile = self.getTile(column, row)

            playerSprite.x, playerSprite.y = tile.xy
 
            self.people.append(playerSprite)

            self.playerBoxes.append(PlayerBox(player.playerNumber))

            for item in player.boardItems:
                self.playerBoxes[-1].addToken(item.itemNumber)
                pass
Beispiel #23
0
    def load( self, filename ):
        f = open( filename, "rb" )

        data = f.read( struct.calcsize("<i") )
        data = struct.unpack( "<i", data )
        self.tiles = []
        for i in range(0, data[0]):
            self.tiles.append( Tile.load( f ) )

        f.close()

        self.update_neighbors()
Beispiel #24
0
    def player_pick_tile_from_middle(self) -> None:
        """
        Handle everything if a player choses to draw from the middle.
        This includes taking the starting player marker, but also removing tile
        type from the middle and adding it to the pattern lines
        """
        if self.the_middle.is_untouched:
            self.starting_player = self.current_player
            self.the_middle.is_untouched = False
            minus_counter = TileCounter(Tile(99), 1)
            self.players[self.current_player].board.floor_line += minus_counter

        style = int(
            input(
                "What tile type or you picking? (0=black, 1=blue, 2=red, 3=yellow, 4=white) "
            ))
        tile = Tile(style)

        tile_count = self.the_middle.pop(tile)
        tile_counter = TileCounter(tile, tile_count)

        self.players[self.current_player].board.add_tile_count(tile_counter)
Beispiel #25
0
 def generate(self):
     sea_tile = TILE_TYPES.get('water')
     land_tile = TILE_TYPES.get('land')
     seeds = self.place_seeds()
     for x in range(self.width):
         new_row = list()
         for y in range(self.height):
             new_tile = Tile(sea_tile, x, y) if (x,
                                                 y) not in seeds else Tile(
                                                     land_tile, x, y)
             new_row.append(new_tile)
         self._tiles.append(new_row)
     self.generate_continents()
     self.generate_bioms()
     self.clear_glitches()
     self.place_resources()
     self.place_states(6)
     return {
         'tiles': self._tiles,
         'cities': self._cities,
         'resources': self._resources
     }
Beispiel #26
0
def importer(name, texture_size):
    with open(name, "r") as file:
        lines = file.readlines()
        size = lines[0].split(",")
        size = int(size[0]), int(size[1])
        grid = Grid(size)

        useless = None
        collision = False

        x, y = 0, 0
        state = "new"
        for line in lines[1:]:
            if "/" in line:
                state = "new"
                x += 1
                if x >= size[0]:
                    y += 1
                    x = 0
                continue

            if "|" in line:
                useless, collision = line.split(",")
                continue

            if state == "new":
                texture, position = line.split(",")
                tile = Tile(Texture(texture, int(position), texture_size))
                tile.collision = bool(int(collision))
                grid.put(x, y, tile)
                state = "added"
                continue

            if state == "added":
                texture, position = line.split(",")
                grid.get(x,
                         y).add(Texture(texture, int(position), texture_size))

    return grid
    def setup_level(self, layout):
        self.tiles = pygame.sprite.Group()
        self.player = pygame.sprite.GroupSingle()
        for row_index, row in enumerate(layout):
            for col_index, cell in enumerate(row):
                x = col_index * tile_size
                y = row_index * tile_size

                if cell == 'X':
                    tile = Tile((x, y), tile_size)
                    self.tiles.add(tile)
                elif cell == "P":
                    player_sprite = Player((x, y), self.display_surface)
                    self.player.add(player_sprite)
	def get_surrounding_tiles(base_node):

		# makes an array that save all the combinations of tiles surround the zombie( base_node == zombieTile)
		# so if zombie moves to N, W, or etc, we have all these combinations numbers (position + 1 or - 1 or + 18, etc)
		# so then we can use them to our math to predict the better path
		array =(
			(base_node.number + N),
			(base_node.number + NE),
			(base_node.number + E),
			(base_node.number + SE),
			(base_node.number + S),
			(base_node.number + SW),
			(base_node.number + W),
			(base_node.number + NW),
			)

		tiles = []

		# *****
		# make this change to make the zombie to be able to walk just N,S,E,W - not NE,SW, etc
		# original node number
		onn = base_node.number 
		diagonals = [onn + NE, onn + NW, onn + SE, onn + SW]
        # *****


        # this for get all the new position(number of the tiles) from the array, that represet the tiles sorround from the Zombie
        # and get the tile, from Tile list in Tile class. Then we check if zombie can really go in the direction(tile)
        # if it does, we add that tile for the tile list
		for tile_number in array:

			surrounding_tile = Tile.get_tile(tile_number)

			# to avoid a zombie to get possible new path in tiles that doen's exist, for example if the zombie is in the
			# border, it cannot go up, for that we have to avoid with this if below
			if tile_number not in range(1, Tile.total_tiles + 1):
			    continue # if there'e not that tile, we jump the for for the next loop, so then, it doen's run the lines below
			    			# and consequently, it doen't calculate the path for that tile

			if surrounding_tile.walkable and surrounding_tile not in closed_list:
			    #tiles.append(surrounding_tile) # Diagonal movement - just add this and coment next line

				tiles = blocky(tiles, diagonals, surrounding_tile) # make sure to add the tile just if it is n,s,w,e

		return tiles
Beispiel #29
0
    def __init__(self, sizeMAze, WIDTH, HEIGHT):

        Maze.widthMaze = WIDTH
        Maze.heightMaze = HEIGHT
        Maze.size_maze = sizeMAze
        Maze.cost_walk = 10
        tileWidth = WIDTH // sizeMAze
        tileHeight = HEIGHT // sizeMAze
        # gonna make N * N maze, each position being a tile ID

        mode = sizeMAze  # used to check each colum each tile belongs to
        yPos = 0  # everytime we change column, it increases by tileHeight
        xPos = 0
        # calculate x and y positions for each tile
        for idMaze in range(1, (sizeMAze * sizeMAze) + 1):
            if (
                    idMaze // mode < 1
            ):  # if it's the number by itself, the tile still belongs to that column
                x = xPos * tileWidth
                y = yPos
                xPos += 1
            else:
                if (idMaze //
                        mode == 1):  # update y position and reset X variables
                    x = xPos * tileWidth
                    y = yPos

                xPos = 0
                yPos += tileHeight
                mode += sizeMAze

            Maze.tilesMaze[idMaze] = Tile(tileWidth, tileHeight, x, y)

        pygame.Rect.__init__(self, Maze.xPos, Maze.yPos, Maze.widthMaze,
                             Maze.heightMaze)

        self._setNeighbors(sizeMAze)
        self._setWalls(sizeMAze)

        # get a cell(node) randomly
        randomNode = random.randrange(sizeMAze * sizeMAze) + 1
        self._generateMazeDFS(Maze.tilesMaze[randomNode])
        #self._createMultiplePathsBFS( ) Not good, runs exponetial time by doing BFS from every node to all nodes
        self._createMultiplePathsRandom()
Beispiel #30
0
    def score_floor_line(self) -> List[TileCounter]:
        """
        Score and flush the minus point area. Returns a list with TileCounter
        that represent the discarded tiles.

        The method makes sure that the minus-tile (=Tile(99)) does not end up
        in the discarded tiles. The minus-point tile implicitly returns to
        TheMiddle (actually it is recreated whenever somebody takes a
        'first draw' from TheMiddle)
        """
        self.point_total -= self.floor_line.count_minus_points

        discarded_tile_list = self.floor_line[:]
        self.floor_line = FloorLine()

        return [
            TileCounter(tile, 1)
            for tile in discarded_tile_list
            if tile != Tile(99)  # Tile(99) is the minus-point tile
        ]
    def update(self, screen, clock_elapsed):

        self.img = Survivor.survivor_img[self.current]
        rotateDirection = self.direction
        self.direction = ''
        self.rotate(rotateDirection)

        # check if next tile/target is a portal, if it's, we change the player position to one of the other portal tile
        if self.tx != None and self.ty != None: 
            self.movement(clock_elapsed)
            # have to change here, instead get where we are, get where we are going to
            targetTileNumber = ((self.x // self.width) + Tile.H) + ((self.y // self.height) * Tile.V)

            # check if the next tile number is actually inside of the portals list, in the tile class
            # it holds the tile numbers that has a portal
            if self.future_tile_number in Tile.portals:
                sortNewPortalTile = randint(0, 3)
                # make sure if actually move from the portal to another one
                while Tile.portals[sortNewPortalTile]==targetTileNumber:
                    sortNewPortalTile = randint(0, 3)

                # then change the position of player to the new portal x and y position
                futureSortPortal = Tile.get_tile(Tile.portals[sortNewPortalTile])
                
                """for i in range(10000):
                    for i in range(10000):
                        a=i
                """
                self.x = futureSortPortal.x
                self.y = futureSortPortal.y

                self.tx = None
                self.ty = None
                # after move to the new portal, we move the player, just to make the action of walking throught the portal
                """self.tx = self.x + 32  
                self.ty = self.y + 32 
                self.movement()
                """
            

        screen.blit(self.img, (self.x, self.y))
Beispiel #32
0
    def player_pick_tile_from_factory(self) -> None:
        factory_nr = int(input("What factory are you choosing from? "))
        style = int(
            input(
                "What tile type or you picking? (0=black, 1=blue, 2=red, 3=yellow, 4=white) "
            ))

        tile = Tile(style)

        tile_count = self.factories[factory_nr].pop(tile)
        tile_counter = TileCounter(tile, tile_count)

        # Add factory leftovers to the middle
        factory_leftover = self.factories[factory_nr]
        for k, v in factory_leftover.items():
            self.the_middle[k] += v

        # Make sure that the factory is empty
        self.factories[factory_nr] = Factory()

        # Add tiles to player's pattern lines
        self.players[self.current_player].board.add_tile_count(tile_counter)
Beispiel #33
0
 def create(self, tile: tiles.Tile, texture: str, scale: int = 1) -> None:
     '''
     Creates new static object on specified tile with chosen texture.
     '''
     new_object = StaticMapObject()
     new_object.texture = texture
     new_object.sprite = arcade.Sprite(texture, scale)
     new_object.size = (new_object.sprite.height, new_object.sprite.width)
     new_object.bottom = random.random() + tile.y
     new_object.sprite.bottom = int(new_object.bottom * tile.size)
     new_object.left = random.random() + tile.x
     new_object.sprite.left = int(new_object.left * tile.size)
     new_object.tiles = self.game_map.get_tiles(
         (int(new_object.bottom), int(new_object.left)),
         (int(new_object.bottom + new_object.size[0] / tile.size),
          int(new_object.left + new_object.size[1] / tile.size)))
     for tile in new_object.tiles:
         if tile.entity != None:
             return None
     for tile in new_object.tiles:
         tile.entity = new_object
     self.sprite_list.append(new_object.sprite)
     self.static_objects_list.append(new_object)
    def spawn(total_frames, FPS):
        if total_frames % (FPS * Zombie.zombieTimeGeneration) == 0: # how much new zombies will show up per frame

            # select one of the musics for when the zombie is create
            # however, we create a new zombie around each 3 second, but we don't want to make a zombie sound every 3 second
            # so then we put * 6, to the zombie make sound, roundly choose for the list, in each 6 seconds(around)
            if total_frames % (FPS * 6) == 0 and total_frames >0:

                r = randint(0, 4)
                sounds = [pygame.mixer.Sound('../Sound_Effects/I_will_kill_you.wav'), 
                        pygame.mixer.Sound('../Sound_Effects/zombie_attack.wav'),
                        pygame.mixer.Sound('../Sound_Effects/zombie_scream1.wav'),
                        pygame.mixer.Sound('../Sound_Effects/zombie_scream2.wav'),
                        pygame.mixer.Sound('../Sound_Effects/zombie_come_here.wav')]
                sound = sounds[ r ]
                sound.play()
            


            r = randint(0, len(Tile.dangeounZombies) - 1) # get a random position from spawn_tiles, to put the zombie on screen
            tile_num = Tile.dangeounZombies[r] # get the number in that random position of the list
            spawn_node = Tile.get_tile(tile_num) # get the tile that represents that tile
            Zombie(spawn_node.x, spawn_node.y) # create a new zombie with that tile x and y position, and add to the static 
    def __init__(self, hex1, hex2, hex3):
        self.coordinate = sorted([hex1,hex2,hex3])
        self.x = self.coordinate[0]
        self.y = self.coordinate[1]
        self.z = self.coordinate[2]

        self.vertex = False

        self.building = 0 #empty = 0, settlement = 1, city == 2
        self.building_ownership = 0 #set this equal to the player.index

        self.tk_index = None  # Tkinter index of settlement or city

        port_tile_pairs = [[15,16],[2,9],[4,10],
                            [12,19],[27,26],[40,33],
                            [46,38],[44,37],[29,30]]

        self.is_port = False
        for pair in port_tile_pairs:
            if (pair[0] in self.coordinate) and (pair[1] in self.coordinate):
                self.is_port = True

        #self.settlement_owner = 0  # Owner of settlement on point
        #self.city_owner = 0  # Owner of city on point

        # Check whether point is valid on board
        tile_1 = Tile(self.x)
        tile_2 = Tile(self.y)
        tile_3 = Tile(self.z)
        if tile_1.has_neighbor(tile_2) and tile_2.has_neighbor(tile_3) and \
            tile_3.has_neighbor(tile_1):
            if not(tile_1.visible) and not(tile_2.visible) and \
                not(tile_3.visible):
                self.valid = False
            else:
                self.valid = True
        else:
            self.valid = False
def interaction(screen, survivor):

    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

        # you can change the gun when you press the key/letter 'e'
        if event.type == pygame.KEYDOWN:

            if event.key == pygame.K_e:

                survivor.current += 1
                survivor.current %= 3 # to make sure it goes to 0,1,2 - because when you get 3, mode 3 by 3 =0
                

    # Movemnt of the player is gonna be not just when you press a key, but when you press or you are holding
    # that's why it goes outside of the loop events
    keys = pygame.key.get_pressed()

    if keys[pygame.K_w]:# North

    	# first, before move we have to ckeck if that position is walkable
    	# so them, you first get the "new" position for that character
    	# in this case we get the number of the character, that represents
    	# his position on screen, minus how many we can move, Remember that is is to
    	# left or right, is gonna move always 1 block, if it's up or down, 18 block
        future_tile_number = survivor.get_number() - Tile.V

        # then we check if that number of tile is walkable, for the we move
        # the character
        # first if check if the new tile actually exist, if the tile number is in the Tile list, it can move
        if future_tile_number in range(1, Tile.total_tiles + 1):
            future_tile = Tile.get_tile(future_tile_number)
            if future_tile.walkable: # if player can move for that direction(future tile), we set the target with that tile
                                     # and the method will take cara of how to move the player smothly - on object-classes.py
                survivor.set_target(future_tile) # it make the movemnt
                survivor.rotate('n') # since we are moving north, we change the rotation of the picture to north
                survivor.future_tile_number = future_tile_number
             
    if keys[pygame.K_s]: # South
    
        future_tile_number = survivor.get_number() + Tile.V
        if future_tile_number in range(1, Tile.total_tiles + 1):

            future_tile = Tile.get_tile(future_tile_number)
            if future_tile.walkable: # if player can move for that direction(future tile), we set the target with that tile
                                     # and the method will take cara of how to move the player smothly - on object-classes.py
                survivor.set_target(future_tile)
                survivor.rotate('s') 
                survivor.future_tile_number = future_tile_number 

    if keys[pygame.K_a]: # West
        future_tile_number = survivor.get_number() - Tile.H

        if future_tile_number in range(1, Tile.total_tiles + 1):
            
            future_tile = Tile.get_tile(future_tile_number)
            if future_tile.walkable: # if player can move for that direction(future tile), we set the target with that tile
                                     # and the method will take cara of how to move the player smothly - on object-classes.py
                survivor.set_target(future_tile)
                survivor.rotate('w')
                survivor.future_tile_number = future_tile_number

    if keys[pygame.K_d]: # East
        future_tile_number = survivor.get_number() + Tile.H
       # print("Future left ",future_tile_number)

        if future_tile_number in range(1, Tile.total_tiles + 1):
            
            future_tile = Tile.get_tile(future_tile_number)
            if future_tile.walkable: # if player can move for that direction(future tile), we set the target with that tile
                                     # and the method will take cara of how to move the player smothly - on object-classes.py
                survivor.set_target(future_tile)
                survivor.rotate('e')
                survivor.future_tile_number = future_tile_number

    # you use the arrow to rotate the character, to point for with direction you want to shot. so you can walk left
    # pressind 'A', but zombies are coming from right, so you can turn your face to right and shot in that direction
    # but keep walking for left

    if keys[pygame.K_LEFT]:
        survivor.rotate('w')
        
        Bullet(survivor.centerx, survivor.centery +5, -20, 0, 'w', survivor.get_bullet_type() )

    elif keys[pygame.K_RIGHT]:
        survivor.rotate('e')
        Bullet(survivor.centerx, survivor.centery +5, 20, 0, 'e', survivor.get_bullet_type() )

    elif keys[pygame.K_UP]:
        survivor.rotate('n')
        Bullet(survivor.centerx, survivor.centery +5, 0, -20, 'n', survivor.get_bullet_type() )

    elif keys[pygame.K_DOWN]:
        survivor.rotate('s')
        Bullet(survivor.centerx, survivor.centery +5, 0, 20, 's', survivor.get_bullet_type() )
Beispiel #37
0
GREEN = [0, 255, 0]
RED = [255, 0, 0]
WIDTH = 960
HEiGHT = 640

pygame.init()
pygame.mixer.pre_init()
pygame.mixer.set_num_channels(3)
pygame.font.init()  # initialize font class in pygame
pygame.mixer.init()

screen = pygame.display.set_mode((WIDTH, HEiGHT))  # 32 x 32  size of tiles
pygame.display.set_caption("Maze Game")

# set up all the tiles
Tile.pre_init(screen)
survivor = Survivor(32, 32 * 6)

clock = pygame.time.Clock()
FPS = 24  # if we increase this number, the speed of character will be lower
total_frames = 0
total_frames_welcome = 0
pygame.mouse.set_visible(True)
# load and play background welcome page sound again
pygame.mixer.music.load('../Sounds/htd.wav')
pygame.mixer.music.play(-1)  # -1 put to loop the music forever

# Loop until the user clicks the close button.
done = False
Zombie.spawn()
while True:
Beispiel #38
0
  def get_tile_n(self, number):

    return Tile.get_tile(number)
Beispiel #39
0
  def get_tile(self):

    return Tile.get_tile(self.get_number())
def get_pos(img, pos_x, pos_y, depth):
    res = img.copy()
    h, w = img.shape[:2]

    M = cv2.getRotationMatrix2D((w / 2, h / 2), (imu_yaw) * 180 / math.pi, 1)
    img = cv2.warpAffine(img, M, (w, h))

    # circle mask
    circle_mask = np.zeros_like(img)
    circle_mask = cv2.circle(circle_mask, (int(w / 2), int(h / 2)), int(h / 2),
                             [255, 255, 255], -1)
    circle_mask = circle_mask[:, :, 0]

    # print(h,w)
    img = img_correction(img)

    blur = cv2.GaussianBlur(img, (7, 7), 0)
    hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV)

    mask = cv2.adaptiveThreshold(hsv[:, :, 2], 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, \
                                 cv2.THRESH_BINARY, 21, 2)

    kernel = np.ones((5, 5), np.uint8)
    opening = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)
    opening = 255 - opening
    opening = cv2.dilate(opening, None, iterations=1)
    contour_mask = 255 - opening
    opening[circle_mask == 0] = 0
    # fit lines to extract major direction
    minLineLength = 100
    lines = cv2.HoughLinesP(image=opening,
                            rho=1,
                            theta=np.pi / 180,
                            threshold=100,
                            lines=np.array([]),
                            minLineLength=minLineLength,
                            maxLineGap=12)

    grad = np.zeros((len(lines), 1))
    i = 0
    for line in lines:
        # find two major gradients
        x1, y1, x2, y2 = line[0][0], line[0][1], line[0][2], line[0][3]
        theta = math.atan(float(y2 - y1) / (x2 - x1)) * 180 / math.pi

        grad[i] = theta
        i += 1
        # cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 3, cv2.LINE_AA)
        cv2.line(contour_mask, (x1, y1), (x2, y2), 0, 1, cv2.LINE_AA)

    hist, bin_edges = np.histogram(grad, density=False)
    ind = np.argmax(hist)
    best_grad = round((bin_edges[ind] + bin_edges[ind + 1]) / 2, 2)

    ind = np.where(np.abs(grad - best_grad) < 10)
    good_grads = grad[ind]
    best_grad = np.mean(good_grads)

    # contour_mask=self.mask_correction(contour_mask)
    M = cv2.getRotationMatrix2D((w / 2, h / 2), best_grad, 1)
    contour_mask = cv2.warpAffine(contour_mask, M, (w, h))

    (contours, _) = cv2.findContours(contour_mask, cv2.RETR_EXTERNAL,
                                     cv2.CHAIN_APPROX_NONE)
    contour_mask = cv2.cvtColor(contour_mask, cv2.COLOR_GRAY2BGR)
    areas = []
    border = 0
    r = []

    for contour in contours:
        rect = cv2.boundingRect(contour)

        if rect[0] > border and rect[0] + rect[2] < w - border and rect[
                1] > border and rect[3] + rect[1] < h - border:
            area = int(rect[3] * rect[2])
            # print(area)
            ar = float(rect[2]) / rect[3]
            real_ar = 0.25 / 0.12
            if area > 1000 and area < 120000 and abs(ar / real_ar - 1) < 0.3:
                cv2.rectangle(contour_mask, (rect[0], rect[1]),
                              (rect[2] + rect[0], rect[3] + rect[1]),
                              (0, 255, 0), 2)
                areas.append(area)
                r.append(rect)

    areas = np.asarray(areas)
    hist, bin_edges = np.histogram(areas, bins='fd', density=False)
    ind = np.argmax(hist)
    # best_area=(bin_edges[ind]+bin_edges[ind+1])/2

    best_area = round((bin_edges[ind] + bin_edges[ind + 1]) / 2, 2)
    ind = np.where(np.abs(areas - best_area) < 0.1 * best_area)
    if len(ind) > 5:
        good_areas = areas[ind]
        best_area = np.mean(good_areas)

    pred_depth = predict_depth(best_area)

    pred_depth = pred_depth * math.cos(imu_pitch) * math.cos(imu_roll)

    for tile in tiles:
        r = tile.one_step_update(r)

    for rect in r:
        tiles.append(Tile(rect, ind_count))
        ind_count += 1

    for tile in tiles:
        if tile.alive == False:
            tiles.remove(tile)

    del_x = []
    del_y = []
    for tile in tiles:
        color = colors[tile.ind % 20]
        color = tuple([int(x) for x in color])
        if len(tile.centers) > 2:
            del_x.append(tile.centers[-1][1] - tile.centers[-2][1])
            del_y.append(tile.centers[-1][0] - tile.centers[-2][0])
        contour_mask = cv2.circle(
            contour_mask, (int(tile.centers[-1][0]), int(tile.centers[-1][1])),
            5, color, -1)
        cv2.putText(contour_mask, str(tile.ind),
                    (tile.bb[0] + 10, tile.bb[1] + 10), font, 0.8, color, 1,
                    cv2.LINE_AA)

    hist, bin_edges = np.histogram(np.asarray(del_x), bins='fd', density=False)
    ind = np.argmax(hist)
    best_del_x = round((bin_edges[ind] + bin_edges[ind + 1]) / 2, 2)

    hist, bin_edges = np.histogram(np.asarray(del_y), bins='fd', density=False)
    ind = np.argmax(hist)
    best_del_y = round((bin_edges[ind] + bin_edges[ind + 1]) / 2, 2)

    # tile real world dimension
    fov_w, fov_h = 48 * math.pi / 180, 36 * math.pi / 180
    px_W, px_H = 640, 480
    W = 2 * pred_depth * math.tan(fov_w / 2) + 0.0001
    ppm = px_W / W
    pos_x -= best_del_x / ppm
    pos_y -= best_del_y / ppm
    return pos_x, pos_y, pred_depth
Beispiel #41
0
# -*- coding: utf-8 -*-
from tiles import Tile
from shanten import Shanten
import utils

hand_str = input("input your hand tiles: ")
your_tile = Tile(hand_str)
your_shanten = 8
error_state = your_tile.error_state
rest_tiles = your_tile.rest_card
if error_state:
    print("please input right 14 tiles")
hand_tiles = your_tile.hand_tiles
discard_list = []
while not error_state:
    shanten_data = Shanten.get_shanten_data(hand_tiles)
    your_shanten = shanten_data["all_shanten"]
    if your_shanten == -1:
        print("win")
        break
    print("hand_str:", utils.codes_to_str(hand_tiles))
    Shanten.print_shanten_message(shanten_data, rest_tiles)
    print("------")
    discard = input("to discard: ")
    discard_code = utils.str_to_code(discard)
    hand_tiles.remove(discard_code)
    discard_list.append(discard_code)
    remove_tiles = input("to remove form deck: ")
    remove_card = Tile(remove_tiles).hand_tiles
    rest_tiles = Shanten.remove_item(remove_card, rest_tiles)
    in_tile = input("in: ")
class Board(AnimateBoard):
    def __init__(self, columns=COLUMNS, rows=ROWS, demo=False,
                 fadeColor=(100, 100, 100)):
        self.tileBatch = pyglet.graphics.Batch()
        self.tokenBatch = pyglet.graphics.Batch()

        self.tiles = []
        self.tokens = []
        self.people = []

        self.playerBoxes = []

        self.dragTile = False

        self.moving = False
        self.movingTiles = []

        self.columns = columns
        self.rows = rows

        self.ourTurn = False

        # make the colour dimmer if we're not running in a real game
        self.started = False
        self.demo = demo
        self.color = (255, 255, 255)
        self.fadeColor = fadeColor

        self.settings = settings.GameSettings()

        # XXX - fix me with something dynamic

        offset_x = OFFSET_X
        if columns == 7:
            offset_x = BOARD_OFFSET_X

        offset_y = OFFSET_Y
        if rows == 7:
            offset_y = BOARD_OFFSET_Y

        for y in range(rows):
            for x in range(columns):
                self.tiles.append(Tile(x * 81 + offset_x,
                                         768 - (y * 81) - offset_y,
                                         x, y,
                                         color=self.color,
                                         tileType=random.randint(1, 3),
                                         tileRotation=random.randint(0, 3),
                                         batch=self.tileBatch))


        self.floatingTile = Tile(-100, -100, -1, -1,
                                 color=self.color,
                                 tileType=random.randint(1, 3),
                                 tileRotation=random.randint(0, 3),
                                 batch=self.tileBatch)

        events.addListener(self)

        pyglet.clock.schedule(self.update)

    def getTile(self, column, row):
        for tile in self.tiles:
            if tile.column == column and tile.row == row:
                return tile

    def boardToSprites(self):
        gameBoard = self.settings.board

        self.rows = gameBoard.rows
        self.columns = gameBoard.columns

        # is this going to gc correctly?
        self.tiles = []
        self.tokens = []

        for y in range(gameBoard.rows):
            for x in range(gameBoard.columns):
                tile = gameBoard.board[y][x]
                self.tiles.append(
                    Tile(x * 81 + BOARD_OFFSET_X,
                         768 - (y * 81) - BOARD_OFFSET_Y,
                         x, y,
                         color=(255, 255, 255),
                         tileType=tile.tileType,
                         tileRotation=tile.tileRotation,
                         batch=self.tileBatch))

                if tile.boardItem and not tile.boardItem.found:
                    self.tokens.append(
                        Token(int(tile.boardItem.itemNumber),
                              self.tiles[-1].x,
                              self.tiles[-1].y,
                              x, y,
                              batch=self.tokenBatch))

        self.floatingTile = \
            Tile(FLOATINGTILE_LOCATION_X,
                 FLOATINGTILE_LOCATION_Y,
                 -1, -1,
                 color=(255, 255, 255),
                 tileType=gameBoard.floatingTile.tileType,
                 tileRotation=gameBoard.floatingTile.tileRotation,
                 batch=self.tileBatch)

        for player in self.settings.board.players:
            column, row = player.getLocation()
            playerSprite = character.Character(column, row)
            tile = self.getTile(column, row)

            playerSprite.x, playerSprite.y = tile.xy
 
            self.people.append(playerSprite)

            self.playerBoxes.append(PlayerBox(player.playerNumber))

            for item in player.boardItems:
                self.playerBoxes[-1].addToken(item.itemNumber)
                pass


    # XXX - remove this later
    def placePeople(self):
        positions = [(0, 0), (self.columns-1, self.rows-1),
                     (0, self.rows-1), (self.columns-1, 0)]

        for count, person in enumerate(self.people):
            pos = positions[count]
            for tile in self.tiles:
                if tile.row == pos[1] and tile.column == pos[0]:
                    person.x = tile.x
                    person.y = tile.y

    def on_mousePress(self, args):
        print "!!! button pressed"
        x, y, button, modifiers = args
        #self.checkTileClicked(x, y)
        if self.ourTurn:
            self.pickupFloatingTile(x, y)

    def on_mouseRelease(self, args):
        print "!!! button released"
        x, y, button, modifiers = args
        if self.ourTurn:
            self.checkTileClicked(x, y)
            if self.dragTile:
                self.dropFloatingTile(x, y)

    def on_mouseDrag(self, args):
        x, y, dx, dy, buttons, modifiers = args
        if self.dragTile:
            self.dragFloatingTile(x, y)

    def on_keyPress(self, args):
        print "!!! key pressed"
        symbol, modifiers = args
        if symbol == key.RIGHT:
            self.settings.client.send('/rotate clockwise')
        elif symbol == key.LEFT:
            self.settings.client.send('/rotate counterclockwise')
        elif symbol == key.SPACE:
            if self.ourTurn:
                self.ourTurn = False
                self.settings.client.send('/end')

    def on_tileRotated(self, args):
        print "!!! tile rotated"
        print args

        self.floatingTile.rotate(int(args[0]))

    def on_playerSetup(self, args):
        print "!!! player setup"
        print args

    def on_turnChanged(self, args):
        print "!!! player turn changed"
        print args

        self.settings.board.playerTurn = int(args[1])

        print "player turn = %d" % self.settings.board.playerTurn


    def on_playerTookObject(self, args):
        print "!!! player took object"
        print args
        playerNum = self.settings.board.playerTurn - 1

        player = self.people[playerNum]

        for token in self.tokens:
            if token.column == player.column and \
               token.row == player.row:
                tokenId = token.tokenId
                for player in self.playerBoxes:
                    for playerToken in player.tokens:
                        if playerToken.tokenId == tokenId:
                            playerToken.setHighlight(True)
                self.tokens.remove(token)
                break

    def on_boardData(self, args):
        boardData = args[0]
        print "!!! board data = %s" % args[0]

        self.settings.board.deserialize(boardData)
        if not self.started:
            self.boardToSprites()
            self.started = True

        print "player turn = %d" % self.settings.board.playerTurn

    def on_startGame(self, args):
        print "!!! start game"
        self.demo = False
        #self.fallOut()

        #self.settings.fallingTiles = True

    def on_tilePushed(self, args):
        nick, pos, direction = args
        self.moveTiles(int(pos), int(direction))
        self.settings.client.send('/data')

    def on_playerTurn(self, args):
        print "!!! your turn"
        self.ourTurn = True
        self.tilePushed = False

    def on_playerMoved(self, args):
        nick, column, row = args
        print "!!! player moved"
        print args
        column = int(column)
        row = int(row)

        traverseGraph = traverse.TraversalGraph(self.settings.board)

        playerNum = self.settings.board.playerTurn - 1
        startLocation = self.settings.board.players[playerNum].location

        print [x.location for x in self.settings.board.players]
Beispiel #43
0
pygame.mixer.pre_init()
pygame.mixer.set_num_channels(3)
pygame.font.init() # initialize font class in pygame
pygame.mixer.init()
  
                                # 30 tiles horizontal per line
                                # 30 columns of blocks in total

                                # and 20 vertical per vertical line
                                # 20 lines of block in total

screen = pygame.display.set_mode((WIDTH, HEiGHT)) # 32 x 32  size of tiles
pygame.display.set_caption("Hunted")

# set up all the tiles
Tile.pre_init(screen)

clock = pygame.time.Clock()
FPS = 24 # if we increase this number, the speed of character will be lower
total_frames = 0
total_frames_welcome = 0

survivor = Survivor(32, 32*6)

princess = Princess()

# set the welcome/final page of the game
Welcome.set_welcome(screen)

# load the background music
#pygame.mixer.music.load('../Sound_Effects/background2.wav')
    def get_tile(self):

        return Tile.get_tile(self.get_number())
Beispiel #45
0
def load_level(num):
    Config.config_level(num)
    Drawable.recreateWindow()
    Tile.load_level(num)
    Character.load_characters(num)