system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: What is a game engine?
gpt
Let's say you're making the game Super Mario Brothers.

You start writing the code for level 1-1. You write code to add some blocks where they go, put a goomba in, put the pipes, etc. Then you write code to keep track of where Mario is, how he jumps, and what to draw on the screen depending on where he is. Awesome, level 1-1 is working perfectly.

Now it's time for level 1-2. Hmm...well this level also has blocks, and goombas, and pipes. So I'll just copy the code from level 1-1 and paste it here. And Mario still moves around and jumps, so I'll copy that code too. Now level 1-2 is working. We're making great progress. Sure, 90% of the code here is the same as from level 1-1, but it works so we won't worry about it.

Now we've done this for a lot of levels. We have worlds 1 through 4 done! But uh oh, we just discovered a bug in the code that makes mario move around. And we've copied this code into all 16 levels we've coded. Ok, so we'll just go through all of them and fix the bug. That's kind of tedious, but it works.

Then someone else comes along with a brilliant idea. What if instead of writing separate code for all our levels, we made up a way to put how a level looks into a text file. Like maybe one line would be "block 23 9" which means that on the 23rd column of our level, there's a block 9 squares above the ground. Now we can save all our levels in files, and then just write code once that will load the file for a level, then draw that level, control how Mario moves around in it and jumps, and all of that. We don't have to copy and paste it for each level anymore, we only have to fix bugs we find in one place.

What we've just created is the game engine for Super Mario Brothers.