Esempio n. 1
0
def Create():
    global delete_idx
    if mode == 't' and kind == 1:
        # basic tile
        tiles.append(tile_class.TILE(x, y, size_x, size_y, 1))
        tile_x.append(x + camera_x)
        tile_y.append(y)
        tile_mode.append(1)
        delete_idx = "tile"
    elif mode == 't' and kind == 2:
        # tile2
        tiles.append(tile_class.TILE(x, y, size_x, size_y, 2))
        tile_x.append(x + camera_x)
        tile_y.append(y)
        tile_mode.append(2)
        delete_idx = "tile"
    elif mode == 't' and kind == 3:
        # tile3
        tiles.append(tile_class.TILE(x, y, size_x, size_y, 3))
        tile_x.append(x + camera_x)
        tile_y.append(y)
        tile_mode.append(3)
        delete_idx = "tile"
    elif mode == 'o' and kind == 1:
        # triangle obstacle
        tri_obses.append(obstacle_class.OBSTACLE_TRIANGLE(x, y))
        tri_obs_x.append(x + camera_x)
        tri_obs_y.append(y)
        delete_idx = "tri_obs"

    pass
Esempio n. 2
0
def ReadPos():
    global tile_x, tile_y, tile_mode, tri_obs_x, tri_obs_y, tiles, tri_obses
    f = open('stage3_tile_pos.txt', mode='rt')
    # tile pos read
    while True:
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or (not line) or line == '':
            break
        tile_x.append(float(line))
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or (not line) or line == '':
            break
        tile_y.append(float(line))
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or not line or line == '':
            break
        tile_mode.append(int(line))
        if tile_mode[len(tile_mode) - 1] == 1:
            tiles.append(
                tile_class.TILE(tile_x[len(tile_x) - 1],
                                tile_y[len(tile_x) - 1], 100, 100, 1))
        elif tile_mode[len(tile_mode) - 1] == 2:
            tiles.append(
                tile_class.TILE(tile_x[len(tile_x) - 1],
                                tile_y[len(tile_y) - 1], 70, 20, 2))
        elif tile_mode[len(tile_mode) - 1] == 3:
            tiles.append(
                tile_class.TILE(tile_x[len(tile_x) - 1],
                                tile_y[len(tile_y) - 1], 70, 20, 3))

    f2 = open('stage3_triangle_obs_pos.txt', mode='rt')
    # triangle obstacle pos read
    while True:
        line = f2.readline()
        line.strip('\n')
        if line == "end\n" or not line or line == '':
            break
        tri_obs_x.append(float(line))

        line = f2.readline()
        line.strip('\n')
        if line == 'end\n' or not line or line == '':
            break
        tri_obs_y.append(float(line))

        tri_obses.append(
            obstacle_class.OBSTACLE_TRIANGLE(tri_obs_x[len(tri_obs_x) - 1],
                                             tri_obs_y[len(tri_obs_y) - 1]))

    f.close()
    f2.close()
def ReadPos():
    f = open('stage3_tile_pos.txt', mode='rt')
    # tile pos read
    while True:
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or (not line) or line == '':
            break
        tile_x = float(line)
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or (not line) or line == '':
            break
        tile_y = float(line)
        line = f.readline()
        line.strip('\n')
        if line == 'end\n' or not line or line == '':
            break
        tile_mode = int(line)
        if tile_mode == 1:
            tiles.append(tile_class.TILE(tile_x, tile_y, 100, 100, 1))
        elif tile_mode == 2:
            tiles.append(tile_class.TILE(tile_x, tile_y, 70, 20, 2))
        elif tile_mode == 3:
            tiles.append(tile_class.TILE(tile_x, tile_y, 70, 20, 3))

    f2 = open('stage3_triangle_obs_pos.txt', mode='rt')
    # triangle obstacle pos read
    while True:
        line = f2.readline()
        line.strip('\n')
        if line == "end\n" or not line or line == '':
            break
        tri_obs_x = float(line)
        line = f2.readline()
        line.strip('\n')
        if line == 'end\n' or not line or line == '':
            break
        tri_obs_y = float(line)
        triangle_obstacles.append(
            obstacle_class.OBSTACLE_TRIANGLE(tri_obs_x, tri_obs_y))

    f.close()
    f2.close()