Online Game

BlitzMax Forums/BlitzMax Programming/Online Game

Zenn Lee(Posted 2006) [#1]
Hi, I may sound a little stupid ( not knowing anything about how online games work, though I've made a LAN game once with BB), but how would I go about making a game you can play over the internet. If you wouldn't mind explaining in small words, that would be nice to :)

thanks a lot


FlameDuck(Posted 2006) [#2]
Well that's a rather simple question that requires a rediculously complicated answer. Basicly there are two models you can persue:

The Server-Client model: This means you have one server that everyones Client "game" connects to. All information is sent to the server, the server "plays" the game, depending on the information it got, and then sends results back to all the clients. Depending on how much of the game logic you want to expose to the clients, you can have either a thick client (which has most of the game logic) or a thin client (which has almost none).

The Peer-peer model: This means that everyone serves as both a client and a server. It increases the amount of information that needs to be sent across wires, but it doesn't requires any one person to host a server, and thus is much more robust (and complicated to implement) solution than the Server-Client model.

But this question isn't one that can easilly be explained in a fora such as this. Instead I would recommend getting hold of a good book or two, and pursueing your answers there.


ImaginaryHuman(Posted 2006) [#3]
Is the main reason for a server that determinism of data values is unpredictable on each client? Is it the most efficient network model with the shortest travel routes?


xlsior(Posted 2006) [#4]
another big reason for using a client/server approach is that if you have a network game with half a dozen players, it's a lot easier to find & connect to a single server, than for each client to find all of the others and keep half a dozen connections open to be able to talk with all of them.

Using a server greatly simplifies things from the individual client's point of view.

Using a server also makes it easier to cope with a player who has a crappy connection, the server can keep things smooth for all the other players so only the person with the bad connection suffers and not everyone else.

Lastly, keep in mind that the 'server' can run on the same machine as a client, so in a network game a single person can be appointed to act as the server, you don't need a seperate machine or something.

A good example is a game like Warcraft3, where a single person 'hosts' the game and he/she then acts as the server for the others connecting to it.

Either the server can broadcast it's presence to the network for the clients to pick up, or the clients can actively broadcast that it's looking for a game to join after which the server can show its presence and link up.


Zenn Lee(Posted 2006) [#5]
Could I use my web host as a server? And, if you don't mind, can I also see some code on how to get connected through the internet. Also, when I was using Blitz Basic I could connect through a LAN, the program searched and found other player but how would I find other players over the internet.

Thanks :)


xlsior(Posted 2006) [#6]
Could I use my webhost for a server?


Kind of -- in that you could cobble up something that allows a meeting place, where the server can gather the IP addresses of the participants, and then pass that info along to whoever hosts the game so their computer could do all the work and hosts the actual game session itself. If the game players would have to submit the game info itself in realtime through a webserver, it would be way to unreliable and slowfor the vast majority of the games -- you'd want one of the clients to play the server.

As far as finding game players on the internet: you really can't automatically discover them -- to do that you would need to scan the entire internet, which is:
a) ridiculously time consuming
b) a HUGE no-no, since people don't exactly appreciate getting portscanned
c) not a good approach

You -can-, however, have the game automatically submit a client presense to a webhost which can then be queried on where to find the other players... Or you could simply allow people to specify a hostname/IP address of whoever is hosting the game, so people can connect to other people they know and have a date/time for a game scheduled with. the first approach (having a website gather & keep track of the players that want to play a game) is probably the most user friendly and allows large groups of players to easily find one another... That's pretty much how something like BattleNet works, where you have a 'lobby' where people can meet, and start/join games in progress. but sometimes it's nice to have an option to just have a direct peer-to-peer game with another person if you already know their IP and don't need a match-making server.


Zenn Lee(Posted 2006) [#7]
Great! One more question, please. If I were to make a client program using TNet could I just add in TNet_JoinUDP( MyIP, 22233 ) (my IP as MyIP). If I was running my Host on my computer could any one connect to it any where on the internet. I'm not restricted to my LAN, right.

Thanks


RepeatUntil(Posted 2006) [#8]
To scan people playing your game on internet, you could use gnet running on this site. gnet was also improved with respect to the version of Mark Sibly and is freely available with ETNA (see my sig).