How would you make an enemy move left to right and go the opposite direction when hitting a wall, like a goomba from Super Mario?
Good question! There are a couple ways to do this.
The simplest method is to use the “bounce on wall” flag for sprites:
However, this isn’t true “goomba” behavior because it won’t work for sprites that have gravity. In mario, goombas fall down when they walk off a ledge. To copy that behavior, we can use an “on hit wall” event instead:
There are comments in both those example that explain the code!
Thank you, this helped a lot