turn based and internet play

Blitz3D Forums/Blitz3D Beginners Area/turn based and internet play

Snader(Posted 2005) [#1]
Hi! It's been a long while since I have been programming in blitz. I started working again on a simple turn based hex strategy game. Now was I wondering, what is the best way to implement network/internet play.

For instance, 5 players, one is server.

The game is very 'light' for modern pc's so, whats the best solution? I want the other players to see what the 'active' player is doing.. so I want to show the mousepointer of the active player on all other pc's. Actually, all players must see the same on screen. All hexadiagonal provinces and the numbers of soldiers and buildings on each one of them.

thanx in advance,

Snader


jfk EO-11110(Posted 2005) [#2]
Displaying a mouse on all players screen is pretty trivial. Frequently sending a packet containing all tiles (coordinates and numbers etc., not graphics) is easy too.
You can save a lot of work when you use existing netcode libraries, eg. the free light verion of BlitzPlay:
http://www.blitzcoder.com/blitzplay/downloads.shtml
Or try RottNet from the toolbox.

Most mportant, to prevent frustration, make sure your game will work trough all firewalls and things. If you plan a fullscreen game, also have a look at the "coordinated Flip" Code in the Archives (probably in the Misc. section).


octothorpe(Posted 2005) [#3]
I would think an event-oriented architecture would make the network side of things super easy. If your program is event-driven, you'd only need the active player to send all his game GUI events to the other players: other players' computers would then process the events separately. Events might be low-level (e.g. "left mouse click at 750, 631") or high-level (e.g. "unit 5 moves to 10,14", "select unit 6", "action window opens", "spellcasting window opens", "spellcasting window scrolls to 5th item", "unit 6 casts fira at 12, 16".) When the game is in "watch" mode, simply lock out user input and use the events that are sent by the active player.

Showing the current position of the mouse pointer should probably be handled differently: just send the current position every X milliseconds. Careful not to trigger duplicate mouse hover events for the clients!


jfk EO-11110(Posted 2005) [#4]
That's in fact a good idea, to use an event oriented architecture. you only need to make sure that everything works the same on all machines (eg. Random creation of things must be coordinated), you also need to calculate the Mouse Coordinates to a fixed value (eg. percent#) because of individual screen resolutions, and events (eg. buttons) must work correctly with this percentual system (beware of bugs due to rounding errors).

Mouse Motion may be interpolated, using bezier curves.


Snader(Posted 2005) [#5]
Thanx all! At the moment I let the server decide which player is the active player. The active player is the one who is sending all the eventinformation to the other players, so they can see that the active player is invading their countries :)
The mouse is kinda 'switched off' at the inactive players.

Nothing to show yet... but I will in time!