robutek.py 477 Bytes
Newer Older
Mareš Martin's avatar
Mareš Martin committed
1
2
3
4
5
#!/usr/bin/env python3

x, y = 0, 0
dx, dy = 1, 0

cermak's avatar
cermak committed
6
7
def fKROK():
    global x,y,dx,dy
Mareš Martin's avatar
Mareš Martin committed
8
9
10
    x += dx
    y += dy

cermak's avatar
cermak committed
11
def fVLEVO():
Mareš Martin's avatar
Mareš Martin committed
12
13
14
    global dx, dy
    dx, dy = -dy, dx

cermak's avatar
cermak committed
15
16
17
commands = {
    "KROK": fKROK,
    "VLEVO": fVLEVO
Mareš Martin's avatar
Mareš Martin committed
18
19
20
}

while True:
cermak's avatar
cermak committed
21
22
23
24
25
26
27
28
29
    prikaz = input("Zadej příkaz:")
    if not prikaz:
        break
    if prikaz in commands:
        commands[prikaz]()
    else:
        print("Nerozumím")
    print(f"Karel je na {x=} a {y=}, kouká se směrem ({dx},{dy})")
print("KONEC")