The Daily Click ::. Downloads ::. Engine ::. Online Lobby Example (with movement)
 

Online Lobby Example (with movement)
Author: Solgryn Submitted: 28th February, 2010 Favourites:0
Genre: Engine Downloads: 492
Rated:


This is how it works

1st creates game:
when "create game button" clicked:
>send message 'gamename' to subchannel whatever


when peers recieve that message, they will add the name to a list object or whatever

now, peers can join that game by selecting the name and pressing join

this will send another message, also we indicate which game the peer wants to join by putting the game name in a string (we'll use that later):
when "join button" clicked:
>send message "I just joined"+'game name' to subchannel whatever
>set global string a to 'game name'


When theres enough players, the 1st will start the name. Notice theres only 1 peer joined, the second peer haven't joined the game yet.

the 1st player (The one who created the game) presses the start game button. And by that, he sends a message:
when "start game button" clicked:
>send message 'gamename' to subchannel whatever
>next frame


when a peer recieves that message, and their alterable string is == message, they will join the channel and go to next frame:
when message recieved == global string a:
(you could also send a message like 'I left the lobby to play 'game name' or something)
>next frame


when a peer that haven't joined the game recieved that message, we'll delete it from the list.
when message recieved <> global string a:
>list: delete line (Find string exact) 'message recieved'


also, have a disconnect at the end of frame
end of frame:
>disconnect


when the players go to the next frame, they will connect as usual but join the channel 'global string a' (the game name, remember?), this does that only those people
can see each other etc.

Review This Download



   


http://www.solgryn.org/Stuff/Random/LobbyExampleSolgryn.zip (21.21 kb )



Posted by Sumo148 1st March, 2010
Rated :

It's a good example, except that there's a huge flaw :/ If you host a game, and then a player connects to the lobby after he cannot see the games that are currently playing...

That what my example seemed more complicated to Sketchy because I had to connect to two channels at once and test to see if a peer just connected on the lobby channel.

The rest is a good example though! (I downloaded it from the forums, so that's why it looks like I didn't download it )
Comment edited by Sumo148 on 3/1/2010
 
Posted by Sketchy 1st March, 2010
Rated :

Sumo makes a good point, but it's an excellent example apart from that, and I certainly found it very helpful.
Thanks again
 
Posted by Noah2006 5th March, 2010

you use no udp on game or ?

 
Posted by Mark McCauley 21st March, 2010

u asking because u have trouble connecting? using udp or tcp ? i dunno ill keep quiet in case im asked what i mean
 

 



Author

Favourite



Advertisement

Worth A Click