Results 1 to 4 of 4

Thread: Message loop, Dx, menu/startup screen

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Message loop, Dx, menu/startup screen

    Hi all. I've got the basics of my game sorted now. So i've decided that i now need a startup screen (the main reason being that the loading time so gonna be significant once i implement my next bit). If i make a startup screen, then i can have a nice progress bar for the loading.

    Currently i'm spawning a window, initalizing DX, then entering the message/game loop straight away.


    I'm just curious as to how everyone else handles things like loading/menu screens.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    In most of my game I am displaying it right before the function (call it what ever you want) where I load all the pictures and sounds and so on into memory, and are making all the objectst that I need. So in between of all the loading of the pictures, I update some sort of progres bar, and update the screen. That way it always need some teaking when you add some more to be loaded, But that is at least the way I have done it untill today.

    Not sure if I have any good idea on how to update the progress bar, if there is some loading like making a terrain that will probably only be one function call.

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for the reply.

    This is what my game's main startup and loop look like:
    Code:
    ShowWindow( g_hWnd, nCmdShow );
    UpdateWindow( g_hWnd );
    InitDX();
    
    while( uMsg.message != WM_QUIT )
    {
    	if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
    	{ 
    	    TranslateMessage( &uMsg );
    	    DispatchMessage( &uMsg );
    	}
            else
            {
    	    GameThink();
    	    while(GetTickCount() < LastThink+10);
    	    LastThink = GetTickCount();
    	    Render();
    	}
    }
    If i were to add a progress indicator to the window, updating it as needed, wouldn't i have to be processing it's messages, as well as doing the loading?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I've had a search, and have decided to use multithreading.

    Here's the code i'm now using:
    Code:
    bool IsLoaded
    void LoadingThread(void)
    {
    	Sleep(5000);
    	InitDX();
    	IsLoaded = true;
    }
    
    //In WinMain function:
    IsLoaded = false;
    ShowWindow( g_hWnd, nCmdShow );
    UpdateWindow( g_hWnd );
    HANDLE hLoadingThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)LoadingThread, 0, 0, 0); //Make a thread for loading
    while( uMsg.message != WM_QUIT )
    {
    	if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
    	{ 
    		TranslateMessage( &uMsg );
    		DispatchMessage( &uMsg );
    	}
            else
    	{
    		if(IsLoaded)
    		{
    			GameThink();
    			while(GetTickCount() < LastThink+10);
    			LastThink = GetTickCount();
    			Render();
    		}
    		else
    		{
    			//Update progress etc...
    		}
    	}
    }
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width