Jump to content

  • Log In with Google      Sign In   
  • Create Account

gameloop


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 JL   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 June 2001 - 06:20 AM

Hi I want anyone to write a simple game/message-loop for me in VC++. I have tried lots of times, but I can''t get ahead with it. If I use GetMessage the loop waits for message to be retrieved, if I use PeekMessage the loop does''nt retrieve any message. This is the problem I got, the loop works well else. function updateFrame() is processed in the loop, where the objects is showed and their positions is changed. Please help me with this! Thanks /J Lindroos

Sponsor:

#2 rollinr33   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 June 2001 - 07:12 AM

this is what my loop looks like:

//all other initialization here
while(1)
{
int t = PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
if (t)
{
if (!GetMessage (& msg, NULL, 0, 0))
return msg.wParam;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
else if (ActiveApp)
{
//PROCESS ALL INPUT HERE
//DRAW ALL GRAPHICS HERE
}
else if (!ActiveApp)
WaitMessage();
}
}
//end of the program here
is that what you wanted? if so i hope that helps, later

#3 Coleco   Members   -  Reputation: 164

Like
Likes
Like

Posted 23 June 2001 - 09:15 AM


//-----------------------------------------------------------------------------
// WINMAIN
//-----------------------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{

WNDCLASS winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
//HDC hdc; // generic dc
//PAINTSTRUCT ps; // generic paintstruct

// first fill in the window class stucture
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;

// register the window class
if (!RegisterClass(&winclass))
return(0);

// create the window, note the use of WS_POPUP
if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class
"LINK Game Engine", // title
WS_POPUP | WS_VISIBLE,
0,0, // x,y
WINDOW_WIDTH, // width
WINDOW_HEIGHT, // height
NULL, // handle to parent
NULL, // handle to menu
hinstance, // instance
NULL))) // creation parms
return(0);

// save the window handle and instance in a global
main_window_handle = hwnd;
main_instance = hinstance;

// perform all game console specific initialization
gameInit();

// enter main event loop
while(1)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
// test if this is a quit
if (msg.message == WM_QUIT)
break;

// translate any accelerator keys
TranslateMessage(&msg);

// send the message to the window proc
DispatchMessage(&msg);
} // end if

// main game processing goes here
gameMain();

} // end while

// shutdown game and release all resources
gameShutDown();

// return to Windows like this
return(msg.wParam);
} // end WinMain


-Coleco

~ c o l ec o ~



Rock the cradle of love!
You stupid WANKER!
S i g n a l D E V .com

--HASBRO SUCKS--

#4 JL   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 June 2001 - 06:25 AM

OK, thanks guys, I think you have helped me a lot, I''ll reply if I will get any problems when tested.

Best Regards
/J Lindroos

#5 AynRand   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 June 2001 - 03:25 PM

I hope you know Windows Programming...

---------------------------------------
"When I lie, I am telling the truth"


#6 JL   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 June 2001 - 02:11 AM

I am in the start but I know what I need to know.
I know how to do the messageloop, but when it came to the game everything stopped to work.

Both your loops worked, so thanks guys!
Best Regards
/J Lindroos





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS