Advertisement

Game Console Programming

Started by April 22, 2002 02:47 PM
8 comments, last by Wachar 22 years, 7 months ago
In Tricks of the Windows Programming, there is a part of the book which confuses me. Does the Win32 API program automaticall read Game_Main, Game_Init, and Game_Shutdown? ---------------------- Always will be smarter than you, --=ME=-- ----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
Without having read the book I would say: No, those functions will not be called automaticly.

// Dalle
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Advertisement
No, all those functions are called inside Winmain, its something like
    WinMain(...){Game_Init()     ;while(1){if(PeekMessage(lpMsg,hWnd,0,0,PM_REMOVE)){TranslateMessage(lpMsg);DispatchMessage(lpMsg);if (lpMsg->message==WM_QUIT) break;}else Game_Main()      ;}Game_ShutDown()    ;}       


this is from memory, but I am pretty sure its something like that.

Edit: Darn its hard to get the font color right




[edited by - kwizatz on April 22, 2002 4:55:00 PM]
Well, yeah, it''s supposed to be in WinMain() . BTW, HOW do you change fonts and colors?

[bold]Test[/bold]

----------
Windows is superior to Macs!!!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
Darn!

----------
Windows is superior to Macs!!!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
So, those functions are automatically called in WinMain()??

----------
Windows is superior to Macs!!!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
Advertisement
about fonts: you are allowed to use some html tags on your posts I just used a <font color="#ff0000"></font> tag.

About winmain:
they are NOT automatically called, you have to put them there, thats the purpose of the colors, so you see the where the functions are called, in case you are a total newbie, words of advice, learn some C/C++ before getting deep inside tricks of the windows game programming gurus, it will save you some frustration, believe me.

now to the point:

once you write your function:

        void somefunction(){printf("Hello!\r\n");}  you can call said function from anywhere in your code:      int main(){somefunction();}      


thats how it works, the functions Game_Init,Game_Main and Game_Shutdown are User Defined Functions
you MUST call them inside winmain at some point if you want them to execute, it is not "automatic".

[edited by - kwizatz on April 23, 2002 12:33:35 PM]
I know. I meant if it was called automatically, without declaring it in your code first. I didn''t know if you had to define it somewhere like: void Game_Main(); .



----------
Windows is superior to Macs!!!
----------
Wachar's Eternity <-<-<-<-<- Me own site!
if you define your functions before they are called then you dont need to declare them, but I find that declaring and then defining is a good practice.

example:

Right:

  void myfunc();int main(){myfunc();return 0;}void myfunc(){...}  


Acceptable for the compiler:

  void myfunc(){...}int main(){myfunc();return 0;}  


Completelly wrong, wont even compile:

  int main(){myfunc();return 0;}void myfunc(){...}  


in the last example main wont know there is a function named myfunction and the compiler will complain about it even if the function is there after main.
Oh, I see. Thanks for clearing that up!

----------
Take it to the Xtreme!
----------
Wachar's Eternity <-<-<-<-<- Me own site!

This topic is closed to new replies.

Advertisement