コード例 #1
0
def move_down(ship, height, width, rocks, brd, c):
    remove_ship(brd, ship)
    if ship[1] == height - 2:  #can't move down
        insert_ship(brd, ship)
        return ship
    elif safe_surround(brd, ship[1], ship[0]):
        ship[1] += 1
        insert_ship(brd, ship)
        return ship
    else:
        return False
コード例 #2
0
def move_left(ship, height, width, rocks, brd, c):
    remove_ship(brd, ship)
    if ship[0] == 1:  #if after we move it there would be extra room to the left to have one more block between teh ship and the border
        insert_ship(brd, ship)
        return ship
    elif safe_surround(brd, ship[1], ship[0]):
        ship[0] += -1
        insert_ship(brd, ship)
        return ship
    else:
        return False
コード例 #3
0
def move_up(ship, height, width, rocks, brd, c):
    remove_ship(brd, ship)
    if ship[1] == 1:  #if we move the whip up there wouldn't be any room to go up anymore
        insert_ship(brd, ship)
        return ship
    elif safe_surround(brd, ship[1], ship[0]):
        ship[1] += -1
        insert_ship(brd, ship)
        return ship
    else:
        return False
コード例 #4
0
def move_right(ship, height, width, rocks, brd,
               c):  #moves the space-ship one block over to the right
    remove_ship(brd, ship)
    if ship[0] == width - 2:  #if there isn't enough room to have an extra block between the ship and the border after moving right
        insert_ship(brd, ship)
        return ship
    elif safe_surround(brd, ship[1], ship[0]):
        ship[0] += 1
        insert_ship(brd, ship)
        return ship
    else:
        return False
コード例 #5
0
ファイル: main.py プロジェクト: MowHogz/space-ship
def las(brd, height, width):
    for c in range(width):
        brd[height - 1][c] = '|'
    return 0


#time.sleep(5)
brd = con(ship, height, width, rocks)
while True:
    for i in range(rock_move):
        time.sleep(speed / 100)
        for l in range(rocket_moves):
            c = press(c)
            if keyboard.is_pressed('r'):
                las(brd, height, width)
            brd = move(ship, height, width, rocks, brd, c)
            move_lasers(brd, height, width)
            insert_ship(brd, ship)
            c = " "
        if brd == False:
            print("You Lost!")
            exit()
        Print(brd)
        if move_rocks(brd, height, width) == False:  #moves rocks
            print "haah"
            print("You Lost!")
            exit()

    insert_rock(brd, rock_gen(brd, height, width))
print("Was a great game")