Jump to content
  • Advertisement
Sign in to follow this  
Maverick Programmer

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

This topic is 3511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. :]

Share this post


Link to post
Share on other sites
Advertisement
How long does would take you to write a main() function which does nothing but invoke the game engine.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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. >.>

:]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!