Monday, November 08, 2010

C# .NET Asynchronous Sockets Tank Game



First, let me say that this project was not about the graphics and game play. I wanted to try out some Asynchronous Client Sockets in C#. Getting sick last week was a good opportunity to try it out since I wasn't going anywhere. I came up with this little Tank Wars game.

I kept the client really simple by using GDI+ to draw the bitmaps on the screen. It just communicates the key events to the server. All of the game logic and scoring is handled by the server. Add some basic scoring and sound effects and we have Tank Wars!

I did hit a roadblock when I decided to add some sound. I used a simple class called SoundPlayer in C#. This was great for the Tank shot but was unable to play multiple sounds at the same time. So, I think it is time to call this exercise finished and move on to the next version.

Overall, it was a fun little couple hour project that got me exposed to what happens behind the scenes.

For the next version:
- DirectX Client.
- Really good sound support.
- Polish up the full GUI.
- Make the Server Public so Client can be downloaded.
- Support a SinglePlayer mode.

Feel free to leave any questions or comments. I can even post some code up here if anyone is interested.

Happy Coding!
Jason

Related Links:
Asynchronous Socket Programming in C#
PlaneShift Video on MMORPG Design.

3 comments:

  1. Graphics or no, it is a fun little game to play! I foresee many a tournie in our future, be it between us or the boys.

    ReplyDelete
  2. Grins. Sounds a little like commbatt, but great great job! Then again, you could always write it in XNA, and get things like Multiple Layered Sound through the Microsoft.Xna.Framework.Audio class.

    Commbatt is based on Server-Server. Each player is their own server. The servers communicated changed objects to each other, thay way they only have to a local lookup to see if it's a hit. Technically, I guess that's a requirment of using XNA as I couldn't write a separate server, it's bring your own.

    I like the clean lines on the interface, very nice.

    ReplyDelete
  3. It would be very helpful if you could post the code, Jason.

    ReplyDelete