I need to make a web based game using flash etc for my college project. I want users to log on and select a room. With a max of 5 players in one room, the 5 players compete with each other on the board(like yahoo games).
My prob:
I dunno how to divide the users ino rooms.
I dunno how to control 5 or less players in a room playing the same swf.
Wow that would be some master coding. I don’t know if you could even do that with the basic Flash. Actually, there is probably a way to count the number of users, store it as a variable, and then each time a user enters the site, check the variable. If the number is more than 5, you oculd probably redirect him to another .swf. I don’t know…
Assign each room and array. When a user wants to go to a room if the array for that room is not full then add him to the array.
As for controlling users in the same room, u need to build a server/client system.
The important instructions are done by the server. The client just makes requests from the server.
For example
on SERVER:
function updateText(textString)
{
textBox=textBox+textString;
for(i=1;i<5;i++)
{
client*.textBox=this.textBox
}
}
on CLIENT:
function sendText(textString)
{
server.updateText(textString)
}
OK so this isnt actally how you reference the client and server, ull have to figure that out but the message passing is the same. a client invokes the sendText when he enters a message and clicks send, the function then passes this to the server who then passes that string out to all users. U would then have a method updateText ont the client :
function updateText(textString)
{
textBox=textBox+textString
}
Thank you Dravos my friend. Great Help!
The room thing in an array is a cool idea.
I was thinking I would have to do this stuff in php or something.
Im still not clear about how to handle different users to use same swf file in same room.
Patola,
I think Dravos’ suggestion about using an Array for each room is a good idea. Another approach you could take is to make each room a node in a linked-list. It might come down to more of a personal preference (as it would work either way), but I just thought I would make the suggestion.
or if you want to get complicated and rooms came under categories which came under categories you could consider using binary or multi noded trees! but its only a small project!