I notice that the player can still go off the left/right side of the screen.
Hmm... you can put a temporary fix in update_player() to keep the player on the screen, but there's a proper fix that you'll be doing later.
What's the temporary fix?
After doing that, I can't move the player completely offscreen, but I can still move it partway offscreen.
That's because we're constraining the origin of the player, and the player's origin is the center (horizontally). Don't worry about this for now, we'll be fixing this up properly later.
Congratulations! You've have finished Stage 1 and your character has gained a level.
Before proceeding to the next stage, make a backup of your current game directory by copying it into a new directory called stage1.
Continue working in your game directory.
GOTO 020 to proceed to stage 2.