online multipayer games

BlitzMax Forums/BlitzMax Beginners Area/online multipayer games

B(Posted 2009) [#1]
Hi,

I was looking at the commands and such for creating online games that use servers and such.

I have no idea how to use these at all, and i looked through the forums, and was unable to find anything.

I would like to know how one goes about creating a game in which two people can connect to a server and player1 can use the arrow keys to move his character (a blue square) and player2 can use the arrow keys to move his character (a green square) around the screen and both players can see each others movements.

I feel that if I were able to do this then I could implement the rest of my ideas into it without nagging everybody on the forums.

Thanks!

B


AltanilConard(Posted 2009) [#2]
This is how a simple multiplayer game works:
There is one server that holds all the information about all the players, like there position. Every client (player) is connected to the server. Lets say there are two players online. When Player A takes a step forward, it will tell the server about his movement. The server will check if the move is legal, and then notify Player B about the movement of Player A. The client of Player B will now process the movement and he will see Player A moving forward.

This 'talking' between the client and the server happens trough sockets. Every time the player tells the server about his movement, he sends a packet (array of bytes) to the server, wich will hold all the information the server needs to know. You might want to look up about sockets on the internet. Blitzmax natively supports sockets, you can look at the Sockets documentations in the help menu. To start with an online game is quite a big step into the world of network programming, I suggest you first try to create a simple chat client/server or something simmilar. A while ago I posted an example of a client/server structure here (post #12), you might find it usefull to get started.

If I find the time I'll create a small example to demonstrate what I've been saying. I hope this helped a little.


Zethrax(Posted 2009) [#3]
Your best bet is to have a squizz through the code archives. Theres a few multiplayer examples in there. There may also be some multiplayer source code libs in the toolbox section of the site, which could be worth a look at.


B(Posted 2009) [#4]
ok thanks guys.

@Conard
ill have a look at the link you posted, and try to wrap my head around all that you said.
it makes sense, so now I just have to think about how I would program it.
If you have the time a demonstration would be most helpful/appreciated!
Thanks! :)


@Bill Stanbrook
I have looked in the code archives and didnt find anything, ill have another go however.
and Ill also have a go at the toolbox.
Thanks!

THanks again guys.
Cheers!

B


B(Posted 2009) [#5]
hey Conrad,

i dont wanna nag, but have you found time to create an example program?

I have been researching the subject and everything, as well as other people's tutorials/examples, are really confusing me.

this is alot harder than I thought.

Sorry if this is nagging.

Thanks again!

B


AltanilConard(Posted 2009) [#6]
It is quite complex indeed. I've cleaned up some old code on my computer that demonstrates how multiple players can walk around and see each other. This code is really simple and probably quite inefficient, but it could help you to understand how an ORPG works. To test it, you should compile both the client and the server, copy the client a couple of times, start the server, then open a few clients. Every player represents a white rectangle.

Just study the code until you understand it a bit, then you could implement some features. You should make the server check each players movement/timing, so all players will actually be positioned the same on every client. Then you could add some features, like account creation, chat system etc.

If you don't understand the code at all, you should first learn some more about network programming: create a little chatbox or a multiplayer tic-tac-toe game.

client.bmx:


serrver.bmx:



B(Posted 2009) [#7]
hey thanks!
i havent looked at it or ran it yet, but thanks for going to all that trouble for me! :)

ill post back when I get it, or when I dont. haha

cheers!

B


B(Posted 2009) [#8]
ok so I sorta understand how it works and all.

however I had my friend run the client after I ran the server and the client and he couldnt connect to me. I also had us both run the server and then the client and we didnt see eachother. Was the program supposed to do that or was it not meant to do that, as it was only a small sample program to try and get my up to speed.

thanks for all your help so far, and dealing with my obvious noobness. :P

B


AltanilConard(Posted 2009) [#9]
Well, the client connects to local host right now. First change the SERVER_IP$ (in the top of the clients code) to your ip. Then compile the client and send it to your friend. Next you'll have to make sure the SERVER_PORT% on your computer is open, if you're behind a router that is (look on www.portforward.com if you don't know how to do this). Now, when you run the server, your friend should be able to connect just fine (you should be the only one running the server, your friend does not have to open his port to connect to you).


B(Posted 2009) [#10]
wow thanks! ill definitely try that soon. That makes alot of sense.

thanks again conrad.
ill post back when I get it working, and ill try to make my own modifications to it.

I like how it senses which button you pressed and sending and recieving to the server,
its really interesting!

thanks again

B