How do I make turn based multiplayer game

0 favourites
  • 11 posts
From the Asset Store
A well commented RPG game template to learn from or use as a base for your own game!
  • Hey Guys.

    I am trying to fig. how to make turn based multiplayer game.

    can anyone help and share how would i code that.

    Thanx

  • Hi 007. You could use a variable that keeps track of who's turn it is and then only enable input from that one player at any time. An AJAX / json call at the end of the "live" player's turn would let the server know that "play" should pass to the next person. Waiting players would then make similar calls at appropriate intervals to check whether it's their turn yet.

  • There are simple tutorials (4) for Multiplayer Object. Multiplayer Object have some bugs but it work well for sign/login and sending messages. Try to avoid all other functions - only use SendMessage (and parse messages with tokenat).

  • There are simple tutorials (4) for Multiplayer Object. Multiplayer Object have some bugs but it work well for sign/login and sending messages. Try to avoid all other functions - only use SendMessage (and parse messages with tokenat).

    What bug are you talking about? I never encounter one so far since the last time I reported.

  • To DuckfaceNinja: I stoped posting bugs to C2 because I see that developers are "bombarded" by tons of other problems with C2. I think they need to grow support up...

    Back to Multiplayer Object... for example small lag when new user join room. If you create smooth animation or movement, all objects lag when new user connect.

    Śometimes I see ghost Host user (I use same name for all hosts) even if they are at different instance and room! Host join an empty room but this ghost user is already in (and is host too for different room and instance)!!!

    Peers not want to leave room or even log out from server (this happens all the time). I saw this problem at someone else here on forum. So If I want a Peer to logout, I must ose Browser.reload().

    Sometimes if you active EditBox or stuff like that (I think it have something with focus ability), Multiplayer Object stops receive (or send?) messages. Friends sometimes report this and it happens lots of times when they start type chars into chat...

    BTW I not use Sync or other functions. Only use SendMessage. This work well but sometimes it looks slow even when ping is < 20ms. I saw lags over seconds at one browser window while second browser was allright!

  • Back to Multiplayer Object... for example small lag when new user join room. If you create smooth animation or movement, all objects lag when new user connect.

    I never experienced this, how many object are you using? I used a lot before, and found out host bandwidth is the limiting factor. That is why a lot of my answers in this forum emphasize on not using the sync object when it is unnecessary. I doubt it's a bug on plugin, most likely bandwidth problem.

    Śometimes I see ghost Host user (I use same name for all hosts) even if they are at different instance and room! Host join an empty room but this ghost user is already in (and is host too for different room and instance)!!!

    Have you reported this with capx? I never tried this, if it is genuinely a bug, then report it. Or give me link if you have reported this, I'll check it out.

    Peers not want to leave room or even log out from server (this happens all the time). I saw this problem at someone else here on forum. So If I want a Peer to logout, I must ose Browser.reload().

    Are you sure your event is properly executed? I never experience this problem as well, I can even automate the process of leaving/joining room without problem but I admit the events are not simple at all.

    Sometimes if you active EditBox or stuff like that (I think it have something with focus ability), Multiplayer Object stops receive (or send?) messages. Friends sometimes report this and it happens lots of times when they start type chars into chat...

    I never tried this as well, ditto to second point.

    BTW I not use Sync or other functions. Only use SendMessage. This work well but sometimes it looks slow even when ping is < 20ms. I saw lags over seconds at one browser window while second browser was allright!

    I totally expect this, because send message is a reliable-type feature, it is designed in a way that the data packets are arrive no matter what. Lags can accumulate if you sending to much message per tick, and even worse lag if it is reliably ordered. Use different mode of reliability to mitigate lag issue. What is your case of use anyway? If it is real-time non-informative data, just positional object data or dynamic data, you should be using sync object or sync variable.

  • I had made a multiplayer turn based game -Gomoku (five in a row) before.

    It is just a possible solution, I am not sure this framework could be suitable for all cases.

  • To DuckfaceNinja:

    lag when user connect to Host happens often - even when I tested it on one computer (so ping was 0). You must create smooth animation / movement to detect it. It is small lag but it can ruin project with lots of users. Try it.

    Ghost Host user from different instance and room ... Friends saw it too in list of peers. Happens 2 times while we test multiplayer. We detect it because Host have allways same name and when it happens, it add "2" to the end of name and show Gost Host in list. But he not receive and send messages like other Peers. If true Host leave room and all Peers ware disconected, he were not. Another login to room and he was there!

    Leave room/disconect for Peer... I tryed create simple button for it but nothing work. I studied tutorials too but only Browser.reload works. Maybe you just not detect it. Create Server(Host)-Client(Peer) project and show number of Peers every 1 second. If Peer leave room, will number of Peers decrease? ... Not in my project.

    For SendMessage you can choose a reliable-type option. Project I use send to Host around 4 messages / sec. I tested even 200 without problem. It is not problem of bandwidth but C2.

    Multiplayer Object can be powerful even for games but C2 have other problems - I do not know if c2 is able to generate high-quality projects ... (( AT THIS MOMENT ))

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • DuckfaceNinja ... you looks like reliable person ... can you try my capx here: *** hmm it not show URL here. Nice one! Post have this caption: Jerking at 60FPS while scrollx/scrolly (made by me). One of my post there have attached capx.

    I have problems with jerkings. Will it jerks too on your system? ... Jerkings are detectable by naked eye. Red Circle change smoothness of movement and sometimes it even do a huge lag. But this project have 0 events and it is only simple bullet behaviour...

    Thank you!

  • Unknow01

    I found that the ghost host is a problem of not deactivating the Host & Peer Groups when a peer disconnects from the room.

    I used the ghost shooter example for my game, and had your ghost host as well.

    Logic of problem:

    Player starts new room becoming host. (Host group activates)

    Player disconnects from room, and joins another room as peer. (Peer group activates)

    Both host & peer groups are now active.

    = Problem

    = Ghost Host

    To fix.

    On disconnect from room --> Set peer group deactivated & --> Set Host group deactivated.

  • Unknow01

    I found that the ghost host is a problem of not deactivating the Host & Peer Groups when a peer disconnects from the room.

    I used the ghost shooter example for my game, and had your ghost host as well.

    Logic of problem:

    Player starts new room becoming host. (Host group activates)

    Player disconnects from room, and joins another room as peer. (Peer group activates)

    Both host & peer groups are now active.

    = Problem

    = Ghost Host

    To fix.

    On disconnect from room --> Set peer group deactivated & --> Set Host group deactivated.

    I think this not fix this. I am not using disconect from from / server because it not work for me. I am using browser reload which do the same.

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)