Compare commits

..

1 Commits

Author SHA1 Message Date
KikooDX 2ede62ba9a Added usefull state information to "draw_score" 2020-09-26 22:57:19 +02:00
2 changed files with 6 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 37 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(state):
def draw_score(score):
global canvas
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')
canvas.create_text(4, screen_h + 52, anchor = NW, text = f'score: {score}, state[7]: {state[7]}, state[6]: {state[6]}', fill = 'black')
def fix_angle(a):
return a * 2 * asin(1) / pi
@ -153,7 +153,6 @@ 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
@ -170,11 +169,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
break
return
l -= .25
state[6] += (state[6] < 200)
state[0:2] = (x, y)
draw_line(start[0] * zx, start[1] * zy, state[0] * zx, state[1] * zy, color)
draw_line(state[3] * zx, state[4] * zy, state[0] * zx, state[1] * zy, color)
def aller_selon(path):
global state
@ -190,6 +189,7 @@ 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)
draw_score(state[5])
aller_selon(path)