a networked Flash game

Started by
6 comments, last by ozmic66 17 years, 11 months ago
I'm not sure how many of you here actually use flash, so let me tell you what its limitations are when it comes to games & networking - its not optimized for math operations - it only allows for tcp sockets I've managed to create a flash client that communicates with the server & synchronizes all of the players' states smoothly (but the sim. isn't running on the server) so i'm trying to create a twitch game with flash, but I'm not completely sure about a few things. - everywhere I've looked, people say you should simulate the game on the server...but if i run, for example, more than 3-4 instances of a flash game on a server it'll be extremely slow (in actual games, is there only one game per server or a lot more?) If i run a c++ copy of the flash game on the server and have flash clients it'd be a lot faster but I'm not sure how similar the outputs will be - using my current system, where everytime the user pressed a key, it sends the server its pos,vel,accel,etc. and the server sends that to everyone else with the change's time, how would i handle non-user-controlled objects & dynamic object-dynamic object collisions? thank you for any help Oz
Advertisement
Flash is, as you say yourself, not the ideal solution for a networked twitch game :-)

The reason you want to run the simulation on the server is to avoid cheating. If that's a risk you want to take, having the server just echo to everyone else is a workable solution, and it reduces the load on the server.

For 2-32 player games, one of the players typically "host" the server, and the other players get hooked up to that server through a matchmaker/lobby system. The hosting machine tyipcally runs two copies of the game; one for the server, one for the local client (unless it's a dedicated server, in which case it runs only one).

For games with more players, typically you get a server cluster, and a sectored/zoned design for scalability -- that's why MMOs need to charge money if they are large; nobody can host that in their closet.

For your game: If you need to put up a server, it would likely be of the matchmaking/lobby kind, and players would then choose to host games on their machines.
enum Bool { True, False, FileNotFound };
thanx that cleared up a few things

If I have one client as a host, wouldn't the data transmition be slower?
because right now the client sends their data to the server who sends the data to all other clients.

If the host is another client, the data would go to the server, then the host, then back to the server, and then to everyone else

I'm not exactly sure how a flash client can be the (server) host since flash cannot bind itself to a port

any tips?

also,
I don't really mind cheating (at least at this stage)
If flash can't bind, then you're SOL, and have to use a separate server. And, in that case, your server will have to forward data for all games out there, which will likely start chewing through bandwidth if the game becomes at all popular :-(
enum Bool { True, False, FileNotFound };
Quote:Original post by ozmic66
If the host is another client, the data would go to the server, then the host, then back to the server, and then to everyone else
I'm not exactly sure how a flash client can be the (server) host since flash cannot bind itself to a port


Very simple approach:
-the flash clients only send in the key codes
-the central server, written in some kind of other language, does all the calculations
-all of the clients get only the data they need for rendering the graphics

The trick is to run the game logic on the server only. You don't have to synchronize the clients with the server because the clients only act as remote displays and input devices for the server. And you get a cheat proof system as a bonus.

Viktor
Viktor: that would work well, only I'm trying to steer away from that option because I dont have many servers available (prob. 2 at the most) and I'd like to think that many ppl will want to play my game

I'm guessing that if i want a multiplayer games with flash i need a lot of servers...

but take a look at this game
http://www.xgenstudios.com/play/stickarena/
u dont have 2 sign up to play

for them, the game doesn't run on the server--it only shares the data between clients, and they only have 4 servers total
My system right now works like theirs, but I want a bit of physics (like player-player collisions) in my game and I'm not sure how that would work with a system like that
Quote:Original post by ozmic66
for them, the game doesn't run on the server--it only shares the data between clients, and they only have 4 servers total
My system right now works like theirs, but I want a bit of physics (like player-player collisions) in my game and I'm not sure how that would work with a system like that


Then you have to use your servers as relay hosts. Essentially they will be chat servers with one 'chatroom' per game. The first client that connects to the room will be the server. You have to run two tasks on the server. The first is the general client task, that sends the keys to the server task and renders the output. The second is the server task itself. On the client mode only clients, the keys are sent to the server, which sends them to the client acting as a server, and it sends back the data to be rendered to the server, which relays it to the clients.

The idea is that you use one of the clients as a server, but each client connects to your relay server. The normal clients send keys to the relay server and receive updates from it, but the 'server' client receives keys from the relay and sends updates to it.

No data is computed on the relay servers, they are just used to copy data between the flash clients. (because the flash clients can't accept connections)

Viktor
I've actually thought about that as a possible solution, but wasn't sure how well it would work. do you know this method to be successfully used anywhere?

I'll give it a try as it seems most feasible

but... what if the client who serves as the server leaves? what if the client's machine is very slow, then everyone else's experience will be affected

also, I just read an interview with the creators of that flash game, and here are some of their stats:

on their 4 servers they hold 1.1 million registered users, and handle 3000 users at peak hours

they allow a max. ping of around 250 ms round-trip

This topic is closed to new replies.

Advertisement