First off, I don’t know how far I will get with this but I was thinking about a small home project to have a play with the SGS as it the the newest, shineyest thing around
I’ve read through the tutorials and think I pretty much ‘get it’ howerver I do have a few questions in my mind. I can see how you would do a MUD like game, (cos that is in the examle ) or an EVE like game where the server is effectivly responding to user input in the form of commands. To some extent WOW too but I’m not sure on collision with terrain (see below).
What I’m not sure about is how you would do a more action orientated game (with dynamics and colission server side). I think this may be related to the physics question post sorry if I’m crossing topics.
With this in mind I have decided to try a little 2d shooter game (hence DarkShooter ), very similar I supose to something Kev wrote a few years ago (Astroprime) for reference for those of you that remember it. I don’t intend it to to be a ‘game’ more a learning experience.
What I basically have in mind is to fly a little space ship around and death match with other players/enemy ai’s. There will be a few seperate ‘Sectors’ that can be jumped too. not much more than this. Collision isn’t intended to be very fancy, just circle to circle.
So my questions are:
- how to regualary update position/perform collision on the server, as the examples I have seen so far just react to event from the client
- how to regualary send info to the clients
- how to get input (key presses) from the clients
- how to keep the clients relativly in sync (to cut down on jumping)
From looking at the javadoc, my initial naive guesses about an approach are:
I think PDTimer is my friend to do regular updated server side (but I’m not sure how to use it, I think there may be a commented out example in the Hack code).
Basic architecture is to have a ‘Sector’ GLO that contains a load of references to ‘Actor’ GLO’s (space ships, asteroids, bullets etc). Player and AI’s will control the ‘Actors’ which will manage state (position, velocity, damage) etc
So to perform the dynamics (I hesitate to say physics) and collision on the server I would set up a regular timer to update these calculations. Basically for each sector the timer wakes up, gets all the Actors, update position perform collision, send any results to the players in that sector. I think this would have to be a GET.
To send info the the players another timer that looks at all the positions of actors in a sector (PEEK?) and sends pos and velocity to the clients. (so the clients can interpolate).
I’m really not sure on sending info from the client tot eh server, I can’t see that every keay press is viable but lets assume that for now.
keeping clients in sync. hmm. may be if the positiont hat comes in from the server is different to that the client thinks it should be the client ‘tends’ towards the position it should be so it dosn’t jump. (I think this has been discussed here before, probably by Kev).
So as I said this is pretty naive but is just initial thoughts from reading the docs and skimming the code examples. Any comments on this approach to using SGS?
Sorry it ended up so long.
Cheers
Dan.