Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

where do i start in building my ultimate game ?

skeleton

where do i start in building my ultimate game ?

by  NEVERSLEEP  Posted    (Edited  )
here the skeleton i use with my vc++6 compiler

Code:
// start m_ain.h
#include <windows.h>

// fonction prototypes
int WINAPI WinMain(
   HINSTANCE hInstance,
   HINSTANCE hPrevInstance,
   LPSTR lpCmdLine,
   int nShowCmd
);
LRESULT CALLBACK WindowProc(
   HWND hWnd,
   UINT uMsg,
   WPARAM wParam,
   LPARAM lParam
);
// end m_ain.h
// start m_ain.cpp
#include "m_ain.h"

int WINAPI WinMain(
   HINSTANCE hInstance,
   HINSTANCE hPrevInstance,
   LPSTR lpCmdLine,
   int nShowCmd)
{
   HWND hWnd;
   MSG Msg;
   WNDCLASSEX wcex = { 
      sizeof(WNDCLASSEX),
      CS_CLASSDC,
      WindowProc,
      0L, 0L,
      hInstance,
      NULL, NULL, NULL, NULL,
      "GameClass", NULL };
   // register class exit on error
   if(!RegisterClassEx(&wcex))
      return FALSE;
   hWnd = CreateWindow(
      "skeleton", "the title",
      WS_OVERLAPPEDWINDOW,
      0, 0, 400, 400,
      NULL, NULL, hInstance, NULL);
   // return if error on CreateWindow
   if(hWnd == NULL)
      return FALSE;
   // show the window
   ShowWindow(hWnd, SW_SHOWNORMAL);
   UpdateWindow(hWnd);
   // Clear out message structure
   ZeroMemory(&Msg, sizeof(MSG));
   // loop until msg = exit
   while(Msg.message != WM_QUIT) {
      // peek into queue to see if there's message waiting
      if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
	 TranslateMessage(&Msg);
	 DispatchMessage(&Msg);
      } else {
	 // time-crusial stuff
      }
   }
   // unreg class
   UnregisterClass("skeleton", hInstance);
   // exit
   return 0;
}
// MSG procedure
LRESULT CALLBACK WindowProc(
   HWND hWnd,
   UINT uMsg,
   WPARAM wParam,
   LPARAM lParam)
{
   switch(uMsg) {
      case WM_DESTROY:
         PostQuitMessage(0); // close app
         break;
      // handle other mesage here
      default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
   }
   return 0;
}
// end m_ain.cpp


not much but here's my contribution [lol]

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top