Compare commits

...

5 Commits

Author SHA1 Message Date
Pavel 9729a067a4 update labygui.png 2020-09-30 13:19:33 +02:00
Pavel 728b83ad37 optimize line drawing 2020-09-29 12:41:18 +02:00
Pavel 4d63c812a2 remove pass 2020-09-27 21:20:16 +02:00
Pavel 43ab3915d0 set score format to %18.14f 2020-09-27 19:04:10 +02:00
Pavel 2a5e6fc59d add state[6] and state[7] to draw_score 2020-09-27 14:32:40 +02:00
2 changed files with 6 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -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)