Is multiplayer "ghosting" possible?

Get help using Construct 2

Post » Thu Mar 08, 2012 9:41 pm

Alright so I heard of Construct 2 through their reddit post on /r/gamedev and it really appealed to me as one man team who is artistically inclined but rather bad at code. On their post I asked about multiplayer and they informed me that turn-based multiplayer was possible but real-time was not, due to engine limitations.

Knowing the multiplayer limitations but not exactly sure the full limits of them, my question is as follows: Is it possible for one player to issue a challenge to another, carry out that action, then when player two is ready to accept that challenge, compete with player one in real time in that regard? So basically, player one would be competing against time while player two would be competing against player one. Is Construct capable of doing this or can I only have both players compete against time and compare after both are finished?

Thanks for taking the time to read this,
Plague
B
1
Posts: 5
Reputation: 410

Post » Thu Mar 08, 2012 10:23 pm

I suppose it could be possible, if you develop an algorithm to turn a sequence of moves into a long string, and convert it back on another computer.

Also, if you don't know good server coding, you probable need to forget multiplayer gaming for the moment!

(Keep in mind this is all based off what I have heard. I could be entirely wrong.)

Make sure you browse the plugins section as you will need third party plugins to facilitate multiplayer.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Mar 09, 2012 3:48 am

@Plague

Construct 2 doesn't currently offer the functionality you need. And as squiddster indicates, it's the server-side coding that's critical. The challenges/actions of your players have to be communicated by the server component of the game. Real time is certainly possible if you've got a capable server.

There are multiplayer plugins currently under development to handle the client/Construct side of the game. You can read about them in other threads - Here's one thread that will give you more info.Velojet2012-03-09 03:50:55
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Mar 09, 2012 4:23 am

Really appreciate the responses! I will research all I can about the multiplayer plugins to investigate how far I can push turn-based combat.

If it helps paint a picture, I plan on releasing to smart phone devices.Plague2012-03-09 04:28:50
B
1
Posts: 5
Reputation: 410

Post » Fri Mar 09, 2012 2:10 pm

@Plague, what kind of game do you think?

I'm thinking about something using ajax: posting/getting every player action to/from server, so comparing previous values could perform the other player's action.
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Fri Mar 09, 2012 4:25 pm

@ Cassianno

Yes I believe something to that effect would work nicely. I plan on having two systems, a turn-based 'combat' back and forth (when Player 2 plays, Player 1's play is played back in a short sequence, similar to the "With Friends" games). The part that I am not sure if it is possible is essentially the second competition system. In which, player one competes against time and player two competes against a replay of player 1 (like when you try to beat your "ghost" in old racing games).

To simplify things, the latter is basically a racing system and, since real time racing seems difficult to pull off, I wanted to try and figure out how to sequence them to give the illusion of real-time, with the benefit of doing it when the player wants, which is essential for someone using a mobile app.Plague2012-03-09 16:27:06
B
1
Posts: 5
Reputation: 410

Post » Fri Mar 09, 2012 7:50 pm

@Plaque

AJAX will be ok for your turn-based system, but for your real-time competing, the only way to go is WebSockets. Both the C2 plugins currently under development use the socket.io implementation of WebSockets.
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Mar 09, 2012 10:57 pm

@Velojet

Sorry if I was confusing, I don't want to do any realtime stuff. I believe turn-based systems are superior for tactics as well as convenience on mobile devices. I understand that realtime processing is pretty difficult to do, especially for someone like me who is very much a newbie with code. I proposed a pseudo-realtime model in which player 1's action is repeated to player 2 so player 2 is not confused as to what exactly happened. To take it a step further, I wanted to see if it was possible for player 2 to take their turn over player 1's turn (for things like racing). Similar to how in say, Mario Kart, you could do time trials against yourself, which would appear as a ghost.
B
1
Posts: 5
Reputation: 410

Post » Sat Mar 10, 2012 3:24 am

@Plague : one way of doing the ghosting would be to record the key presses (up or down) that a player does and record the time (relative to the start of the turn, current_time - beginning_time) when that event happened. You could store that info into a string by appending to the string every time that event happens, and separate the info with commas to separate events and a ! for separating the time from the event type. At the end of the turn, your string would eb something like:

L!D!3.10,L!U!7,L!D!14,L!U25...

Where L is a code for the Left key, D is key down, U is key is up and the numbers are the seconds since the start of the turn. Now for smarthphone, I am not sure what events you will use to move the player, but you can use the same idea. When the turn ends, you can send the string via AJAX to your custom server (you or somebody will have to write the server-side code) and when the other player (player2) can chooses to refresh his screen to receive any new data, your C2 code will need to do another Ajax request to ask for any new data.

Your server side code will need to return the string sent by the other player. Once the string arrives at player2 via Ajax, you can devise something to split the string into arrays and then call each of the events at the time associated with them by using the compare "Compare Time" condition to compare the relative time with the time registered in the string for the 1st event.

The above is a very high level overview of what you could do, it will take you some time to tune up by trial and error and may or not work for you.
B
26
S
7
G
3
Posts: 118
Reputation: 4,264

Post » Sat Mar 10, 2012 4:23 am

@Juantar

Thank you for the descriptive explanation! I will be sure to save this information. Do you know of any server architectures I could use that would be more reliable than a home-run one? Would OpenFeint have the capabilities I needed to do this type of stuff?
B
1
Posts: 5
Reputation: 410

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests