Introduction
This game demonstrates the simple, yet powerful .NET Compact framework that allows concurrent development for the PocketPC as well as the PC. The code is a demonstration of multithreading, networking via TCP/IP, drawing using graphics, and simple game and AI mechanics. The game is based on a risk style arcade game I saw at a truck stop.
Background
This version of the game was inspired by the .NET Compact Framework Contest in May of 2004. It is written in C#. The networking code was a push to stand out and represents my first ever attempt at networking, something made very simple in .NET CF.
Using the code
Thanks to the .NET Framework, the source includes a Compiled Help File (.chm) that documents the namespaces, classes and their methods/properties.
To compile the code, you need VC.NET and possibly the embedded VC 4.0 download from Microsoft. Simply compile and deploy to the PocketPC, Pocket emulator, or run directly from your machine.
Points of Interest
This is my first attempt at a game and the first time I've ever done networking. The .NET CF made it possible to do both very quickly.
I noticed some benefits afforded to me because of .NET and .NET CF:
- Faster Development! .NET Compact Framework provides namespaces and classes you need at your fingertips, so you can autocomplete your way to the finish line.
- Portability! Develop in C# and run on both the PC and PocketPC. Once I had converted the PC version to .NET, it was simply executing the binary on the PC or PocketPC! With the .NET CF, I can recompile for other mobile devices! Measure once, cut Twice...ad infinum.
- Networking. What could be a cooler use for WAN cards than to play against other PocketPC users? I'll tell you: playing the same game, the same executable, against a person running on a computer with your new WAN PocketPC. Maybe you don't have a Pocket... play computer on computer - Over the Internet!
- Works from behind Firewalls - Just connect out to another person over the net not behind a firewall.
- Work over LAN - It shows your IP to Instant Message or tell your friend to connect to. If you're behind a firewall, your Internet IP Address will be the same as your LAN IP address.
- Better Drawing Code:
- Smaller distributable because instead of bitmaps, I used the GDI+ classes in .NET.
Graphics
class allows for redrawing just the updated tiles instead of drawing the whole screen.
- Complex Filled Polygons with .NET GDI+.
- Collections with Garbage Collection! Instead of using an external set of tools like for common containers, Collections keep with the style and conventions of the rest of C# .NET.
- Source Code Documentation: .NET specifies a schema for commenting that allows XML generation of comments. Follow the rules, use a tool provided with the IDE, and you have generated documentation for later reference between you or your team!
Rules
- Each player starts in their respective corner with a default color. The Host (or singleplayer) is in the bottom left hand corner. The person joining the Client is in the upper right hand corner.
- They take turns switching colors back and forth.
- You cannot change to the same color as the Opponent.
Gameplay
When you change colors, any tile surrounding your current set will be added to your collection. The point of the game is to occupy the most spaces on the board. If you play over TCP with another person, you take turns back and forth. If you are playing single player, the Computer AI takes a turn and returns almost immediately. The AI becomes progressively harder, the more games you win. If you win 6 games in a row, it becomes the hardest to get. If you can beat this, then you need to play against a human!
Multiplayer
In order to get Multiplayer working, you must follows these steps:
- Execute the binary on both machines and hit NO to the Single player dialog.
- Note the IP address of the host and relay this to the other player. Start the host connection for your LAN or over the Internet.
- If the 'Net' and 'LAN' IP addresses are the same, this client cannot host a game over the Internet, but it can join a game hosted on the Internet.
- If you are hosting over the Internet, check the 'Net' radio button and press host.
- If both machines are on a Local Area Network (LAN), either machine may host.
- After the Host is running, have the Client type in the IP address into the box and press the Join button.
- Even if you are behind a firewall, you should be able to connect to a Host over the Internet that is not behind a firewall.
- If both machines are behind a firewall, a connection cannot be made.
- If both machines are behind the same Firewall, connect using the LAN.
- Once the connection has been made, the Host will generate a board and send it to the joining player.
- The Host is the first player, who is in the bottom left hand corner on both machines. The Host takes the first turn. The joining client's buttons are disabled until it is its turn.
- The Client is the second player and its tiles are in the upper right hand corner.
- After the game is finished, it tells you who won and asks you if you want to play again. Choose yes if you want to play again.
- If you are connected to a machine, then it will ask you if you would like to use the same connection to play another game.
Requirements
Requires that you download and install .NET CF onto your Mobile device. This is only necessary once to enjoy the multitude of applications to follow.
Screen Shots
This is a picture of the beginning of a match between the emulator and the desktop. Notice, the boards are the same, that means they're connected and playing!
This is a picture of the beginning of a match between a Computer and another Computer. Notice, the boards are the same, that means they're connected and playing!
This is a picture of the Networking box. If you click on "Net", you get your connected IP for your service. If you are behind a firewall, you get the LAN IP in this box. If you click on "LAN", you can see your LAN IP address.
Special Thanks
Where would we be without our friends and family? Special thanks goes out to all those who helped test and made suggestions for this project:
- Testers:
- My Love, My Wife, Thanks.
- My family for testing it.
- My dad for showing me that 'just because I wrote it' doesn't mean that he can't wipe the floor with me.
- The crew at GameDev.Net for testing the Win32 Version.
- Suggestors
A special thanks to Mr. Lewey Geselowitzs for helping me debug this application, compile and test it on his PocketPC, and for general coolness. Cheers!