I just started learning HTML5 canvas and Google App Engine's Channel API.
I build a simple game demo based on a isometric map. Right now I want to implement character movement, but I am wondering how I should implement it.
current demo: http://cheukalex.appspot.com
This is how I think it would be implemented:
The client will handle the movement. Once the arrow keys are pressed, the client will do the movement, then sends the new coordination to the server which then will be broadcast to other users on the server to update the location of your character.
Problems I thought of:
What if I want to implement "movement speed", as in how fast can the user walk five squares for example. The delay between each movement will be done on the client side. But will that be safe? since javascripts are easily edited.
How do I deal with latency? If i built a simple chase-tag game, how would I sync up the users so situations where, one person looks like they "tag" another user, but the other user see him 1-2 squares behind, wont happen?
EDIT: @nycynik, you are right, the latency is around 200ms. I have tested it here.
Latency Test: http://cheukalex.appspot.com/latency
Thats is the smallest latency it will ever get. 200ms is pretty fast. Then it might be my code that is slow?
How i implemented the whole game is.
- Client enters website
- Server creates token, open channel, store client data ( channel id ) in DB
- .... some logic
- When Client press arrow keys, it notifies the server which client moved and what direction
- Server recieve movement, does logic, loops through database (only currently online clients), broadcast message to all clients the position of every client on the map in json. Client then "moves".
Something wrong with this?