Results 1 to 38 of 38

Thread: Multiplayer programming Q

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Question Multiplayer programming Q

    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.

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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 )

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Smile

    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.

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    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.

  6. #6
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    2D or 3D????
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yes...if you are using DirectSound then the user already have to have DX installed, so why not go for DirectPlay...

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  9. #9
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  10. #10
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    There are some tutorials here as well:

    http://www.rookscape.com/vbgaming/tutorials.php

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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......

  12. #12
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Nope, I just have made some tutorial contributions and post there sometimes.

  13. #13
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    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.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    The links are good.
    Now, is there a speed difference between DPlay and Winsock?
    If no I prefer using Winsock.

    Thank you,
    Arie.

  16. #16
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Any difference is probably going to be negligible.

  17. #17
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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

    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    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.

  19. #19
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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..

  20. #20
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  21. #21
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    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.

  22. #22
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  23. #23
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Originally posted by BodwadUK
    Direct Play Does have its advantages but it is also a pain in the Ar**!!!!!
    Could you be more specific?

  24. #24
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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

    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Talking

    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.

  26. #26
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Ok Ok I have used both

    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.

    Happy Deciding....
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  27. #27
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    Attached Files Attached Files
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  28. #28
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Originally posted by BodwadUK
    Try Reading an example of Directplay and you will know what i mean!!!
    I had no problems understanding DirectPlay. Maybe it's just me though
    Originally posted by BodwadUK
    Direct Play Can (When Coded incorrectly) cause MASSIVE crashes in the system...
    LOL, anything coded incorrectly may cause a program crash, that's not a problem with DirectPlay

  29. #29
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    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.

  30. #30
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  31. #31

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    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!

    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.

  32. #32
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Originally posted by BodwadUK
    I hit one major problem in direct play and that was ILLEGAL OPERATIONS when a call is incorrect.
    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.
    Originally posted by BodwadUK
    Thats why i define it as difficult along with the fact there is very little help out there for directplay.
    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.

    Originally posted by BodwadUK
    Winsock is easier face it!!
    At the expense of power and the need to write more code to do things.

  33. #33

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Question What is slowing down?

    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:
    1. Select Case Left(Data, 1)
    2.  Case "U"
    3.   Data = Right(Data, Len(Data) - 1)
    4.   PNum = Int(Left(Data, 1))
    5.   Data = Right(Data, Len(Data) - 1)
    6.   SNum = Int(Left(Data, 1))
    7.   Data = Right(Data, Len(Data) - 1)
    8.  
    9.   If SNum = 0 Then
    10.    Player(PNum).pPosition.pX = GetNum(Data)
    11.    Data = Right(Data, Len(Data) - _
    12.               Len(Str(Player(PNum).pPosition.pX)))
    13.    Player(PNum).pPosition.pY = GetNum(Data)
    14.    Data = Right(Data, Len(Data) - _
    15.               Len(Str(Player(PNum).pPosition.pY)))
    16.   Else
    17.    Player(PNum).pShot(SNum).sPosition.pX = GetNum(Data)
    18.    Data = Right(Data, Len(Data) - _
    19.               Len(Str(Player(PNum).pShot(SNum).sPosition.pX)))
    20.    Player(PNum).pShot(SNum).sPosition.pY = GetNum(Data)
    21.    Data = Right(Data, Len(Data) - _
    22.               Len(Str(Player(PNum).pShot(SNum).sPosition.pY)))
    23.   End If

    Thank you,
    Arie.

  34. #34
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  35. #35
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: What is slowing down?

    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:
    1. Select Case Left$(Data, 1)
    2.  Case "U"
    3.   PNum = CInt(Mid$(Data, 2,1))
    4.   SNum = CInt(Mid$(Data, 3,1))
    5.  
    6. Dim strArray() as string
    7.   Data = Mid$(Data,4)
    8.   strArray = Split(Data,"&")  
    9.  
    10.   If SNum = 0 Then
    11.    Player(PNum).pPosition.pX = strArray(0)
    12.    Player(PNum).pPosition.pY = strArray(1)
    13.   Else
    14.    Player(PNum).pShot(SNum).sPosition.pX = strArray(0)
    15.    Player(PNum).pShot(SNum).sPosition.pY = strArray(1)
    16.   End If
    17.  
    18. 'If you use "Data" after this point you will also need this bit:
    19.    Data = Mid$(Data, Len(strArray(0)) + Len(strArray(1)) [b]+ 2[/b])
    20.   'nb: i'm not sure about the +2 bit, you'll need to play around to check

  36. #36
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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????

  37. #37
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    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

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    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?

    Thank you,
    Arie.

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