michaelth wrote:Hi.
Socket programming for networking a game is always a better choice than sth like DirectPlay.
I totally agree.
michaelth wrote:
I just send every machine' own controlling Kart's "running data" to other machines for a networked implementing.The "running data" includes
{
sgCoord curr_pos ;
sgCoord last_pos ;
sgCoord curr_vel ;
sgCoord velocity ;
float wheelie_angle ;
sgVec2 curr_track_coords;
};
That won't work anymore, most of these variables are now 'read only' and will actually disappear soon - they are just set with the values from the bullet physics.
michaelth wrote:
To aquire these data,I even have to change these "Protected variable" to "Public:"
In my version,I send these every game frame.Somebody told me that I need some optimize technology to reduce the transmission data for a Internet envrionment.After all, I just have a successful test under the LAN envrionment.
Yes, this approach won't work for a general internet (i.e. non LAN) environment. UDP packets can get lost, arrive in the wrong order, the latency is significantly higher, and the amount of data might just be too big. Consider a latency of 30 ms (which I guess is rather on the lower side of things - I get more than 60ms if I ping work from home, though that's via a VPN, which doesn't exactly help) - with that you would be limited to 33 FPS, which comes close to be unplayable (bullet simulates everything with 60 HZ) - reaction times are too slow. We would need some kind of extrapolation - e.g. assume that each kart kept doing what it was doing for the last frames. Once we receive a packet, we update and correct the current data for that kart - not entirely trivial, since locally we might not get a collision which just happened with another kart because its position was slightly different than what we thought it would be.
Extrapolation solves (partly) the problem of lost packets, and the game might still playable if there is a sudden large lag for some players.
Then there is information that must not be lost, e.g. a rocket was fired or so - we have to make sure that the information that a rocket was fired (or a rocket exploded or ...) arrives at all computers, which means either using a 2nd tcp connection (which guarantees delivery, though it's slower), or make the udp protocol more robust (which might then be as slow as tcp) ...
Additionally, what if you have computers of significant different speed? Well, with your method they will all be slowed down to match the slowest computer, so that might actually be ok, but it might be better to allow computers at faster speed to display at higher FPS.
Then there's things like lost connections ...
It's not at all trivial! On the other hand, I would be happy to get LAN network multiplayer in as a start, where we might get away with updating the positions on each frame (what are the typical latencies you get? I see under 1ms, making 50-100 FPS possible (50 if we assume a kind of handshake)).
Implementation-wise (for a LAN) it might be easier to do all computation one one computer, and let all other computers be clients, which send the kart inputs (steering, acceleration), and receive the new position, heading, and special events (rockets fired, ...). The main 'issue' is that it is rather difficult with bullet to change the position of a rigid body, unless you turn them into kinematic objects, which means that the physics are not computed for these objects. This would mean a somewhat larger change to the source code (the local kart would be a normal rigid body, remote karts would become kinematic bodies), while otherwise (a server does all computation, and just receives steering information and sends positions back) we would just have to skip all physics computation for the 'clients', and instead get the new position from the network.
Oh,I have trying compiling your"SuperTuxKart" in VC++6.0.But I failed with 347 errors.Can you give me a solution for that because I am only skilled in VC++6.0.
Did you use the VC++ project file (supertuxkart/src/ide/vc8)? It's vc8 (I am using it with the free visual express version), perhaps you can import it? Do you have all dependencies installed (more than tuxkart: besides plib you need sdl, and if possible alut, openal, ogg, vorbis, and (for now) glut)? The README in the vc8 directories explains what to do.
Otherwise: can you send me some of the error messages?
Furthermore,I have a new idea for you.Have you thought of a network game such as the "Korean Kart Game"?
You are talking of 'Kart Rider' I guess.
You can build a database for Players's registering and Players's record.One Player can hold a room for other 3 players's Joining so that they 4 players can have a Kart-race in a track. And the database can do the Player's data and rooms space management.All of these may be a "Right" network-game-form of the "SuperTuxKart". Since the ASP+Access structure is easy for aquiring and learning, this "Right" game can be finished not so difficutly.
All of this other network handling is no problem once we have the actual race working. I wouldn't mind adding the options to participate in online races to STK (though it should only be an option, many people might not like it and prefer using it stand alone only). But then there are issues about what server can we use (since we are not making any money).
Having said that, I am very interested in starting working on multiplayer, and LAN would be a good start. I won't have time to do much in the near future (am busy with fixing all physics bug so that we can do a release soon), but will always have enough time to answer questions etc. Best would be to contact me directly (email address above somewhere), or you can post to the STK development list (see web page).
Cheers,
Joerg