multiplayer over the network
multiplayer over the network
Hello,
I wanted to add another player to my little game but it would be nice to have it over the network - so my question is how to start.
In short:
1. two people start the game on two computers
2. one computer finds the other one so the programs can communicate with each other (by communicate I mean sending sprite position so the movement of both players can be visible on each computers)
If this is possible I think I could find the solution by "hit and miss" method but it would take a long time since I have no idea where to start.
Thanks for any help/suggestion/example in advance.
I wanted to add another player to my little game but it would be nice to have it over the network - so my question is how to start.
In short:
1. two people start the game on two computers
2. one computer finds the other one so the programs can communicate with each other (by communicate I mean sending sprite position so the movement of both players can be visible on each computers)
If this is possible I think I could find the solution by "hit and miss" method but it would take a long time since I have no idea where to start.
Thanks for any help/suggestion/example in advance.
Re: multiplayer over the network
I am not made such code yet, so just guesses.
1. It is a big difference if you want to MP on LAN or over the Internet.
2. If you choose LAN, then the problem much simpler. Choose a port to communicate. Send messages by that port to all of your IP range. The IP with a reply will be your MP partner.
3. Over the Internet, you have to use a server or have to set port forwarding on the routers at each side.
4. Over the Internet you have no guaranteed transfer times.
1. It is a big difference if you want to MP on LAN or over the Internet.
2. If you choose LAN, then the problem much simpler. Choose a port to communicate. Send messages by that port to all of your IP range. The IP with a reply will be your MP partner.
3. Over the Internet, you have to use a server or have to set port forwarding on the routers at each side.
4. Over the Internet you have no guaranteed transfer times.
Re: multiplayer over the network
Over the Internet would be nice but if that's more problematic than I'll try over the LAN first.
So i means I have to use CreateServer() command on one computer and then OpenConnection() on the other one?
So i means I have to use CreateServer() command on one computer and then OpenConnection() on the other one?
Re: multiplayer over the network
Or you can set up a listening server at each side.
It really depends on the type of the gameplay.
It really depends on the type of the gameplay.
Re: multiplayer over the network
I do need some help here - just to establish the connection.
I have no idea how network works all these servers, ip's and other stuff is just a black magic to me - but I know that once I make the "connection between two hollywood programs I will manege the rest
I run this command on one computer (just removed p_functionHandler and installEventHandler stuff)
a little bit later in the program I have the following:
and the output eg:
and I get an error:
I have no idea how network works all these servers, ip's and other stuff is just a black magic to me - but I know that once I make the "connection between two hollywood programs I will manege the rest
I run this command on one computer (just removed p_functionHandler and installEventHandler stuff)
Code: Select all
server$=CreateServer(Nil)
Code: Select all
DebugPrint(GetLocalIP(serverID,#NETWORKSERVER))
DebugPrint(GetLocalPort(serverID,#NETWORKSERVER))
Now I move to the other computer and write:0.0.0.0
7316
Code: Select all
OpenConnection(1,"0.0.0.0",7316)
Please do not laugh just helpcannot assign requested address
Re: multiplayer over the network
Though 0.0.0.0 is a valid IP address, it has a special meaning, It means not only local host but also: only available locally. Thus calling it is only possible from the same machine. If you run your client code on the same computer, you will be successful in connecting. When you try to connect from your second computer to the 1st one (the one running your server), you have to use the address of your 1st computer that it has in the network. Most often it is sth. like 192.168.0.x. Open a Shell on your 1st computer and type ipconfig or ifconfig (depends on the OS used) to find out your network address.
Re: multiplayer over the network
Thanks for that answer - that helped me a lot !! - I've connected 2 computers.
Just last one question:
follwing command
generates a port number - how do I know (being on the client computer) what port that is?
Up to now i used (on the server side):
and the resulting number (eg. 5167) )I put into the following command on client computer:
Thanks
Just last one question:
follwing command
Code: Select all
serverId=CreateServer(Nil)
Up to now i used (on the server side):
Code: Select all
DebugPrint(GetLocalPort(serverID,#NETWORKSERVER))
Code: Select all
openConnection(Nil,"192.168.1.4",5167)
Re: multiplayer over the network
You cannot. But CreateServer has a 2nd argument. You can set a port number as you wish. (later you can migth want to make it configurable).
Re: multiplayer over the network
How could I miss it
Thanks !!!
I know I said "last question" but...
as you can see on the picture I have my project running on two computers
The problem I'm facing now is .. the speed
Whenever I use arrows to move my hero on the left laptop then the right "freezes" for about 3-5 seconds - it happens because of the following command:
That whole data I'm sending/receiving is only one number between 0 and 300
Is it always taking so long? The network I'm using is very fast (I think).
Thanks !!!
I know I said "last question" but...
as you can see on the picture I have my project running on two computers
The problem I'm facing now is .. the speed
Whenever I use arrows to move my hero on the left laptop then the right "freezes" for about 3-5 seconds - it happens because of the following command:
Code: Select all
playerTile=ReceiveData(clientID,#RECEIVELINE)
Is it always taking so long? The network I'm using is very fast (I think).
Re: multiplayer over the network
I'm not deep into the internet stuff, but maybe you better try an UDP connection instead? Hollywood docs state it's faster, but one has no guarantee the data arrived.