forked from Pavel/labygui
Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Pavel | 9729a067a4 | |
Pavel | 728b83ad37 | |
Pavel | 4d63c812a2 | |
Pavel | 43ab3915d0 | |
Pavel | 2a5e6fc59d |
BIN
labygui.png
BIN
labygui.png
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 36 KiB |
12
labygui.py
12
labygui.py
|
@ -127,9 +127,9 @@ def draw_path():
|
|||
y = 16
|
||||
canvas.create_text(4 + (i % 12) * 80, screen_h + 4 + y, anchor = NW, text = '(%5.2f, %3.1f)' % path[i], fill = color)
|
||||
|
||||
def draw_score(score):
|
||||
def draw_score(state):
|
||||
global canvas
|
||||
canvas.create_text(4, screen_h + 52, anchor = NW, text = 'score: %f' % score, fill = 'black')
|
||||
canvas.create_text(4, screen_h + 52, anchor = NW, text = 'score: %18.14f (state[6]: %5.1f, state[7]: %5.1f)' % (state[5], state[6], state[7]), fill = 'black')
|
||||
|
||||
def fix_angle(a):
|
||||
return a * 2 * asin(1) / pi
|
||||
|
@ -153,6 +153,7 @@ def tourner(a):
|
|||
|
||||
def avancer(l, color):
|
||||
global state
|
||||
start = state[0:2]
|
||||
t = fix_angle(state[2])
|
||||
dx, dy = cos(t), sin(t)
|
||||
state[7] += l
|
||||
|
@ -169,11 +170,11 @@ def avancer(l, color):
|
|||
t = dx <= 0 or int(x) < laby_w - 1 or int(y) < laby_h - 1
|
||||
if t and tx or ty or (drx and dry and (t and tx or ty)) or (drx and dry and (t and vw(iy, laby_w - 2 - min(ix, ix - drx)) or hw(min(iy, iy - dry), laby_w - 1 - ix))):
|
||||
state[5] += 15
|
||||
return
|
||||
break
|
||||
l -= .25
|
||||
state[6] += (state[6] < 200)
|
||||
state[0:2] = (x, y)
|
||||
draw_line(state[3] * zx, state[4] * zy, state[0] * zx, state[1] * zy, color)
|
||||
draw_line(start[0] * zx, start[1] * zy, state[0] * zx, state[1] * zy, color)
|
||||
|
||||
def aller_selon(path):
|
||||
global state
|
||||
|
@ -189,7 +190,6 @@ def aller_selon(path):
|
|||
if y < laby_h:
|
||||
draw_rect(x * zx, y * zy, zint, zy + zint, 'black')
|
||||
else:
|
||||
pass
|
||||
draw_rect(x * zx, (y - laby_h + 1) * zy, zx + zint, zint, 'black')
|
||||
for i in range(len(path)):
|
||||
tourner(path[i][0])
|
||||
|
@ -201,7 +201,7 @@ def aller_selon(path):
|
|||
state[5] += sin(fix_angle(state[7])) - state[6] // 2
|
||||
draw_help()
|
||||
draw_path()
|
||||
draw_score(state[5])
|
||||
draw_score(state)
|
||||
|
||||
aller_selon(path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue