Exemple #1
0
def checkBlock(x, y, dx, dy):
    updateVars()
    b = files.getBlockType(files.getBlock(x + dx, y + dy))
    if (b < 2):
        return False
    else:
        return True
Exemple #2
0
def attemptMoveRight(a, b):
    global scrn
    blk, t = getWater(a, b)
    if (files.getBlockType(files.getBlock(a + 1, b)) != 2) and t == 1:
        l = getWaterNum(files.getBlock(a + 1, b))
        if l == 8: l = 0
        if (l < 4):
            files.setBlock(a, b, (getNumWater(blk - 1), 0))
            files.setBlock(a + 1, b, (getNumWater(l + 1), 0))
            if (a > scrn[0] and a < scrn[2]):
                if (b > scrn[1] and b < scrn[3]):
                    gui.drawBlock(a - scrn[0], b - scrn[1], a, b)
                    gui.drawBlock(a - scrn[0] + 1, b - scrn[1], a + 1, b)
Exemple #3
0
def getWater(a, b):
    blk = files.getBlock(a, b)
    t = files.getBlockType(blk)
    blk = getWaterNum(blk)
    return blk, t
Exemple #4
0
def getBlockType(x, y):
    return files.getBlockType(files.getBlock(x, y))
Exemple #5
0
def generateWorld():
    global width, height, desert, corruption, fileName
    filledRect(screen, 0, 0, 640, 480, (0, 0, 0))
    width = files.getSetting(5)
    height = files.getSetting(6)
    fileName = "Worlds/" + randomString(8) + ".wrld"
    files.setDim(width, height)
    gnd = 50
    desert = [50, 100]
    corruption = [100, 200]
    dGnd = 0
    pgnd = [gnd] * width
    title("Generating", 0)
    title("Terraforming", 1)
    for a in range(width):
        progress(a / width, 1)
        if (a > desert[0] and a < desert[1]):
            for b in range(0, gnd):
                blk = 0
                files.setBlock(a, b, blk)
            for b in range(gnd, height):
                blk = 3
                files.setBlock(a, b, blk)
        elif (a > corruption[0] and a < corruption[1]):
            for b in range(0, gnd):
                blk = 0
                files.setBlock(a, b, blk)
            files.setBlock(a, gnd, 5)
            for b in range(gnd + 1, height):
                blk = 2
                files.setBlock(a, b, blk)
        else:
            for b in range(0, gnd):
                blk = 0
                #if (random.randint(0, 100) < 10):
                #blk = random.randint(4, 7)
                files.setBlock(a, b, blk)
            files.setBlock(a, gnd, 1)
            for b in range(gnd + 1, height):
                blk = 2
                files.setBlock(a, b, blk)
        dGnd = dGnd + random.randint(-1, 1)
        if (dGnd < -1):
            dGnd = -1
        if (dGnd > 1):
            dGnd = 1
        pgnd[a] = gnd
        gnd = gnd + dGnd
    spwnx = random.randint(files.getSetting(4) + 1, files.getSetting(4) + 51)
    spwny = 0
    while (files.getBlockType(files.getBlock(spwnx, spwny)) != 2):
        spwny = spwny + 1
    progress(.3, 0)
    title("Generating Landmarks", 1)

    for i in range(random.randint(15, 35)):
        chasmRadius = random.randint(3, 5)
        a = random.randint(corruption[0] + chasmRadius + 2,
                           corruption[1] - chasmRadius - 2)
        curRadius = chasmRadius
        chasmDepth = random.randint(25, 50)
        for y in range(pgnd[a], chasmDepth):
            for x in range(a - curRadius, a + curRadius):
                files.setBlock(x, y, 0)
            files.setBlock(a - curRadius, y, 4)
            files.setBlock(a + curRadius, y, 4)
            curRadius = curRadius + random.randint(-1, 1)
            if (curRadius < chasmRadius - 2):
                curRadius = chasmRadius - 2
            if (curRadius > chasmRadius + 2):
                curRadius = chasmRadius + 2

    for i in range(random.randint(100, 200)):
        x = random.randint(5, width - 5)
        y = random.randint(5, height - 5)
        w = random.randint(3, 5)
        h = random.randint(3, 5)
        for a in range(-w, w + 1):
            for b in range(-h, h + 1):
                files.setBlock(x + a, y + b, 6)
    progress(.6, 0)
    progress(1, 0)
    files.setSpawn(spwnx, spwny)
    files.saveWorld(fileName)
    files.prepareWorld(fileName)