Advertisement Jump to content


This topic is now archived and is closed to further replies.



This topic is 6868 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

hey all, I want to thank you on the good job you did helping me on my first programming crisis. Now i have another. I was wondering how i could make my own game function. In one of the examples it had a DoGame() and i could not get this working so could some show me how to do a prototype and then initiallize it in my program?? Thanx again, node_5r

Share this post

Link to post
Share on other sites
I''m not sure if this is what you mean, but you declare a function prototype like this, somewhere as a global (in c++, btw):

void function(params);

create it:

void function(params)

call it:


Sorry if this wasn''t what you were looking for,

Share this post

Link to post
Share on other sites
Not sure what you mean. Maybe something like:

#include <stdio.h>

void initDrivers(){
//your initialization comes here

void renderGraphics(){
//Render the scene

void playAudio(){
//Play sound and music

void renderAI(){
//Calculate all AI movements

void miscFunctions(){
//Whatever I forgot

void main(){

Now most games divide the functions up into different files for ease of programming. It is alot easier if all graphics functions are in graphics c or cpp files, while the sound functions are in sound files, etc.

Just create a file like graphics.h

In it you would include function prototypes, etc. (I prefer to use classes, although you could use the c equivilent, structs, or go global).



#include <iostream.h>

class Graphics{
int texture;
void loadTexture();
int getTexture();
void initGraphics();
void drawBackground();
void drawSprites();

//Or outside the class
void setMode(int mode);

Then in your main file, remember to:

#include "graphics.h" //Or whateever the header file is named.

Remember, none of the functions you see in other files will work unless you actually need the function and have it initialized.

One more thing I forgot. You don't have to declare functions you use if:
1) They are in the same file as where you call them.
2) They are above the functions you call them from.
And remember to return values if they need it.

int calculateFramesPerSecond(){
int FPS; //Frames per second
//do calculations here
return FPS;

Edited by - Nytegard on 3/29/00 10:02:03 PM

Share this post

Link to post
Share on other sites
Just simply:

int DoGame(); //function prototype

int main()
//do things....

return 0;

int DoGame()
//run the game here

//return success
return 1;

- Daniel

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!