Mathematical Puzzle. The Monster and the Swimmer

I want to make a game on GDevelop that looks similar to the famous mathematic puzzle. The puzzle consists on the player swimming on a perfect circular shaped like lake and having a monster chasing the player around the shore, ready to eat the player when it gets near to the shore, so the player must get to the shore without being catch by the monster. The problem is that the monster can’t swin, but run on the land exactly 4 times faster than the player swins on the water, and will always try to stop the player for going to the shore safely first, so the player must use a strategy.
You can see a simple explanation of this puzzle here Can You Escape The Goblin? [Math Puzzle] - YouTube
and the code of the guy who made the game on Python here GitHub - HackerPoet/GoblinEscape: Simple python game to avoid a goblin

I tried to look on the Python code, but I don’t know Python, so I couldn’t make much of it
Can someone help me reproduce this on Gdevelop?
I already make the player move, win, lose, and restart the game, I just need that the monster try to chase him on that circular way he was supposed to do.
And please, if someone can help me using the put object around position function it would be easier for me.
Thanks!

More than Python, it’s math wizardry. :smile:
The part dealing with the monster chase is under “def updateGoblin():”
It uses the math tool “atan2” which GDevelop has too, but I just don’t know how this magic works. :blush:

Regarding Put an object around position, you pick an object, you pick a position (X/Y), in your case the center of the lake, you pick a distance, in your case the radius of the lake, and you pick an angle, the tricky part. :sweat_smile:
If you’re not a math buff, I think you can create an arrow at the center of the lake that you rotate towards the swimmer, and you use that arrow’s angle to decide whether to increase or decrease the angle of the monster. :thinking:

1 Like

heyy
How I didn’t thought on that sooner??
Thanks Gruk, that is brilliant!
I used an object at the center of the lake to calculate the distance between the swimmer to the center of the lake, so I can make the player win, so I don’t how I didn’t thought on this before, it was so obvious.
Thanks a lot, it worked here ^^

1 Like