Aug-14-2019, 07:44 AM
(Aug-13-2019, 10:38 AM)Windspar Wrote: Also could just do this.
def can_move(x, y): if 0 <= x < 4 and 0 <= y < 4: return True return False # in event loop if event.key == pygame.K_LEFT: if can_move(x - 1, y): x -= 1
or
# in event loop if event.key == pygame.K_LEFT: if 0 <= x - 1 < 4: x -= 1
Thank you. I'll try it, but I still have got this problem, I've mentioned above.:
every time I run the code, Python crashes. Eh...yeah. Python crashes. When I'm running other Pygame-Projects, it's not crashing. I ran your code a few times, and the first few times, Python just crashed. I tried it again and then it was not crashing anymore, but just nothing happened (I didn't got an error message).
Thanks for the help, but still not working.
Edit: I just imported pygame. So above the code, I just have the lines:
import pygame
and
pygame.init()(But I'm not sure, if I really need the pygame.init()).
If somebody helps me with this, I'll be able, trying your code.