0

I am 2th grade student. I have a question about one of my assingments. I need to make a maze game in pygame but I cannot find an effective way to forbid my charater to pass through the walls. Here is my background photo:

How can I add these walls as blocks to my script?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 2
    *"How can I add these walls as blocks to my script?"* - Can you show the relevant code of your script? Please read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – Rabbid76 Jan 06 '21 at 19:02
  • You can calculate, if your movement will intersect with one of those lines – user8408080 Jan 06 '21 at 19:04
  • Actually I just create the player character walking around. I could not do anything about the maze part – Kemal Ayhan Jan 06 '21 at 19:04
  • 1
    Also, I'm pretty sure you meant to say 12th grade, not 2th grade. – M-Chen-3 Jan 06 '21 at 19:06
  • Yes, it had to be 12th – Kemal Ayhan Jan 06 '21 at 19:10
  • Should I enter every line's x and y coordinate and then calculate if x of player intersect with any of line's ? – Kemal Ayhan Jan 06 '21 at 19:11
  • the players position can not intersect a line, his movement vector can – user8408080 Jan 06 '21 at 19:17
  • Some examples: [Adding collision to maze walls](https://stackoverflow.com/questions/55833941/adding-collision-to-maze-walls/55837809#55837809) / [How to implement barriers to stop the player moving through walls](https://stackoverflow.com/questions/65124664/how-to-implement-barriers-to-stop-the-player-moving-through-walls/65130719#65130719) – Rabbid76 Jan 06 '21 at 20:00

0 Answers0