Fighting Game - how to proceed

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
dbp
Posts: 8
Joined: 28 Feb 2011, 00:02

Fighting Game - how to proceed

Post by dbp »

Hi !

I am reading more and more about smartfox server as i find it very exiting.
The AS3 Documentation is also very well done !
Good job guys.

My question is not only for a fighting game but more a general approach on how to.

To make it simple, my game run at 60 fps. (I can change the framerate if necessary)
Let's say that there is 4 players gaming together on the server.

So, in the case of a fighting game, do i need to update all the characters who are doing an action or moving every 60 fps ?

like :

Code: Select all

private function onEnterFrame(evt:Event):void {
     ...
     smartFox.setUserVariables(uVars);
}

function onUserVariablesUpdateHandler(evt:SFSEvent):void {
    //get the 4 users variables here
    //this is called every frames per seconds.
}
My question may sound stupid but, is it the correct way of doing ?

With 60 call every seconds, looped for 4 users isn't the server going to explode ?

Thank you very much for any help or advices.
Regards.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

With 60 call every seconds, looped for 4 users isn't the server going to explode?
Not likely. The server can handle many messages per seconds. Have a look at: http://www.smartfoxserver.com/whitepape ... index.html and http://www.smartfoxserver.com/whitepape ... index.html.

It's a question of how clients can handle this. If there was 3 other players in the same room, each client would get 180 messages per second (60 x 3) and in a normal internet environment, the average ping rate is about 200ms. If you do the maths, clients may not be able to keep up with the incoming data thus will cause dropped messages. See "Understanding Dropped Messages" section in http://www.smartfoxserver.com/docs/docP ... ooting.htm

In a LAN environment, it may work because the data rate is almost like real time.

So you will need to take into consideration about upload/download rate. A suitable upload rate would be 200ms (or 5 times per seconds).

The best way to implement this, is to send a command to execute a fighting move along with parameters such as direction, position etc - then have each client play a certain animation.
Smartfox's forum is my daily newspaper.
dbp
Posts: 8
Joined: 28 Feb 2011, 00:02

Post by dbp »

BigFIsh, again thanks for your explanations !

You explained very well and it really made sens to me.
Now i will read all the links that you gave to me so i will be able to know more about it.

But what is important is i learned that data-send economy was a crucial point.

Thanks again !
dbp
Posts: 8
Joined: 28 Feb 2011, 00:02

Post by dbp »

Hi !
I have read a lot of documentation about how everything work and the possible work around for latency problems.
I have another question.

Is it possible to wait for other player response before doing an action on my own computer ?

For example, if directly after pushing the left button, my chatacter go on the left, on the other people screens, the my character will move only after the packet have been sent to all people.
So there will be a (gap / interval) on my computer and on their computer.
My questions are the following :

1 - Do all people receive the information i send at the same time ?
2 - Is it possible to know when other people receive the information ? So that way, i can move my character with a kind of delay ?

In fact i would like to know if waiting for other people response before moving my character is a possible solution.

Thank you very much for your time.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

1 - Do all people receive the information i send at the same time ?
Nope, it depends on the player's 'ping' - the time it takes for a package to travel from client to the server and vice visa.
2 - Is it possible to know when other people receive the information ? So that way, i can move my character with a kind of delay ?
Yes, you can do this by roughly knowing each player's ping. See http://www.smartfoxserver.com/docs/docP ... dTripBench how to do this.
In fact i would like to know if waiting for other people response before moving my character is a possible solution.
No solution is prefect. You will need to think of all possible solutions and go for the one that would be the best.

But there is one thing I would suggest: Validate all actions (punch, kick etc) via server-side if you can. Knowing each player's ping, you could calculate roughly where each player were previously at the time the 'action' was triggered. Use client side animation to give each player time before getting a validation of the 'action' which will trigger 'hit' or 'miss'.
Smartfox's forum is my daily newspaper.
Post Reply