0

I just got into coding and I started off learning with scratch and now I'm trying to learn python by making my scratch game on python. The game I'm trying to make is basically where a character is inside a map and they have to dodge the enemy to get to the finish line. What I'm trying to figure out is how I can make my character's position reset if it hits the color green on the map. For example, on scratch it has a feature like "if touching color green then go to x y position". Is it possible to implement a similar feature on python or have a boundary on that letter so the character can't go outside the letter A on the map? [1. Picture of the map (the character is the mouse) ]: https://i.stack.imgur.com/1dCCA.png [2. Picture of the code in scratch]: https://i.stack.imgur.com/MkH11.png

Fahmi
  • 1
  • pygame rather use rectangle regions to detect collisions. It has `pygame.Rect` which has `colliderect()` or `collidepos()` to check collision with other rectagle (other player/object) or with point (i.e. mouse). You will have to write own method to detect it. Eventually pygame has method to use `black&white` bitmaps to detect collisions and you would have to create image with black instead of green. See doc: [mask](https://web.archive.org/web/20220117140701/http://www.pygame.org/docs/ref/mask.html) – furas Mar 14 '22 at 03:07

0 Answers0