A "kind of" multiplayer game idea.

New releases and general discussions.

Post » Thu Apr 07, 2011 12:23 am

This is my first post so here it goes..

My idea of simple and easy multiplayer game is sharing a file containing player position:

1- we share a folder named positions through a lan network or vpn.

2- we make 2 similar games, player1 and player2. both have player 1 box and player2 box.

3- both games have 2 editboxes, one to write and one read.

4- every 1000 milliseconds player1 game writes player1 position to a hashtable using keys posxp1 and posyp1 and then saves a file named p1.lol to a local network address that has been written in the write editbox.

5- every 1000 milliseconds player2 game writes player2 position to a hashtable using keys posxp2 and posyp2 and then saves a file named p2.lol to a local network address that has been written in the write editbox.

6- every 1000 milliseconds player1 game reads player2 position file p2.lol from the read editbox address to a hashtable using keys posxp2 and posyp2 from the shared folder.

7- every 1000 milliseconds player2 game reads player1 position file p1.lol from the read editbox address to a hashtable using keys posxp1 and posyp1 from the shared folder.

8- every 1000 milliseconds player 1 game sets player2 position x and y to the values of the hashtable p2.lol

9- every 1000 milliseconds player 2 game sets player1 position x and y to the values of the hashtable p1.lol

10 on the player1 game you only control player1 box.

11 on the player2 game you only control player2 box.

p1.lol = (102 bytes)
p2.lol = (102 bytes)

here is an example video:

[code:24gr0vn7]http://www.youtube.com/watch?v=jkYo5vKsm5U[/code:24gr0vn7]
B
1
G
1
Posts: 9
Reputation: 443

Post » Thu Apr 07, 2011 1:01 am

Welcome to the forum!

Very wild and interesting idea to share files for positions. It isn't really practical (the lag is abysmal, but you could always lower the check time to every game tick) though as you begin to add more and more objects this will become unwieldy quick.

Still very cool first post. Looking forward to seeing your next demo. :-)
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Thu Apr 07, 2011 1:10 am

[quote="scidave":3fdogp48]Welcome to the forum!

Very wild and interesting idea to share files for positions. It isn't really practical (the lag is abysmal, but you could always lower the check time to every game tick) though as you begin to add more and more objects this will become unwieldy quick.

Still very cool first post. Looking forward to seeing your next demo. :-)[/quote:3fdogp48]



Thanks for the feedback and sorry for not introducing me in some way.
Yes it has a lot of lag, i think its more suitable for board games like chess or card based games.
I did this because i wanted to make a game like stranded II but with multiplayer (at least 2 players).
Checking every tick should be better than 1 sec of interval.
B
1
G
1
Posts: 9
Reputation: 443

Post » Thu Apr 07, 2011 1:21 am

scidave youre the man!! ;) look the video. now with every tick instead of 1000 milliseconds. it's instant. but im doing it in the same computer. so it should have some 10 ms of lag between 2 LAN pc's.
[code:1wc8ygu8]http://www.youtube.com/watch?v=_nCog43WN9A[/code:1wc8ygu8]
B
1
G
1
Posts: 9
Reputation: 443

Post » Thu Apr 07, 2011 10:49 am

could this work with files shared over dropbox or box.net?
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Thu Apr 07, 2011 1:02 pm

This isn't a good way to design a multiplayer game! You shouldn't use files on disk (you're moving the mechanical drive head when you could be reading directly from memory), and using files or HTTP is the wrong protocol. These systems are designed for one-off transmissions: open connection, transmit data, close connection. You're introducing a huge amount of open-close overhead for every single message. Also, these protocols are designed for file transmission, where latency really isn't a big deal. They are only concerned with eventually getting the data there, rather than working in real-time. There's also no message ordering so you can get your data reordered in transmission and your players start jumping all over the place. The right way really is to open a socket connection and stream data. That solves all these problems, and was designed for such purposes.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Apr 07, 2011 1:49 pm

i understand. i would have only been using it for turn-based stuff, where speed is not important, nothing real-time.

as for the 'sockets', i'm sure they work great, i just don't know how to use them...lol.

but from what tom has been illuminating to, this 'could' become part of c2...natively.

...so there's that.
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Thu Apr 07, 2011 3:41 pm

[quote="harrio":3uugctw2]could this work with files shared over dropbox or box.net?[/quote:3uugctw2]

maybe, i tried an ftp but it took too long.
B
1
G
1
Posts: 9
Reputation: 443

Post » Thu Apr 07, 2011 3:50 pm

[quote="Ashley":oscj5tu7]This isn't a good way to design a multiplayer game! You shouldn't use files on disk (you're moving the mechanical drive head when you could be reading directly from memory), and using files or HTTP is the wrong protocol. These systems are designed for one-off transmissions: open connection, transmit data, close connection. You're introducing a huge amount of open-close overhead for every single message. Also, these protocols are designed for file transmission, where latency really isn't a big deal. They are only concerned with eventually getting the data there, rather than working in real-time. There's also no message ordering so you can get your data reordered in transmission and your players start jumping all over the place. The right way really is to open a socket connection and stream data. That solves all these problems, and was designed for such purposes.[/quote:oscj5tu7]

you're right, but aren't browser games working like that, like writing sql or txt on a server hard drive?
I'm no coder, i only had vb6 in school and that was 5 years from now. Is there a topic/tutorial showing how to send players position, health, ammo with that socket connection? not that podsix network, just something simpler.

edit:
I was thinking, what if we play the game using a ramdisk? no moving parts, pretty fast, no damage to drive. does the write/read trough a network takes a lot of time? I think my ram works at 32 gb per sec and should be fast enough. And my network is 1gigabit lan, so its 100megabytes per second, my example is sending 100bytes every tick, only for player position
Im working on another example now.
This is a noob way of making multiplayer until construct comes with a plugin.
B
1
G
1
Posts: 9
Reputation: 443

Post » Thu Apr 07, 2011 6:31 pm

Sorry, I guess my other post was a bit critical for someone without much coding experience. It's cool that you're thinking through ideas like this, but there are still a few problems:
- you can't assume all your players have a ramdisk (or SSD) - the reality is most people have traditional hard drives
- writing files is probably quite slow, again because it's not designed for latency - complex games might take a framerate hit
- the overhead of writing files is still large, so although your simple case works, you might find you can't add many players or much more data in transmission before it bottlenecks. It's not so much the maximum data rate as the latency that is the problem (i.e. how long it takes the message to arrive, rather than how much data the message holds).

I think R0J0 did some python tutorials on how to use sockets? You might be able to search the forum for that. Also, you could try reading up on websockets - that's what modern browser games use for multiplayer.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests