do game developers build an engine, then create a new class that
inherits from engine which becomes the game?
It depends. Most of the time developers will make uses of existing game engines but sometimes they won't due to non-existence of wanted effects.
I have tried a number of different game engines. Most of them are behaving like this:
- Defining sprites and sound elements by extending the class of it's basic entities
- Defining groups for the ease of management
- Defining a room or world for interaction between IO and the sprites
- Program the logic in common functions like "update()" (the function will be called per frame)
- Modify the entrance of the program to get into the first "room" or "world" (it can be a menu)
So a game engine is mainly do jobs of defining how the screen should display in a middle-layer, and the developer no need to worry about issues like will there be too many sprites loading outside the view-port?
or When I press a key, where should the callback be located?
, `Are they entity collided?" but focus on the higher level logic of the game.