Page 1 of 1

Building a MMO

Posted: 06 Jun 2009, 18:54
by rjgtav
Hi there again. I have a problem making the movement of the character. I want to make that in the client, the character is always in the center (like pokemon) and the other clients see the player moving when it moves. Please someone help me. thank you.

Posted: 07 Jun 2009, 03:42
by m-productions
Basically on the client side, youll want the clients "hero"character to move, BUT move the MC that the hero is in, in the opposite direction that the hero just moved, this will keep the hero in the same place (aka the middle) but the other characters will move around where they should.

Now are you having trouble sending the movement to other clients, or just wondering how to keep the "main" guy in the center?

Posted: 07 Jun 2009, 06:42
by rjgtav
i want to send the movement to the server. i already read the docs but i don't understand much.

Posted: 08 Jun 2009, 21:40
by m-productions

Check out section 5.6, thats where its all at.
I am actually working on my own tutorial for people who want to get straight to making a simple game (and skip some of the "chat" sections that the docs build on) However, section 5.6 has the basic idea of movement, when you move, you need to change that useres uservars, and then make the other clients pick up that update, and move the character to the right location.

Posted: 09 Jun 2009, 14:27
by Lapo

Posted: 09 Jun 2009, 18:39
by rjgtav
Ty for the help. i'm already understanding a little of the script but i have some problems.
If i put when the mouse is down, the character moves, it works bu when i put when i press a key, the character moves, the character doent's move
I want to do that when the key is down, the other clients see the character moves and the animation of moving.
can anyone help me?

This is my code:

Code: Select all

function walk(horizontal,vertical){
   avatarMC._x += horizontal;
   avatarMC._y += vertical;
   if (inited)
      if (!_global.isBusy)
         var px:Number = int(avatarMC._x)
         var py:Number = int(avatarMC._y)
         if ((px > avatarW/2) && (px < areaW - avatarW/2) && (py > avatarH/2) && (py < areaH - avatarH/2))
            // save new variables
            // Please note that init is set to false:
            // this means that we're only moving somewhere and we don't need to init tha avatar
            smartfox.setUserVariables({px:px, py:py, init:false})
            // method derived from the [flashAPI].as
            // moves the mc using the "Quint" equation, with "InOut" easying
            // to the new px,py position in 100 milliseconds.


myMouse.onMouseDown = function()