snake_move #16
2
App.py
2
App.py
@ -41,7 +41,7 @@ def init_demo(): #Demo purpose
|
|||||||
bfsRoot.reverse()
|
bfsRoot.reverse()
|
||||||
print(bfsRoot)
|
print(bfsRoot)
|
||||||
# ui.render_text(string_to_print="traktor porusza się ścieżką bfs")
|
# ui.render_text(string_to_print="traktor porusza się ścieżką bfs")
|
||||||
traktor.move_by_root(bfsRoot, pole, traktor.irrigateSlot)
|
traktor.move_by_root(bfsRoot, pole, [traktor.irrigateSlot])
|
||||||
start_flag=False
|
start_flag=False
|
||||||
# demo_move()
|
# demo_move()
|
||||||
old_info=get_info(old_info)
|
old_info=get_info(old_info)
|
||||||
|
@ -207,15 +207,18 @@ class Tractor:
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
quit()
|
quit()
|
||||||
def move_by_root(self, root, pole, action):
|
def move_by_root(self, root, pole, actions = None):
|
||||||
for move in root:
|
for move in root:
|
||||||
|
self.slot.redraw_image()
|
||||||
if move == 'forward':
|
if move == 'forward':
|
||||||
self.move_forward(pole)
|
self.move_forward(pole)
|
||||||
if move == 'right':
|
if move == 'right':
|
||||||
self.turn_right()
|
self.turn_right()
|
||||||
if move == 'left':
|
if move == 'left':
|
||||||
self.turn_left()
|
self.turn_left()
|
||||||
action()
|
for a in actions:
|
||||||
|
a()
|
||||||
|
|
||||||
self.clock.tick(3)
|
self.clock.tick(3)
|
||||||
|
|
||||||
#to tak zrobiłam już na później, może się przyda
|
#to tak zrobiłam już na później, może się przyda
|
||||||
|
Loading…
Reference in New Issue
Block a user