C++ custom game engine using main() without user

Started by
16 comments, last by Sneftel 15 years, 4 months ago
I am working on a game engine that has beginners ( as if total newbs ) in mind ( but not limited to! ). It is designed to be simple to implement and simple to use. I have been showing a few people ( that I know ) the engine and wanting their input. It is also open-source. Anyway, the main() function is being used by the engine already and so is the game loop ( within the main() ) The game loop directs itself to these functions: GameUpdate(), GameDraw(), and GameLoading(). All you have to do is place your wanted game objects into GameInitialze() and make sure they are deleted withing GameKill(). No int main() required. However, one of the people I showed it to mentioned that typical game engines leave out main() for the user to place. So this is where my question begins: is it wrong to do this? Coding-wise. I personally understand where he is coming from, but I also personally don't see it as a big deal. What is your opinion on the subject? Thanks. :]
Holy crap, you can read!
Advertisement
It sure makes it hard to write tool applications that compile and link against the engine code.
How long does would take you to write a main() function which does nothing but invoke the game engine.
Well, it is a game engine and not designed to make tools but I'm not saying it isn't possible to do so with it. But since it is open-source and under the Zlib license, it doesn't limit you. You have the rights to modify main() to your liking. Does this still provide a hindrance?

@Sneftel:
I am not entirely sure what you are stating.
Holy crap, you can read!
Quote:Original post by PCN
@Sneftel:
I am not entirely sure what you are stating.
If you provide main() in your engine, you're making it extremely difficult to put the engine in a DLL, or run some other sort of startup code before invoking the engine, for the minor trade off of saving the user 4 lines of code.
If you don't provide main() as part of your engine, the only down side is that the user has to write 4 lines:
int main(int argc, char** argv) {   Engine engine;   return engine.Go();}
But you're giving the user much more control.

Personally, I'd never write an engine that includes main().
Yes yes everyone, he knows, and we all know, that it is not a good programming practice!

But that's not what he is trying for, he stated it was for total n00bs. And n00bs won't be packing it into a DLL, or writing tools for it.

I understand what you're trying to do, cool idea :)
==============================
A Developers Blog | Dark Rock Studios - My Site
For noobs it should come as a DLL, they shouldn't have to do that themselves.
Quote:Original post by Wavesonics
But that's not what he is trying for, he stated it was for total n00bs. And n00bs won't be packing it into a DLL, or writing tools for it.

I understand what you're trying to do, cool idea :)


What is the first and absolutely only thing a "noob" must learn if they wish to write C/C++ code?

Variables? For loops? Functions? Or something else?
I suppose I did not make myself clear. I included main(), but it is taken over by game engine code. In main(), there are functions that direct to the given "framework". So you never have to look at main(), just the GameUpdate, GameDraw, etc. functions.

So the programmer doesn't have to write main() themselves.... at all.
My question was is this wrong to have the main() written already for users and not have it to be written.

Gah, I need to find better words to explain myself. >.>

:]
Holy crap, you can read!
What is suggested is that the Engine might have a Go() or Run() method that contains your current main, and then the user can simply only call that or do something else in main() as they like.

But I wonder, what the user has to write. What do you mean by "placing" game objects into a method and why should I look at GameUpdate etc?

This topic is closed to new replies.

Advertisement