Multiplayer Games?

BlitzMax Forums/BlitzMax Beginners Area/Multiplayer Games?

CASO(Posted 2007) [#1]
I would like to play around with making a multiplayer game. I would be working with two computers on the same network. (No internet stuff) What is the best way to go about this?

Examples and Tutorials would be nice because I have no expierence in network games.


tonyg(Posted 2007) [#2]
Does this help?


CASO(Posted 2007) [#3]
Why do you need an address for gnetconnect but not gnetlisten? And what is up with 127.0.0.1? And can the port be anything?


tonyg(Posted 2007) [#4]
Because GnetListen listens on the port set during GnetConnect.
127.0.0.1 is the IP for LocalHost.
Some ports numbers are used by specific applications.


CASO(Posted 2007) [#5]
I want to make a game like the one below. The code is from an old BlitzPlus Program. I want to connect 2+ computers that are on a LAN. Any ideas?




deps(Posted 2007) [#6]
The computer acting as a server always listens for connections. Even if you create a peer -> peer type, one of them must listen for incomming connections. Because of that, the listen command doesn not need an adress since it have no idea of what computer is going to connect.

127.0.0.1 is always pointing at your own computer. THink of it as a magic address. No matter what computer you use or if it has internet or not, 127.0.0.1 is always valid. To try the game on one computer, start the server and then launch the client and tell it to connect to 127.0.0.1. if it fails you did something wrong. :)

The port can be anything from 1 to 65535 if I remember correctly. But please use a port aboce 1024 because most ports below may be used by other programs.


CASO(Posted 2007) [#7]
Not to be whiney, but I WANT 2 DIFFERENT COMPUTERS TO COMMUNICATE, 127.0.0.1 may be magic but it doesn't do that. BlitzPlus pulled up a box that let me check for games in progress or start a new one. Does Blitzmax have a way to let me see what connections are available and which are used?

PS: Thank you so much for answering my questions.
---- And I am going to give BNet a shot.


deps(Posted 2007) [#8]
The easy route:
1) Find out the IP on computer 1
2) Use it instead on 127.0.0.1
3) You teh win!

The not so easy route:
1) Server broadcasts that it is running and waiting for clients
2) The clients listens to broadcast packets
3) The client shows a list of running games
4) Connect
5) Yay!

The last method depends on what library you use. If I remember correctly you could send a message to another "magic" address and it would be automatically broadcasted over the LAN. But I have never done this before so I'm not sure.


CASO(Posted 2007) [#9]
Cool! I finally got all my numbers straight and it worked.


CASO(Posted 2007) [#10]
I have two computers chatting away and I am starting to get an idea of how it all works. I have hit a problem though. I don't know what the structure for a 3+ player game is. I would like to know what arrays, types, lists, etc. need to be setup for me to write a game that keeps track of individual players' info (name, x, y, etc.)


Derron(Posted 2007) [#11]
array or list of "objects" containing connected remote IPs, Ports, Names, PlayerIDs ... what you want to store to unify the remote-PCs.


Instead of only sending it to "remoteIP" you then have to make a "foreach"-loop with all remote IPs and send the same thing again and again.

Depending on how the information is spread...:
a.) Each client sends its changes to the server - and the server sends the changes to all clients

or

b.) Each client knows all other clients and sends itself the information to keep the dataamount for the server as small as possible


you need to program it differently.
I prefere a mixture of it a.) is used for the networklobby ...before game starts, server spreads around all needed infos ... game changes are then spread using b.). To keep everything in sync the a) method is used again all XXX millisec() to spread really the same info to all clients (I use UDP packets with Ack-responses but this take as much tries that the position differs to much to make some calculations correct - so the server sends its information about the players and overwrites all other commands).


bye
MB


CASO(Posted 2007) [#12]
I'm having trouble putting my concern into words. Here is another go...

What is the best way to figure out which remote-PC the info coming in came from.

Here is my concern stated in yet another way...

A is the server. B, C, and D are clients. When info comes in from a remote-PC, how do I know which (B-C-D) it came from. I would like to have 1 program that can be the server or client. (Also-How can you figure out how many/which people are involved at a given moment)

I'm sorry for all the questions.


Dreamora(Posted 2007) [#13]
you save the on that user on the first connection into an object for that user that you hold in a TUser list (or however you call the type) and when a message comes in you check for those information.

If you only have 1 datafield to identify, use TMap instead of TList