Exemplo n.º 1
0
def runGame():
    global WIDTH, HEIGHT, SCALE, OCTAVES, PERSISTANCE, LACUNARITY
    playerBoat = Boat(SELECTED_BOAT, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
    SEED = np.random.randint(0, 100)
    world = Terrain(HEIGHT, WIDTH)
    world.generateTopTerrain(SCALE, OCTAVES, PERSISTANCE, LACUNARITY, SEED)
    world.generateTopColor(-0.2, 0.01, 0.055, 0.25, 0.33, 0.47, 0.55)
    image = pg.surfarray.make_surface(world.topColorTerrain).convert()

    while True:
        deltaTime = clock.get_time()
        backgroundInputCheck(pg.event.get())

        playerBoat.getInput(pg.key.get_pressed(), deltaTime)
        playerBoat.update(
            deltaTime, world.topColorTerrain[len(world.topColorTerrain) -
                                             int(playerBoat.position.x)]
            [len(world.topColorTerrain[0]) - int(playerBoat.position.y)])

        screen.fill(BLACK)
        screen.blit(image, (-playerBoat.position.x, -playerBoat.position.y))
        playerBoat.draw(screen, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)

        clock.tick(60)
        pg.display.flip()
Exemplo n.º 2
0
def showLand(waterLevel):
    global WIDTH, HEIGHT, SCALE, OCTAVES, PERSISTANCE, LACUNARITY
    SEED = np.random.randint(0, 100)
    world = Terrain(HEIGHT, WIDTH)
    world.generateTopTerrain(SCALE, OCTAVES, PERSISTANCE, LACUNARITY, SEED)
    world.raiseTerrain(-0.3)
    print("Land Generated")

    while True:
        backgroundInputCheck(pg.event.get())
        world.generateTopColor(waterLevel, waterLevel + 0.045,
                               waterLevel + 0.24, waterLevel + 0.32,
                               waterLevel + 0.46, waterLevel + 0.54)
        image = pg.surfarray.make_surface(world.topColorTerrain).convert()
        screen.fill(BLACK)
        screen.blit(image, (0, 0))

        clock.tick(30)
        pg.display.flip()
Exemplo n.º 3
0
def createLand(initWaterLevel, increment):
    global WIDTH, HEIGHT, SCALE, OCTAVES, PERSISTANCE, LACUNARITY
    SEED = np.random.randint(0, 100)
    world = Terrain(HEIGHT, WIDTH)
    world.generateTopTerrain(SCALE, OCTAVES, PERSISTANCE, LACUNARITY, SEED)
    print("Land Generated")

    waterLevel = initWaterLevel

    while waterLevel < world.findMaxHeight():
        backgroundInputCheck(pg.event.get())
        world.generateTopColor(waterLevel, waterLevel + 0.045,
                               waterLevel + 0.24, waterLevel + 0.32,
                               waterLevel + 0.46, waterLevel + 0.54)
        image = pg.surfarray.make_surface(world.topColorTerrain).convert()

        screen.fill(BLACK)
        screen.blit(image, (0, 0))

        waterLevel += increment
        clock.tick(30)
        pg.display.flip()