Real-time multiplayer corona

0 votes

Hi, 

I am new to AppWarp and I am interested in real-time multiplayer games. I have seen the Color Move sample for corona here and got it to work in the simulator. I was wondering if it would be possible to make it so that object positions are always updated like if they were other players in an MMO instead of being updated on mouse release. Would that be possible, if so, how would I go about it.

 

Thank you.

asked Jun 6, 2015 in AppWarp by j.kazma (10 points)

1 Answer

0 votes
Hi,

In the sample, when player moves an object the game sends the new position of the object to AppWarp server, then server sends notification to all the players joined in the room. When the client receives notification then object position gets updated at other player's end.

This process gets triggered when player touch the object and moves it. Two implement your case, you just need to think of strategy for changing the object position instead of touch event in the current sample, for example, you can start sending updated object positions to AppWarp server from the gameloop function based on certain strategy suits for your game logic.

Let us know if it helps.

Thanks.
answered Jun 6, 2015 by rajeev.etc (1,660 points)
So I modified the code to make it send values constantly instead of touch events but I get choppy movements. I might be doing something wrong so I'll look more into it but can AppWarp support real time multi player like an RPG game would?

Edit: It looks like the function onUpdatePeersReceived in the ColorMove example is called in batch as if every few frames, multiple function calls are executed. Is there a way to call it once every frame to make it smoother?
Hi,
onUpdatePeersReceived callback always invoked in response of sendUpdatePeers api, it never gets called in batch. Whenever data flows on network, there is a latency involved and it all depends on the network strength. It can be handled properly as per the game strategy, for example, in this case you can have an array that can store the data you get in onUpdatePeersReceived. Whenever onUpdatePeersReceived gets invoked, you can add the data received to the array. You can always check the array in the game loop to update the object position instead of updating it directly from the callback itself and if there is data then you can update the position with some movement animation. In case array has multiple data then you can use them sequentially.

Let us know if it helps.

Thanks.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...