W
W
Workguy2020-12-25 12:47:02
Python
Workguy, 2020-12-25 12:47:02

The program does not want to run?

I need the "finish" cycle to start immediately after the snake reaches the field boundaries, but this does not happen, i.e. the "finish" loop does not start itself, but only after I perform some action (press any key, etc.) Here is the code itself:

# What we are doing if we have collision
      if snake_x >= 1051 or snake_x <= 209 or snake_y >= 841 or snake_y <= -1:
         # starting "game over" loop
         finish = True

      while finish:
         window.fill((0, 0, 0)) ...

Please tell me what I am doing wrong or maybe what I am NOT doing.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gromyko21, 2020-12-25
@gromyko21

# What we are doing if we have collision
      if snake_x >= 1051 or snake_x <= 209 or snake_y >= 841 or snake_y <= -1:
         # starting "game over" loop
         finish = True

         while finish:
            window.fill((0, 0, 0)) ...

put a while inside an if

S
SunnyWolf, 2020-12-26
@NEDOprogrammer

def finish():
   while finish:
       window.fill((0, 0, 0)) ...

Maybe it will work
And well, yes, and then
call a function
finish()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question