Efficient Multiplayer Coding

For questions about using Classic.

Post » Mon Jun 07, 2010 11:21 pm

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.
B
15
S
2
G
3
Posts: 50
Reputation: 1,863

Post » Tue Jun 08, 2010 3:07 am

It seems like all I do now days is answer posts asking for more details... ;-) but I do think more would be helpful here.

[quote="L5j":1xdwfxzm]I want to include a variety of classes[/quote:1xdwfxzm]
This isn't clear what classes are? I'm guessing an RPG type class like Wizard, or Warrior, etc...

[quote="L5j":1xdwfxzm]hot-seat multiplayer game[/quote:1xdwfxzm]
Will everybody use the exact same controls?

[quote="L5j":1xdwfxzm]code all the skills and abilities for every class FOUR times for each player[/quote:1xdwfxzm]
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?
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Tue Jun 08, 2010 9:34 am

[quote="scidave":2ijsusx0]
This isn't clear what classes are? I'm guessing an RPG type class like Wizard, or Warrior, etc...[/quote:2ijsusx0]

Yes precisely.

[quote="scidave":2ijsusx0]Will everybody use the exact same controls?[/quote:2ijsusx0]

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.
B
15
S
2
G
3
Posts: 50
Reputation: 1,863

Post » Wed Jun 09, 2010 2:35 am

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
B
8
S
3
G
7
Posts: 835
Reputation: 5,313


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests