7 Replies Latest reply on Jan 21, 2008 9:16 PM by hwa-jun yu

    Making a multiuser game running 'realtime'

    hwa-jun yu Level 1
      I've been testing Multiuser server for few weeks. Sadly, I saw an article saying Adobe discontinued developing it and recommend users to move to Flash Media Server. Anyway, I've been studying MUS for some time now and trying to make a multiuser game and there I found a problem.

      It is a fishing game. The idea is that two players will move their baits on screen and catch fishes, on separate computers. Problem is, I had a bad time getting those baits to move in acceptable speed, which others may say 'realtime'.
      My script works like this:
      1. If a player moves mouse pointer, the app sends information of mouseLoc to server
      2. A server-side script catches the info and sends back to All-Users
      3. The bait then moves accordingly
      4. The bait must have finished moving before the app sends new information to server

      I was wondering whether I'm doing it right, cos my baits moves very slow. Seems like it keeps sending info to server which ends up a huge array of jobs queued in my app.

      Is there a better way in doing this?
      I really need help, I haven't done anything like this before. Thank you in advance.
        • 1. Re: Making a multiuser game running 'realtime'
          Zen Seven Level 1
          I'm fairly new to MUS as well, but I'm going to guess you're using TCP to send your data, and not UDP. UDP responsiveness is much much faster since it doesn't wait for an acknowledgement to be sent back to the sender to complete the message. UDP is fire and forget. If you get the message, great, otherwise, who cares.

          That's why it's important to have a tight incoming/outgoing network loop in your main loop to keep updating/receiving the appropriate message updates.

          So instead of sending mouse location on where your bait is going to swim to (or whatever), I would calculate the position, orientation and direction of movement of your bait client side first, and then send a message containing that data continuously. So if the internet eats one some of those messages you still have the bait moving in the last direction your server told the client to.

          Do some searches on google regarding "game development networking" - there are plenty of examples and well written articles regarding this. Not in director of course, but the concepts are the same.
          • 2. Re: Making a multiuser game running 'realtime'
            hwa-jun yu Level 1
            Thanks big time, Zen Seven.
            I was starting to think the same way. I saw sample codes of a 3D game and I see the workaround you're telling.
            I'll go search for some articles right away.
            FYI, I'm working on a 2D game. We've been working on 2D graphics and feel happy for it. We wanted to go for 3D but there seems to be a jump for our sense.
            Anyway, what do TCP and UDP stand for? What are they?
            • 3. Re: Making a multiuser game running 'realtime'
              Level 7
              This might help:
              http://xtrema.rtr.gr/cArti/?trg=1


              "hwa-jun yu" <webforumsuser@macromedia.com> wrote in message
              news:fmibek$cr6$1@forums.macromedia.com...
              > Thanks big time, Zen Seven.
              > I was starting to think the same way. I saw sample codes of a 3D game and
              > I
              > see the workaround you're telling.
              > I'll go search for some articles right away.
              > FYI, I'm working on a 2D game. We've been working on 2D graphics and feel
              > happy for it. We wanted to go for 3D but there seems to be a jump for our
              > sense.
              > Anyway, what do TCP and UDP stand for? What are they?
              >
              >




              • 4. Re: Making a multiuser game running 'realtime'
                hwa-jun yu Level 1
                Thank you, alchemist. I've read the articles in http://xtrema.rtr.gr/

                It has enlightened me with new understandings of network programming.

                So, in director (or is it in any software) we can only select one protocol, TCP or UDP. We just can't use both of them in the same application, right?

                I also read this: "Flash Communication Server supports HTTP Tunneling. The Multiuser Server does not." Does it mean I can't use shockwave multiuser server to make multiuser game that connects over the internet?

                Sorry to have asked silly question, I'm learning. I feel like a 2 years old learning ABCs...
                • 5. Re: Making a multiuser game running 'realtime'
                  Level 7
                  > So, in director (or is it in any software) we can only select one
                  > protocol,
                  > TCP or UDP. We just can't use both of them in the same application, right?
                  Sure we can. Long as we use more than one sockets.
                  Btw, that's what the multiuserXtra does when establishing a connection with
                  a server that supports udp, but does it transparently.
                  When you send tcp messages, it's tcp(stream) socket is used, while for udp,
                  the udp(datagram) one.

                  > I also read this: "Flash Communication Server supports HTTP Tunneling. The
                  > Multiuser Server does not."
                  I'd say that that the comparisson was mostly a marketting comment. HTTP
                  tunelling is a method of packing the data in an http-like format, to allow
                  the use of http proxies and go through firewalls that block unknown binary
                  data transfers.

                  > Does it mean I can't use shockwave multiuser server
                  > to make multiuser game that connects over the internet?
                  A: Of course not, and B: sure you can.
                  Http tunelling helps in the cases mentioned above -companies, mostly-, but
                  also increases the packet size + cpu overhead. Though the last two don't
                  have the gravity they used to, the udp support of mux/mus makes it a far
                  better choice for non turn based applications, like action games.


                  "hwa-jun yu" <webforumsuser@macromedia.com> wrote in message
                  news:fmkdl2$m8h$1@forums.macromedia.com...
                  > Thank you, alchemist. I've read the articles in http://xtrema.rtr.gr/
                  >
                  > It has enlightened me with new understandings of network programming.
                  >
                  > So, in director (or is it in any software) we can only select one
                  > protocol,
                  > TCP or UDP. We just can't use both of them in the same application, right?
                  >
                  > I also read this: "Flash Communication Server supports HTTP Tunneling. The
                  > Multiuser Server does not." Does it mean I can't use shockwave multiuser
                  > server
                  > to make multiuser game that connects over the internet?
                  >
                  > Sorry to have asked silly question, I'm learning. I feel like a 2 years
                  > old
                  > learning ABCs...
                  >








                  • 6. Re: Making a multiuser game running 'realtime'
                    hwa-jun yu Level 1
                    Thanks alot for the explanation, alchemist.

                    I've managed to create UDP connection in director after reading several articles. But don't know why my game again runs slowly.

                    I used getNumberWaitingNetMessages() and checkNetMessages() on a TimeOut handler to force incoming messages checking. I tried several combinations of parameters yet to no avail.

                    I looked back on the Christopher Campbell's Demolition Derby sample. I see he sent KeyFrame Data and sub-KeyFrame Data which in my opinion helps improve Derby's performance.
                    I followed his techniques of using checkNetMessages() but, funny, maybe it was me haven't understood Lingo enough or my programming techs just insufficient to make a similar result as his Derby. The problem is just me.


                    In short, I'm clueless dealing with all this Realtime stuff. Is there any other movie sample regarding MUS besides Demolition Derby?
                    • 7. Re: Making a multiuser game running 'realtime'
                      hwa-jun yu Level 1
                      In a times of desperate programming, I finally found a suitable parameter that fits in and results in an acceptable performance. Weird, never thought I'd find a solution at last minutes.

                      I used a TimeOut object of 50 milliseconds like this.

                      new timeOut("ForceMessageProcessing", 50, #CheckNetMessages)

                      Which then in the CheckNetMessages handler I allow only 1 message to be processed in one moment.

                      num = GetWaitingNetMessages()
                      if(num > 1)then num = 1
                      gMultiUser.CheckNetMessages(num)


                      Well, for now it runs okay. I want to add more interactions to my movie and see further performance when I finish adding them.