Theory Of Online Gaming
In this article I am going to explore with you the theory of online multiplayer gaming and teach you the concepts so you can start programming your online games with ease. I'm going to try and explain it in the easiest ways possible for I had vast amounts of problems when first programming my online codes. When I mention snippets of code it will be using a dll called 39dll v2 by 39ster which is a very nice extension. So if you want go to his topic (a simple search at the GMC (gmc.yoyogames.com) should do the trick) and intergrate the scripts into your online game to get this to work.
First I'm going to list some online connectivity jargon you should familiarise yourself with:
Server: This is basically any computer connected to the internet.
Internet Protocal Address: Also known as an IP Address or simply an IP, this is the unique identifyer for each computer connected to the internet. This is basically the same as a telephone number, you must dial the number to connect.
Port: This is a gateway if you like into the computer messages are send to and from a port where appropriate. HTTP Internet browsers use port 80 and the reason that there are different ports is so that all the data doesn't get mixed up, When you phone someone there might be several people who could pick up the phone, you say which person you want to speak to and then exchange messages with them which leads into the next part.
Packet(s): Or sometimes known as messages are pieces of data on travelling down internet wires. These are how two computers exchange data with each other. So if a web browser requested a webpage the web browser would send a message to a server requesting a webpage and then the server would send messages back which contain the webpage.
Buffer: This is a place where data is temporary written to or read from. If a computer received a message it would be written to a buffer where the computer can then read the information. When a computer wants to send data it must first write it to the buffer then send the information in the buffer to the other computer.
Host: This is the name given to the computer which is the main link for all internet data transaction within a star network. This is how most online games are programmed. The host computer will be connected to everyone but itself in the network (network being everyone playing the online game which is usually about 8 or 16 max); and when the host receives information it will send the relavent information to everyone else on the network to synchronise everyones game.
Client: This is simply any computer connected to the host computer. It gets sent information about all the other players in the game and in return sends its own information about the player on that computer.
Socket: This is a connection between two computers that messages are sent down.
Okay don't worry if you don't get all that at first because later on in the article I'm going to show you some GML. Another important thing to point out in online games is the use of puppets, if your blowing someones brains out playing online on Counter-Strike your actually blowing out the brains of a puppet and heres how it works:
The player (the one whos brains your blowing out), lets say s/hes a client, sends a message through a socket to the host, telling the host whos blowing his/her brains out and that the player is dead, then the host, lets say hes the only other player so theres no need to forward this message to any other players, reads the message and applies appropriate action to the pupput (this is the object on the hosts screen mimicking the other player) which would be to kill the object and draw text in the screen saying that "You killed him/her". And that's how it works.
And heres a healthy dose of code for 39dll v2.
The host opens a port and listens for incoming connections:
Then in the hosts step event s/he checks for incoming connections from clients:
The clients code to connect to an IP is:
The code to send a message to a socket is:
The code to recieve a message from a socket is:
I strongly reccommend that you do check some 39dll tutorials before diving into this stuff because it can get quite complicated.
And that concludes my article on the theory of online gaming, I hope this has been useful and that you have come out of it with a more improved knowledge of the subject. Thanks for reading.
-Adam
In this article I am going to explore with you the theory of online multiplayer gaming and teach you the concepts so you can start programming your online games with ease. I'm going to try and explain it in the easiest ways possible for I had vast amounts of problems when first programming my online codes. When I mention snippets of code it will be using a dll called 39dll v2 by 39ster which is a very nice extension. So if you want go to his topic (a simple search at the GMC (gmc.yoyogames.com) should do the trick) and intergrate the scripts into your online game to get this to work.
First I'm going to list some online connectivity jargon you should familiarise yourself with:
Server: This is basically any computer connected to the internet.
Internet Protocal Address: Also known as an IP Address or simply an IP, this is the unique identifyer for each computer connected to the internet. This is basically the same as a telephone number, you must dial the number to connect.
Port: This is a gateway if you like into the computer messages are send to and from a port where appropriate. HTTP Internet browsers use port 80 and the reason that there are different ports is so that all the data doesn't get mixed up, When you phone someone there might be several people who could pick up the phone, you say which person you want to speak to and then exchange messages with them which leads into the next part.
Packet(s): Or sometimes known as messages are pieces of data on travelling down internet wires. These are how two computers exchange data with each other. So if a web browser requested a webpage the web browser would send a message to a server requesting a webpage and then the server would send messages back which contain the webpage.
Buffer: This is a place where data is temporary written to or read from. If a computer received a message it would be written to a buffer where the computer can then read the information. When a computer wants to send data it must first write it to the buffer then send the information in the buffer to the other computer.
Host: This is the name given to the computer which is the main link for all internet data transaction within a star network. This is how most online games are programmed. The host computer will be connected to everyone but itself in the network (network being everyone playing the online game which is usually about 8 or 16 max); and when the host receives information it will send the relavent information to everyone else on the network to synchronise everyones game.
Client: This is simply any computer connected to the host computer. It gets sent information about all the other players in the game and in return sends its own information about the player on that computer.
Socket: This is a connection between two computers that messages are sent down.
Okay don't worry if you don't get all that at first because later on in the article I'm going to show you some GML. Another important thing to point out in online games is the use of puppets, if your blowing someones brains out playing online on Counter-Strike your actually blowing out the brains of a puppet and heres how it works:
The player (the one whos brains your blowing out), lets say s/hes a client, sends a message through a socket to the host, telling the host whos blowing his/her brains out and that the player is dead, then the host, lets say hes the only other player so theres no need to forward this message to any other players, reads the message and applies appropriate action to the pupput (this is the object on the hosts screen mimicking the other player) which would be to kill the object and draw text in the screen saying that "You killed him/her". And that's how it works.
And heres a healthy dose of code for 39dll v2.
The host opens a port and listens for incoming connections:
global.listen=tcplisten(10101, 8, 1); // 10101 is the port to open, 8 is the maximum amount of incoming connections, don't worry about the 1.
if global.listen<=0 show_message("Failed to listen for connections on port 10101. Go to www.portforward.com to help solve this problem.") /* Port forward is actually a really good website you should visit if you get this error*/
Then in the hosts step event s/he checks for incoming connections from clients:
sock=tcpaccept(global.listen,1); // waits for incoming connections and then accepts them if (sock) then global.client_sock=sock; /* stores the connection id or sock in a variable global.client_sock, if there are more than 2 players I'd suggest you use arrays to store the sock info.*/
The clients code to connect to an IP is:
global.host_sock = tcpconnect("127.0.0.1", 10101, 1); // "127.0.0.1" is the IP your connecting to i.e. the server IP
if (!global.host_sock) then show_message("Unable to connect to server");
The code to send a message to a socket is:
clearbuffer();
writebyte(x); // writing the value of x to the buffer
writebyte(y); // writing the value of y to the buffer after the x
writestring("hello"); /* writing the string "hello" after the y value (you must read these values in the same order on the recieving computer)*/
sendmessage(global.client(or host)_sock); /* please don't literally write global.client(or host)_sock here what I merely mean is you type global.host_sock if your the client, or global.client_sock if your the host*/
The code to recieve a message from a socket is:
size=recievemessage(global.client(or host)_sock);
if size<=0 exit; // if this occurs it means the other player(s) havn't sent any messages
x=readbyte(); // reading the values from the buffer
y=readbyte();
string=readstring("hello");
I strongly reccommend that you do check some 39dll tutorials before diving into this stuff because it can get quite complicated.
And that concludes my article on the theory of online gaming, I hope this has been useful and that you have come out of it with a more improved knowledge of the subject. Thanks for reading.
-Adam
0 Comments On This Entry
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
-
Theory Of Online Gamingon Mar 02 2008 05:30 AM
-
Why And How To Use Surfaceson Feb 22 2008 09:09 AM
-
Announcing...on Feb 18 2008 02:29 PM
Search My Blog
5 user(s) viewing
5 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment








|