csharpjava's official thread of n00b questions:

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

csharpjava's official thread of n00b questions:

Postby csharpjava » 14 Mar 2008, 12:37

:)

so: i finally printed out all the smartfox flash api docs/ and tutorials (boy was that hard) and started reading through them very thoroughly. and i decided to just make 1 thread to narrow down all my questions

man have i learned a lot by reading those but i'll need some stuff clarified i think

the first question i'll pose =

:arrow: from how i understand now, a smarfoxclient object CONTAINS a room and a user?

:arrow: can they contain multiple(can i override the sf object to do so) or is it only one each?

thanks to all who can help!
User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

Postby csharpjava » 14 Mar 2008, 12:56

and while i have an extra minute

i want to do a multiplayer game that simply updates x,y coordinates of players pretty realtime-ish

:arrow: anybody care to explain a basic game design paradigm to get this started? (example: should i create a client that has a room and a player with coordinates x,y or is that too simple?)

:arrow: also, if i want 'real-time', should i lower the server pollspeed to something really low? or keep it around 300ms and just write a clever way to animate the players while the updates are occuring?

sanks guys
didibus
Posts: 34
Joined: 09 Sep 2007, 19:31

Postby didibus » 15 Mar 2008, 07:56

:arrow: from how i understand now, a smarfoxclient object CONTAINS a room and a user?

No, I don't think you understood. The SmartFoxClient doesn't contain any Room or User. It handles the flow of the server-client relationship. The server actually holds the User and the Room. Well, the server allocates them, and the smartFoxClient keeps track of them. So Room and User are classes on their own, they live in memory, but the smartFoxClient holds references to them.

:arrow: can they contain multiple(can i override the sf object to do so) or is it only one each?

Yes, you can. As I said, the smartFoxClient holds references to the Rooms, he keeps them inside an array, so you can have as many Room as you want and the smartFoxClient will keep track of them in his roomList array. Now off course, for every Room in the client, so must the server have.

It's pretty much the same for Users, except it's actually the Rooms which keeps track of the Users. Every Room is aware of the user inside itself. They store them inside a userList array. It also separates the local user from the other users. So you can easily know who you are. Now if you wanted to know if their can be 2 local user, well I'm not sure, you could make 2 connection to the server from the same machine, and you could try it inside the same .swf, but I'm not sure.

:arrow: anybody care to explain a basic game design paradigm to get this started? (example: should i create a client that has a room and a player with coordinates x,y or is that too simple?)

Well, I can try...

On the client side, you need to make a smartFoxClient. Then have it login to the server, this will create a User and log him in to the server. Then have the smartFoxClient join a predefined room on the server that you set up inside the config.xml. This will have the effect of creating a Room and moving your User inside it. Then yes, simply create two userVariables x and y, so the server will hold their value. Now every time you move, update the UserVariables.

On the server, you need do nothing else then create the room in the settings.xml.

At this point, if you start two instances of your game, the server will hold two Users connected inside the same room and their respective x and y coordinates.

So that the client gets aware of the other users, you need to add some events. OnUserEnterRoom and OnUserLeaveRoom. Have it so that when a user join the room, you create everything required for displaying, like his avatar. And make it so you destroy everything when he leaves the room(unless he never needs to leave the room). Then to update their coordinates, add an OnUserVariablesUpdate event and simply retrieve the x and y of the user who just moved from the event and assign it to your corresponding avatar or whatever the players are and your done.

:arrow: also, if i want 'real-time', should i lower the server pollspeed to something really low? or keep it around 300ms and just write a clever way to animate the players while the updates are occuring?

I don't know about the poll speed. I don't even know what it does. But I guess writing a clever animation would be the more efficient lag wise way of doing it. But you have to ask yourself, do you want real time as in lag free experience, or real time as in second and millimetre accurate interaction?

Well, I hope it helped, and if you have anymore question just ask. People on this forum are pretty nice and quick to answer, especially Lapo, but :roll: that's understandable from him, but other users are surprisingly helpful also.
User avatar
Lapo
Site Admin
Posts: 21521
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 15 Mar 2008, 10:47

Thanks didibus, nice job :)

To get started with the very basics of SmartFoxServer I would never stop to repeat that the first three tutorials are essential.

Take tutorials 5.1, 5.2 and 5.3 and study them thoroughly.
Those are the essence for building anything with SmartFoxServer.
Then you can move to more advanced examples that show you how to move avatars around, use the buddy list, up to real-time stuff and more...

This document is also helpful for getting started-> http://www.smartfoxserver.com/docs/docP ... /index.htm
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

Postby csharpjava » 17 Mar 2008, 18:41

didibus, i really appreciate the response.

also, lapo, i've been going through the tutorials. they are really good.

once i get a decent version of my client / sever running and enough users interested, i'll be looking into buying a licence for more users.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 13 guests