Hi, Guys.
I have a question.
What is the best way of working with multiplayer:
With the simple Winsock or DirectPlay programming?
Which is easier? and simpler?
Thank you,
Arie.
Printable View
Hi, Guys.
I have a question.
What is the best way of working with multiplayer:
With the simple Winsock or DirectPlay programming?
Which is easier? and simpler?
Thank you,
Arie.
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...
Thank you anyway,
Arie. :)
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.
2D or 3D????
Yes...if you are using DirectSound then the user already have to have DX installed, so why not go for DirectPlay...
We are looking forward to see your game :)
Good DirectPlay tutorilas...I don't know...but you could check out those two they have at DirectX4VB...they should the trick...
Get the DX SDK for direct play learning and use there example programs for help, thats how i did it and i did quite well :D :D :D :D
There are some tutorials here as well:
http://www.rookscape.com/vbgaming/tutorials.php
Quote:
Originally posted by Machaira
There are some tutorials here as well:
http://www.rookscape.com/vbgaming/tutorials.php
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......
Nope, I just have made some tutorial contributions and post there sometimes.
Yes I saw one of them. Nice to see that people that knows more then others are willing to teach the rest...Keep up the good work...
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.
Arie.
The links are good.
Now, is there a speed difference between DPlay and Winsock?
If no I prefer using Winsock.
Thank you,
Arie.
Any difference is probably going to be negligible.
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
:D :D :D
So, BodWadUK...
You say that I should use DirectPlay?
Anyway, I'm using DirectSound so it won't be a problem.
Should I use it?
Thank you,
Arie.
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.
SP5 Here
http://msdn.microsoft.com/vstudio/do...p5/default.asp
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.
Direct Play Does have its advantages but it is also a pain in the Ar**!!!!!
ill Leave it up to you what you use but for winsock you will need SP5
Could you be more specific?Quote:
Originally posted by BodwadUK
Direct Play Does have its advantages but it is also a pain in the Ar**!!!!!
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
:D :D :D :D :confused: :confused:
Guys, Guys... relax!
What I need is an advice from one of you who have experience with both DirectPlay and Winsock.
Which is recommanded?
Thank you,
Arie.
Ok Ok I have used both
What is the exact functionality you want because choose based on these things
Direct Play
:D Easy To Use Search For Games Functionality
:D Can Use Lobby Servers (Seek Descriptions From others)
:D IPX, TCP/IP etc support
:D Dam Reliable
:mad: Often Confusing
:mad: Can Be Difficult to find bugs (I Found Illegal Errors Occuring)
:mad: Setup Can Often Be A Pain
Winsock
:D Code As You Want
:D More Control Over The Recieve System (Do As You Will)
:D Easy If You Know How
:D Reliable When In a Control Object
:D Much Simpler To Find Bugs(More Required To Fix Them)
:mad: No Search Unless You Make It
:mad:No Lobby Server Support (Unless You Make It)
:mad: 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.
Happy Deciding....:D :D :D :D
If You Havent Got The SDK and You Have A 56K Connection Then Instead You Can Take This Zip Of DirectPlay Example Projects
I Do However Highly Recommend you get the DX SDK if you want to develop in DX
I had no problems understanding DirectPlay. Maybe it's just me though :)Quote:
Originally posted by BodwadUK
Try Reading an example of Directplay and you will know what i mean!!!
LOL, anything coded incorrectly may cause a program crash, that's not a problem with DirectPlay :)Quote:
Originally posted by BodwadUK
Direct Play Can (When Coded incorrectly) cause MASSIVE crashes in the system...
LOL!!! The same can be said for DirectPlay!!!:DQuote:
Originally posted by BodwadUK
Winsock
...
:D Easy If You Know How
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 :D :D :D :D :D
Ok...
According to your posts...
I have made a decision:
I know Winsock better than DirectPlay and I don't want to start learning it now. I'll use Winsock! :D
Thank you all for sharing your opinions,
you helped me a lot,
and when my game will be ready, i'll give it to you all.
Thank you,
Arie.
Write bad code and bad things could happen :) I have never gotten an illegal operation error with DirectPlay and I've been using it for years.Quote:
Originally posted by BodwadUK
I hit one major problem in direct play and that was ILLEGAL OPERATIONS when a call is incorrect.
Try the tutorials here - http://rookscape.com/vbgaming/ and here - http://www.directx4vb.com/ There's plenty of resources out there if you just look.Quote:
Originally posted by BodwadUK
Thats why i define it as difficult along with the fact there is very little help out there for directplay.
At the expense of power and the need to write more code to do things.Quote:
Originally posted by BodwadUK
Winsock is easier face it!!
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)
VB Code:
Select Case Left(Data, 1) Case "U" Data = Right(Data, Len(Data) - 1) PNum = Int(Left(Data, 1)) Data = Right(Data, Len(Data) - 1) SNum = Int(Left(Data, 1)) Data = Right(Data, Len(Data) - 1) If SNum = 0 Then Player(PNum).pPosition.pX = GetNum(Data) Data = Right(Data, Len(Data) - _ Len(Str(Player(PNum).pPosition.pX))) Player(PNum).pPosition.pY = GetNum(Data) Data = Right(Data, Len(Data) - _ Len(Str(Player(PNum).pPosition.pY))) Else Player(PNum).pShot(SNum).sPosition.pX = GetNum(Data) Data = Right(Data, Len(Data) - _ Len(Str(Player(PNum).pShot(SNum).sPosition.pX))) Player(PNum).pShot(SNum).sPosition.pY = GetNum(Data) Data = Right(Data, Len(Data) - _ Len(Str(Player(PNum).pShot(SNum).sPosition.pY))) End If
Thank you,
Arie.
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 :rolleyes: 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:
VB Code:
Select Case Left$(Data, 1) Case "U" PNum = CInt(Mid$(Data, 2,1)) SNum = CInt(Mid$(Data, 3,1)) Dim strArray() as string Data = Mid$(Data,4) strArray = Split(Data,"&") If SNum = 0 Then Player(PNum).pPosition.pX = strArray(0) Player(PNum).pPosition.pY = strArray(1) Else Player(PNum).pShot(SNum).sPosition.pX = strArray(0) Player(PNum).pShot(SNum).sPosition.pY = strArray(1) End If 'If you use "Data" after this point you will also need this bit: Data = Mid$(Data, Len(strArray(0)) + Len(strArray(1)) [b]+ 2[/b]) 'nb: i'm not sure about the +2 bit, you'll need to play around to check
I have never asked anybody for this before...I'm so embaressed....but you wrote...
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????Quote:
the $ part makes it noticable faster
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 ;)
I changed the code for your code. no error. nothing wrong.
except, the speed remains slow...
I have a question:
maybe is it slow because I use two games at the same time to check the winsock?:rolleyes:
Thank you,
Arie.