Feb-15-2020, 06:48 PM
Line 68 is giving you trouble. If you want to go this route you'll need to make this a lot more complex.
The real solution to the problem is to use the pygame sprite class for your player and walls. Then it is easy to see if they hit and to stop your player from moving.
Here is a tutorial for pygame:
https://www.youtube.com/watch?v=3UxnelT9...5EMxUWPm2i
Here is a simpler one that used the Turtle module.
https://www.youtube.com/watch?v=inocKE13...q9RzORkQWP
Both these will show you how to draw your map with a .txt file, which you will find a lot better and easy to modify. Moreover, if you want enemies in your game or shooting, your will have a hell of at time without using some of these other tools.
if x >= 140 and x <= 340 and y <= 260 and y >= ?????..... etc, etcbasically, outer boundaries are easy to do this way because you only come at them from one side. The way you are doing it, you'll basically have to write big ifs for every side of every object.
The real solution to the problem is to use the pygame sprite class for your player and walls. Then it is easy to see if they hit and to stop your player from moving.
Here is a tutorial for pygame:
https://www.youtube.com/watch?v=3UxnelT9...5EMxUWPm2i
Here is a simpler one that used the Turtle module.
https://www.youtube.com/watch?v=inocKE13...q9RzORkQWP
Both these will show you how to draw your map with a .txt file, which you will find a lot better and easy to modify. Moreover, if you want enemies in your game or shooting, your will have a hell of at time without using some of these other tools.