Efficient Multiplayer Coding

This forum is currently in read-only mode.
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • If anyone could give me a few tips I would be highly appreciative. I'm trying to create a hot-seat multiplayer game. I want to include a variety of classes but I can't seem to wrap my head around the easiest way of designing this. I'm afraid of having to code all the skills and abilities for every class FOUR times for each player. So I know there must be an easier way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It seems like all I do now days is answer posts asking for more details... but I do think more would be helpful here.

    I want to include a variety of classes

    This isn't clear what classes are? I'm guessing an RPG type class like Wizard, or Warrior, etc...

    hot-seat multiplayer game

    Will everybody use the exact same controls?

    code all the skills and abilities for every class FOUR times for each player

    Why not have only one character sprite, but multiple instances of him for each player. That way the core abilities will apply to the sprite and only those things unique per player will change.

    But I'm not the best to answer this on the whole as I have not made a hot-seat multiplayer game yet. I though Souljaboy was?

  • This isn't clear what classes are? I'm guessing an RPG type class like Wizard, or Warrior, etc...

    Yes precisely.

    Will everybody use the exact same controls?

    Sorry I didn't mean to say hotseat, I just meant to say local multiplayer. "hotseat" is just a really fun expression to say, so I guess it slipped. It will be simultaneous playing. Because of that I'm wondering for every event in which I must say "Player 1 is pressing" if I'll need to do it for every player. Now I'm thinking of all the skills, maneuvers,spells etc, and how this could be very lengthy. So far I all have them using the same sprite but different "collision boxes" for lack of a better term. I just don't know the most efficient and smartest way to go about coding this. Since the code for the 4 players will be completely identical, I'm thinking there has to be a good approach to take.

    On a sidenote, I just want to thank you scidave, not just for your help here, but your contributions to the community as a whole. Your tutorials, particularly the rpg one I read on here, have been very helpful and inspiring. I hope to be able to return the gesture to the community later on, even if its just something small like releasing the cap file to my game so others can learn.

  • Thanks L5J, I'm happy the tutorials and info has been useful!

    What I would do is try to make things as generic as possible. Hopefully someone here that has made a local on one machine multiplayer will chime in.

    If I had to do it this is what I would invision. What you want to do is have a function that says if "player X" is pressing then do X. Everything in that function will then take action on things that relate to player X. For example, an array with X being an index into the stats, power, skills, etc for that particular player.

    For example, let's say the player 2 wants to cast the "fire" spell. They hit some button to switch to the "fire" spell. This calls a generic function to set an array index value (to "fire") based on the the player #. Then when that player in the future cast a spell. This calls a generic cast function which is called with a parameter which is the player #. You set the player number by checking a range of keys pressed or certain keys pressed. That would be some of the only code that is player specific.

    Now, you may run into synchronization issues where two players are trying to cast spells at the same time.. but it is worth experimenting like that. You may need to have more complex logic to handle that case. So to summarize.. lots of generic functions

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