Forum C# Creating a multiplayer game from a single player game

Creating a multiplayer game from a single player game

Postby mark.knol » August 11th, 2010, 11:27 am

Hi there,

I have created an as3 pokercardgame application which is almost finished for single players. It checks what hand each player has. I have worked very long on this, since its not very easy to do all the calculations. For now you play agains bots which are very dumb and do random moves :) It would be cool if I can convert this app to a multiplayer app, so I can play agains some friends. The game engine I have written in as3 is very open, so I think it is possible with these setup, but I know I have to wrap code around this to make it happen. Now I have seen some documentation and some samples but I need to know some things before getting in this, maybe you can help me. I have never created an multiplayer game. I have a bit experience with c#, and I'm a flashdeveloper.

The game engine (creating a pokertable/players/getting cards/calculating the winner) is now calculated inside the Flash (clientside). Is it needed to convert the full engine to c#? I have another idea but I don't know if this is possible: Set one player as an 'hostplayer' which creates the pokertable, shares new cards, sends money to the winner of the round etc. This player sends the pokertable-data into to the playerio-database, and other players will receive data that belongs to them (they will be 'receivers' only, who can only bet/fold and update the money of the bank)? This implies that if the hostplayer quits the game, the game cannot continue, but I'm fine with this.
The game doesn't need to be very secure (i know it would be better to do most things from serverside perspective) since this is a fun project for me. I'd love to do minimal coding in c#, Is it possible to let the hostplayer sending stuff to others? Is it possible to send free global objects to the players, so the flash can handle most things? Or do you still think this will require lots of c# coding?

Maybe anyone can give me some tips how to get started.
mark.knol
 
Posts: 3
Joined: February 19th, 2010, 10:16 am

Re: Creating a multiplayer game from a single player game

Postby Oliver » August 11th, 2010, 1:24 pm

Hello.

Since you're saying that "the game doesn't need to be very secure" and you'd like to "do minimal coding in c#" i think it's a good idea if you let one of your players act as "gamemaster" as you propose.

The C# code could be as simple as relaying messages directly to the gamemaster always.

We don't have the concept of global synchronized objects -- you'll have to build that on top of the current system. You could use BigDB if you wanted to share access to the same data, but i don't think it's the best idea in this case.

My recommendation would be to just go for it. Play a bit with some of the simple examples, like DrawPad, and then write some very simple serverside code that just picks a gamemaster and relays messages to/from him.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Creating a multiplayer game from a single player game

Postby fox1980 » August 11th, 2010, 5:24 pm

You can also use the buit-in "bounce" servertype that automatically broadcasts every message it receives to all clients.
That way you wouldn't need to write a single line of c# code.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Creating a multiplayer game from a single player game

Postby mark.knol » August 12th, 2010, 9:57 am

Ok thanks for the inspirational answers! The bounce looks very nice, I will look into this function. I wonder how to make a difference between the hostplayer and normal players with this bounce function?
mark.knol
 
Posts: 3
Joined: February 19th, 2010, 10:16 am

Re: Creating a multiplayer game from a single player game

Postby fox1980 » August 12th, 2010, 3:16 pm

You could make the first player to join a room to be the host. Check the user id on the API, the one with the lower value should be the first one to connect.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm


Return to C#



cron