Download Nutmeg multiplayer code

I have uploaded both the server and client side code for the Multiplayer Nutmeg game mentioned in a previous post. Here is a short description on the steps to have your own copy up and running. Be warned that I have never written Actionscript code before and Java was a looong time ago so this is probably not the prettiest code you've seen.

Prerequisites
In order to have a go yourself you must first download the Nutmeg tutorial files (second part) from .net Magazine (Issue 218) and get it to compile and run using FlashDevelop or similar IDE.
You also need to install Smartfoxserver 2 on your PC. Installation files are available for Windows, Linux and Mac.

Client steps

  1. Download and extract the attached ZIP file (see end of this post)
  2. Add Network.as, RemoteUser.as and Users.as to the Flixel project.
  3. Next add the Smartfoxserver library, SFS2X_API_AS3.swc, to your project. This file you will have to copy from your Smartfox installation - **installdir**/Client/Flash/API.
  4. Replace PlayerState.as with the one from the ZIP
  5. Copy the sfs-config.xml file from ZIP into the bin directory of the project. Edit that file and replace www.spelagon.com with localhost or the name of the server with your Smartfoxserver instance.

You should now be able to compile the project and start the game. It will still not be multiplayer because you need to setup the zone, room and server extension as shown below.

Server steps

  1. Create a new Java project using Eclipse or your favourite IDE. Add MoveHandler.java and Nutmeg.java as source files.
  2. Also be sure to reference the smartfoxserver libraries: sfs2x.jar, sfs2x-core.jar
  3. Build the Nutmeg.jar file and copy it into the smartfox installation directory **installdir**/SFS2X/extensions/Nutmeg. You have to create the Nutmeg directory.EclipseEclipse
  4. Next we have to add the Zone "Rune" in the Smartfox admin Tool. In the Zone extension tab add Nutmeg as name and com.nutmeg.sfsx2.Nutmeg as file.
  5. Create a room in the zone called "FirstRoom"
  6. Restart Smartfoxserver. This is needed to activate the new Zone.

If you have any problems compiling or installing the server extension there is a nice video tutorial on how to do it. It sure helped me =)

You should now be able to start the Nutmeg game and see it connect to your server. I haven't really explained any of the code here so if you have any questions feel free to ask!

AttachmentSize
MultiplayerNutmeg.zip11.89 KB

Newsletter

Get the latest news, upgrades, tips and tricks by joining this FREE newsletter.
Make sure you don't miss out on anything! We keep your information confidential.

Your Email:

Hosting by YMLP.com