Beispiel #1
0
choice = 1
if choice == 1:
    # how many squares
    w = 32
    h = 32
    size = w * h
    grd = Grid.Grid(width=w, height=h)  # create a grid object
    # snk index related to the actual snake index so we don't want shifts when some are deleted hence its a dictionary
    snk = {}
    snakec = 0  # snake count
    while snakec < 4:  # create 4 snakes
        ran = random.randint(0, size - 1)
        if grd.show(
                ran
        ) == 0:  # if there is something there it will not generate it helps with over crowding
            snk[snakec] = Snake.Create(grd, headpos=ran, key=snakec)
            snakec += 1

    # all object are treated equally and so they to get a dictionary
    fod = {}
    foodc = 0  # food count
    while foodc < 10:  # create 10 apples
        ran = random.randint(0, size - 1)
        if grd.show(ran) == 0:
            fod[foodc] = Food.Create(grd, index=ran, key=foodc)
            foodc += 1

world_counter = 0  # basically a global counter used for refreshing at different rates and other stuff

# by map it means the world map
map = Output.Table(root, grd, w, h, siz=800 // h)