2016년 12월 22일 목요일

Multiplayer Games -- One Canvas


This is posted from my student:

Is it possible to have a local multiplayer pong game? If so how? I have one canvas and two dragged event handlers for each paddle. I want them to act interdependently from each other but you can only move one at a time but some times they sync up and they do the exact same thing and I don't want that to happen.   


--
Perhaps search the Gallery for pong?   There is at least one app that claims to do exactly what your student intends...  Pong (2 Player)...does it work?   You need to try the aia.  there may be more...I did not review the code.

Can the student code be made to work?   Possibly.  It is very difficult to debug animation code without an aia.  It may be necessary to provide some  if..then statements to keep one player from acting while it is the other's turn to return the ball.   I do not see any code like that in the example.    A thing to look at might also be the Ball.Interval  which might be too short, might try increasing that value.   AI2 graphics are very slow compared to graphics from other compilers and processing is asynchronous  (One event must finish before the next starts) ...possibly why their is a current synchronization issue?

Here is some forum advice about building multi-player games.

Merry Christmas, Wesołych Świąt,  Feliz Navidad, God Jul, Joyeux Noel, Καλά Χριστούγεννα, Happy Christmas, Veseloho Rizdva, Prettige Kerstdagen, Frohe Weihnachten!, 성탄 축하 , Buon Natale,  聖誕快樂 ,  圣诞快乐,  Sretan Božić, C рождеством!,  عيد ميلاد مجيد

-- 
Also search this board for multitouch.
That will send you far afield into manifest editing, extensions, and JavaScript stunts in the Web Viewer.

For an easy straw to grasp, try two canvases, one per player,
with a ball on each canvas that hides itself when it reaches the 
edge of the other canvas, and signals the other canvas's ball to 
proceed from that edge onwards.

Before programming the multiple ball trick,
verify that the two canvases' paddles can be dragged
simultaneously.
That might not be the case, without multitouch capabilities.

--
I tried two canvases on an old device (Android 2.2).
Only one canvas responded to drags at a time.

You will probably need a multitouch hack.

-- 

댓글 없음:

댓글 쓰기