Making of LLemMings

Collisions and movement

ChatGPT: New prompt for collision detection and lemming movement

>>> Prompt: Modification of a previous prompt
...
It should move around on a 2d canvas which has gravity (that is, when there is no ground under it,
it should fall down). If it runs in to an obstacle on the x axis (or the edge of the canvas) it should
turn around and walk the other way. The ground (dirt and rock) can be a bit hilly,
so there should be some fuzziness in the collision check so that it only stops when it runs into a
high obstacle. If it falls into something on the y axis it should stop moving on the Y axis and start
walking on the x axis. If it falls into the water or went outside of canvas, the lemming is dead.
Updates should be done every frame. There will eventually be many lemmings, so do note that they are
not controlled by keys, they move by themselves and is constrained by the collision rules outlined above.

It is important that you use the declared things I mentioned above and just give me the code with
minor comments -- be brief, don't explain anything in plain text.
...