That might depend on what you are used to. And an other thing is what you are doing...If you are doing a game or something in DX then it would probably be more natural to use DirectPlay...but if you are not using DX then it would probably be more natural to use Winsock...(And then the user don't have to have DX installed )
In that case...
My game isn't using any DX except for DirectSound.
I think I'll use winsock. I very used to it.
I thought DPlay is easier and better...
DirectPlay is much easier in my opinion as it's more object oriented and easier to understand. A lot of the work is done for you. Since you're using DirectSound it's going to require DirectX anyway.
Ok...
In that case: Does anyone have a good tutorial for me? a good one?
Arie.
P.S.
In a few weeks my new game, Magical Operation, will be released.
This multiplayer question is for this game. It will be a multiplayer game. Very good game. Expect my link for that game.
I'm just wondering...are you one of those who makes this Web-page. Because I have seen you post up links to it a couple of times now...It's is a great site by the way......
My new game, Magical Operation is a 2D game, with a 3D effect.
You can go around objects, even hide behind them, or be in front.
I don't want to start talking about this great game, but...
In the moment that it will be released (I hope very soon), I will put a link here for everyone.
I have two last things to do in this game: Multiplayer engine and Sound.
If you are using the winsock you will need service pack 5 installed because it contains memory leak fixes and it does make a significant difference in other areas as well
No that was not what he said...but if you want to use the winsock controll...you should downlaod the fix from microsfts homepage....If you want to use winsock do it...or start learninf directPlay now....
If I where you I would probably used Winsock for this prject since you already know how to use it....then become familier with DirectPlay before starting on a new project..
No No dont use Direct Play It is powerful but it is a right pain in the backside!!!!!
When creating a network game i recommend creating a control or activex exe with the main parts in it(Control is Probably best). This way it can be multithreaded and prevent missed events.
DirectPlay is already multithreaded in that messages are received by another thread. I have never had a problem with missed messages. Why would you want the overhead involved in a control or another exe?
I can't imagine DirectPlay is more painful than using Winsock. DirectPlay encapsulates all of the functionality of the Winsock API into neat classes, which is more understandable. It also handles a lot of stuff for you that you would have to code yourself.
Try Reading an example of Directplay and you will know what i mean!!!
Direct Play Can (When Coded incorrectly) cause MASSIVE crashes in the system, Oh and you have to implement a clash in order to host, there is a lot of code that needs to be established before you can connect so choose based on your experiance and confidence as a programmer
What is the exact functionality you want because choose based on these things
Direct Play
Easy To Use Search For Games Functionality Can Use Lobby Servers (Seek Descriptions From others) IPX, TCP/IP etc support Dam Reliable Often Confusing Can Be Difficult to find bugs (I Found Illegal Errors Occuring) Setup Can Often Be A Pain
Winsock Code As You Want More Control Over The Recieve System (Do As You Will) Easy If You Know How Reliable When In a Control Object Much Simpler To Find Bugs(More Required To Fix Them) No Search Unless You Make It No Lobby Server Support (Unless You Make It) TCP/IP Support Only (For Gaming)
Based On These Facts you can choose which to use and while writing these i would like to say i would swing towards DirectPlay but then i do have a project i wrote a while back that has DP in it so i could reference that.
Originally posted by BodwadUK Winsock
... Easy If You Know How
LOL!!! The same can be said for DirectPlay!!!
Most of the professional industry uses DirectPlay from my experience, so that says something. The company I worked for only used DirectPlay, we never used the Winsock API.
I hit one major problem in direct play and that was ILLEGAL OPERATIONS when a call is incorrect. Thats why i define it as difficult along with the fact there is very little help out there for directplay.
Winsock API???? Just use the winsock control!!!!!!!!!!
Winsock is easier face it!! The Winsock allows a user to do as they please and is much easier to find the bugs because they dont cause ILLEGAL OPERATIONS!!!
Anyhow i have come round to looking at using direct play instead of winsock in my next project
Ok. Now that i decided. I began to work on it. now...
What is so slow in these lines that the game movement is slow?
Data is the string data that I get from the other computer.
If SNum = 0 then I want to change the player position.
Else I want to change the player's shot position.
The form of this data is: Upsx&y&
U - symbol for Update
p - Player number (1 byte)
s - Shot number (1 byte)
x - x position (1-4 bytes)
y - y position (1-3 bytes)
& - end of number (1 byte)
Sum of max bytes: 11 bytes
GetNum function gets a string and returns the number at the begining till the & (example: gets 178&654& and gives 178)
You might fond the split command very useful for this
Dim strArray() as string
strArray = Split(Data,"&")
Select case strArray(0)
Case Blah
Posx = strArray(1)
PosY = strArray(2)
end select
Dont use this it wont work but you may find this simplifies your code. as for the slowdown you might find it elsewhere in your program i really cant tell you sorry
There is an easy way to speed up the code you posted - use Mid$ instead or Right - the $ part makes it noticable faster, and using Mid means you don't need to do calculations with Len.
Eg:
Data = Right(Data, Len(Data) - 1)
is the same as:
Data = Mid$(Data, 2) 'all chars from the second onwards
But, now you know about the MID function you can shorten again, the above line can be taken out completely!
Eg:
Data = Right(Data, Len(Data) - 1)
PNum = Int(Left(Data, 1))
can become:
PNum = CInt(Mid$(Data, 2,1))
Which all means you can make it like this instead:
I have never asked anybody for this before...I'm so embaressed....but you wrote...
the $ part makes it noticable faster
What do you mean by that. I have tried to look it up in the MSDN several times. But I can't understand why some people puts the $ sign there. Is it because the Mid function returns a Variant data type, and you force it to return a much faster string data type with the $ sign????
That's basically right, I think the slow part is checking/converting the input to make sure it can be used as a string.
There have been several threads on this forum that discuss it in detail (along with other useful tricks to speed up your code), it could be worth a look for tips in other areas