Archived

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

Direct Play Tutorials?

This topic is 5737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I cant find tutorials for direct play... Is it becose its so difficult subject? if u know any tutorials around the net please tell!

Share on other sites
well...

DirectPlay is more complicated than other DirectX APIs... But the documentation is not so too bad...
All I can advise you (in fact, I did that) is to follow the steps of the source codes of the samples, and look at the tutorials, so that you can see how it is actually implemented.

I think you should try to look at the samples that match best with your project, that work in console mode... they are much easier to understand.

Share on other sites

hahahaha, read it again, because it doesnt tell you half the crap

the sdk says you gotta enumhosts to find a host, and make the address object, but in an example, you can just pass

DP8SP_TCPIP

and thats all you need

there are several events that go unexplained, example:

DirectPlay8Event_CreatePlayer

Description: Called when a player is created.

NO DUH! Yet none of the directplay class have a "createplayer" function, nor does any of the function say "this will call CreatePlayer on the other end"

Lovely job microsoft, do me a favor and document my next game so half the players will be lost while playing.

--Fireking

Genetics 3rd Dimension Development

Share on other sites
DPlay isn''t so difficult. I have learnt and successfully implemented it in about two months and my game is running well. I use DP4. I agree with anonymous poster) follow examples and try to rewrite it. I do it and it works.

Share on other sites
Well thats what i have done, readed the sambles.

But so far i havent been aple to connect my application.. i mean i cant host and find games becose pDP->InitializeConnection()
fails. And the fail reason is INVALIDPARAMS and like u might ques i dont now what is wrong. (not that i would now what invalidparams is)

So maybe u can help whit this?

Only thing what i have done is enumrated connections and butted them to combobox

  // Initialize the COM library	hr = CoInitialize( NULL );	hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER, 						   IID_IDirectPlay4A, (VOID**)&pDP );pDP->EnumConnections( NULL, EnumSP, hwnd, 0 );// so far everything works...//connections are now in comboboxInitializeConnection(); //my function look down		CoUninitialize();//// functionsBOOL FAR PASCAL EnumSP( const GUID* pSPGUID, VOID* pConnection,DWORD dwConnectionSize, 					   const DPNAME* pName, DWORD dwFlags, VOID* pContext ){// this is copyed and pasted function fron the sambles !!!!!	HWND	hWnd = (HWND)pContext;	LRESULT iIndex;	GUID*	pGuid;	// Store service provider name in combo box	iIndex = SendDlgItemMessage( hWnd, IDC_SPCOMBO, CB_ADDSTRING, 0, 								 (LPARAM)pName->lpszShortNameA );	if( iIndex == LB_ERR )		return TRUE;	// Make space for service provider GUID	pGuid = (GUID*)GlobalAllocPtr( GHND, sizeof(GUID) );	if( pGuid == NULL )		return TRUE;	// Store pointer to GUID in combo box	*pGuid = *pSPGUID;	SendDlgItemMessage( hWnd, IDC_SPCOMBO, CB_SETITEMDATA, (WPARAM)iIndex,		                (LPARAM)pGuid );	return TRUE;}HRESULT InitializeConnection(){        VOID*   pConnection = NULL;    LRESULT iIndex;    HRESULT hr;    GetDlgItemText(hwnd, IDC_PLAYER_NAME_EDIT, strLocalPlayerName, MAX_PLAYER_NAME );    HWND hWndCombo = GetDlgItem(hwnd, IDC_SPCOMBO );    iIndex = SendMessage( hWndCombo, CB_GETCURSEL, 0, 0 );	iIndex=3; ///////////// this is 3 becose only serial cable are suported... for testing    SendMessage( hWndCombo, LB_GETTEXT, iIndex, (LPARAM)strPreferredProvider ); /// ???    pConnection = (VOID*) SendMessage( hWndCombo, CB_GETITEMDATA, iIndex, 0 );	    // Release previously selected DirectPlay object, if any.    SAFE_RELEASE( pDP );    // Create the DirectPlay object    if( FAILED( hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_ALL,                                        IID_IDirectPlay4A, (VOID**)&pDP ) ) )	{        ErrorBox("CoCreateInstance( CLSID_DirectPlay, ... ",hr);        return hr;    }    // Initialize the connection based on the selected connection type    if( FAILED( hr = pDP->InitializeConnection( pConnection, 0 ) ) )	{            // this fails!!!!!!!!!!!!! //INVALIDPARAMS !!!!!!!!!!!!!!!!!!!!!		ErrorBox("pDP->InitializeConnection ",hr);        return hr;	}	return DP_OK;}

So there was some of the code in my application, well all of the parts what worked but after i dont know what to do.

oh and note that code wasnt exactly like that my app and some carpage might be there but u should get the picture what im doing.

Or maybe becose this is so easy to u, u could throw some code wich initalized dPlay?

Share on other sites
As most people have pointed out, the DX SDK is the best source for examples using DirectPlay. I learned everything from the samples and documents, and had enough knowledge from there to write a book with DP in it (with a client/server game engine).

Now, with the ''tudes aside, what EXACTLY do you need help with. Please don''t say write a DP server for you, but a little more specific like the client object init functions, creating a message function, etc. From there, we can point you directly to the DX SDK help or a sample that shows how.

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Share on other sites
quote:
As most people have pointed out, the DX SDK is the best source for examples using DirectPlay. I learned everything from the samples and documents, and had enough knowledge from there to write a book with DP in it (with a client/server game engine).

Now, with the ''tudes aside, what EXACTLY do you need help with. Please don''t say write a DP server for you, but a little more specific like the client object init functions, creating a message function, etc. From there, we can point you directly to the DX SDK help or a sample that shows how.

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Yes i try to learn from the sambles but now i have encounter a problem so thats why i pasted some code above so somebody could say what wrong whit pDP->InitializeConnection function why doest it fail.

1) initialize guid
2) enumerate connection types
3) choose one do i have to enumerate baund speeds ports etc?
4) initialize dplay and connection guids

is that it, or did i mis shometing?

Share on other sites
CoCreateInstance(CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC, IID_IDirectPlay8Client, (void**)&pDPClient);

Fails! Any good way of debugging it, becuase even if it try to step into it it just jumps over it.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633701
• Total Posts
3013442
×