Forums Kongregate

Multiplayer API suggestion

12 posts

Flag Post

You know how the current HighScroe APIs work? You need about two lines of code, and is increadibly easy to use. I’m thinking we could do something simmilar for Multiplayer APIs.

Basically, what I am suggesting is an API that allows users to easily pass variables through the server. For instance, take a simple pong game. In each frame, player one will have the code for moving his own racket, for dying, for lives, and for the ball bouncing off of either racket. Now, player one would have this in his code:

_root.kongregateStats.givevar(“position”,1, root.racket.x);

root.enemyracket.x = _root.kongregateStats.getvar(“position”,2);

and player 2 would have

_root.kongregateStats.givevar(“position”,2, root.racket.x);

root.enemyracket.x = _root.kongregateStats.getvar(“position”,1);

Ok then. For somebody who knows, I have these questions.

1) Would it be hard to make an API like that?

2) Would the API work quickly, or make the game lag seriously?

3) Would there be a reasonable way to make a “lobby”?

4) Do any games on Kong do this, or did I come up with an original idea?

Flag Post

Come on! Someone has to know more about this then I do!

Flag Post

When you say variables you mean Objects? I think that the current standard is to send and receive Objects and they can be whatever you want

Flag Post

I actaully ment variables. Like a string / value.

Flag Post

It could be pretty straining if used badly – if someone made an (inefficient) game which sent/requested the positions and other statistics of, say, 10 soldiers every frame, and was running at 35fps, each person playing the game would be sending a large number of requests every second. And if you’ve got hundreds of people playing these games…

Flag Post

Well, that is a reasonably easy way, however if done this way, the API would have to throttle the connection to prevent flooding and server overload as Kalinium pointed out. It could wait and construct a packet then send the data at its own intervals, but that removes a bit of control for the developer. It may be wiser to construct your own packet with all the data you want to send, then let the API know you want to send the packet. Technically, you could send a packet using a ‘givevar’ type method, however encouraging and allowing users to send var by var could be severally detrimental to the server.

_root.kongregateStats.send ( “charPacket”, userData );

If you wanted to go the ‘givevar’ way so that the user could avoid the complexities of packet construction, a send() or flush() method could be added that lets the API know its time to send. Meaning you could queue up the data with givevar() but it wouldnt actually send that queued data till the user instructs it. eg:

_root.kongregateStats.givevar ( “x”, racket.x );
_root.kongregateStats.givevar ( “y”, racket.y );

There are lots of ways to go about it, and the implementation would depend largely on whether the developer or the API has more control. However, in the end making it totally ‘dumbed down’ for the developer is not completely an ideal, since a person should know a bit about coding before attempting to make a multiplayer game. Otherwise, we’ll be killing our Kongregate servers for everyone, all for a bunch of crappy multiplayer games that dont work well.

Flag Post

Umm… shouldn’t this be in the programming forums? Cuz I’m confused… :/

Flag Post

Haha, your fancy schmancy flash talk is wasted on normal people like me and yoshi

Flag Post

Confuse the people! HAHAHAHA!

I understand. Good luck with API :)

Flag Post

It is about a KONGREGATE api. SO it has to do with Kong.

Flag Post

Plus, anything that drives home the fact of developers’ obvious superiority over normal users is good :P

Flag Post