Direct Play Tutorials?

Started by
6 comments, last by Craazer 21 years ago
I cant find tutorials for direct play... Is it becose its so difficult subject? if u know any tutorials around the net please tell!
Advertisement
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.
not too bad?

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

Owner/Leader
Genetics 3rd Dimension Development
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
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.
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.

any advice? questons?


Or maybe becose this is so easy to u, u could throw some code wich initalized dPlay?
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.



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

quote:Original post by Jim Adams
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.



Jim Adams
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.

And if some one gould give me better picture about this:

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
5) dplay ready for connection

is that it, or did i mis shometing?




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.

This topic is closed to new replies.

Advertisement