Several times in the past I've tried to go the route of designing an engine and a game... usually it starts to work at first, but then gets really complicated as unexpected things pop up.
Currently, I'm writing a
game, and I'm doing my best to keep my code clean and concise. As I'm writing the game, I see logically how it's separating into three different types of code: general code, genre-specific code, and game-specific code. So I then separate those types of code into three different folders (which I call, 'Common', 'Engine', and 'Game', respectively).
As I'm writing my game, the engine falls out of it if the game is coded well. If the game isn't coded well, me trying to make an engine will result in an engine that isn't coded well and can't be used anyway.
Your solutions are:
1) Code a game poorly.
Result: You have a completed game.
2) Code an engine poorly, and a game alongside it.
Result: [color="#1C2837"]You have a not-working engine, and stop working on the game, because the engine doesn't work.
[color="#1C2837"]
3) Code a game properly.
Result: You have a completed game... and a completed engine that pops out of nowhere!
[color="#1C2837"]
4) Code an engine properly.
Result: You have an completed engine. But to code an engine properly, you have to have experience coding a finished game properly in the past anyway, so you are probably a professional already.
[color="#1C2837"]The game to learning how to make good game engines in the future is to make good games in the present. If you aren't focusing on the game, then all you are doing is making a fancy API by wrapping whatever API you are already using.
[color="#1C2837"]
Also i have a question about collision... I don't know when to check for collision, I guess i'd have to check inside the main loop if all the sprites in the game are solid and if they are solid if they are colliding with each other OR with the tiles wich are solid... because if i just check for collision on a key down for example, i'm only checking for the player and I want to check for the enemies also...[/quote]
[color="#1C2837"]After a keypress, call something like Player->Move(). After the AI thinks, the AI calls something like Enemy->Move(). The 'Move()' function could check for collision, not the keypress handling function.
[color="#1C2837"]But that looks like it's gonna eat too much cpu[/quote]
[color="#1C2837"]If your CPU can run advanced 3D games from two or three years ago, why worry about a few 2D images like what they used to make 20 years ago?
[color="#1C2837"]It can handle your game. Only start optimizing your game when your game drops below 20 frames per second. Otherwise, wait until your game is
[color="#1C2837"]complete, then optimize it using a proper profiler, not guesswork.
[color="#1C2837"][color="#1C2837"]And that's the basic structure (wich is probably bad), what do you think?[color="#1C2837"][/quote]
[color="#1C2837"]Don't second guess yourself or put yourself down. Just run hard, and when you hit a wall, dust yourself off and run again.
[color="#1C2837"]It's good to have something to run toward, though, otherwise you are running at the wrong goal. Making an engine, even for learning, isn't the best goal. It's an 'acceptable' goal, but a better goal is to make a game. Simple and friendly advice that a lot of people are offering you - you can accept it, reject it, or store it away for later, it's your call!
[color="#1C2837"]
[color="#1C2837"]I fully understand the desire to make an engine because it sounds so cool. Just don't let it stop you from making your game; and if you fail, don't let it stop you from picking yourself up again, and if you succeed, don't let it go to your head.