SimpleAVRG/Part 1

This is the first part of the Simple AVRG Tutorial. It details the basic AVRG Skeleton

This tutorial assumes that you have already set up your Whirled development environment.

See also: AVR games

New Project
In your Whirled SDK directory, run "ant newproject" and select "AVRG". Name it "SimpleAVRG".

(On Windows, you have the option of using newproject.bat instead. In fact, anywhere that I say to run Ant, there is an equivalent .bat file.)



Ant does its thing, resulting in a new directory with a minimal AVRG project:

- simpleavrg/ - Server.as        The server side actionscript. - SimpleAVRG.as    The client side actionscript. - build.bat        A build file for Windows users. - build.xml        A build file for anyone with Ant.

The build files are beyond the scope of this introduction to AVRGs, but you can read the Ant manual here if you're curious: http://ant.apache.org/manual/index.html

Server.as
At this point, your server side code looks like this:

// // $Id$ // // The server agent for SimpleAVRG - an AVR game for Whirled

package {

import com.whirled.ServerObject; import com.whirled.avrg.AVRServerGameControl;

/** * The server agent for SimpleAVRG. Automatically created by the * whirled server whenever a new game is started. */ public class Server extends ServerObject {   /**     * Constructs a new server agent. */   public function Server {       _control = new AVRServerGameControl(this); trace("SimpleAVRG server agent reporting for duty!"); }

protected var _control :AVRServerGameControl; }

}

SimpleAVRG.as
And here is your client code:

// // $Id$ // // SimpleAVRG - an AVR game for Whirled

package {

import flash.display.Sprite;

import flash.events.Event;

import com.whirled.avrg.AVRGameControl;

public class SimpleAVRG extends Sprite {   public function SimpleAVRG {       _control = new AVRGameControl(this);

// listen for an unload event _control.addEventListener(Event.UNLOAD, handleUnload); }

/**    * This is called when your game is unloaded. */   protected function handleUnload (event :Event) :void {       // stop any sounds, clean up any resources that need it. This specifically includes // unregistering listeners to any events - especially Event.ENTER_FRAME }

protected var _control :AVRGameControl; } }

First Build
So far, your game can set itself up and tear itself down, but not much else.

Go ahead and build it anyway to confirm that your environment is set up correctly. Run "ant" in the project directory.

If you don't get "BUILD SUCCESSFUL", figure out what has gone wrong and fix it.

Note: For Windows users, using build.bat will show an error about "test-avrg" but it will still generate the needed .swf and .abc files. If you don't want to see that error, you should install Apache Ant by following the instructions here and use ant in the command line prompt in your simpleavrg directory.



Upload: First Build, Part 2
The game doesn't do much, but let's upload it to see the little it does.


 * 1) In Whirled, proceed to Games &rarr; My Games. Click the Create button to get the game uploading interface.[[Image:Games-Create_Game.png|none|425px|thumb|The game uploading interface.]]
 * 2) Select In-Whirled Game.
 * 3) Under Game Name, type "Simple AVRG."
 * 4) Under Thumbnail Media, click Browse..., and select your image file. This thumbnail is used to represent the game in My Games.
 * 5) Under Client Code, click Browse..., and select your SimpleAVRG.swf file in the file system browser that appears. When the file has finished uploading, you should see a SWF id show up (e.g. 031c99dbf403923daad884fb562bd7f0d83d555x.swf) in the Client Code section.
 * 6) Confirm that you own the copyrights to the item or have authorization to upload it.
 * 7) Click on the Save button and your browser will switch to the Edit Game interface where you can configure your game.

Fill in the tabs with the appropriate values:

Info Tab Name: Simple AVRG Genre: MMO / Whirled (why not be ambitious?) Description: Enter a description of the game you plan to build. Group: Choose the Group to associate with the game (or none). Shop Tag: Enter any tags that will apply to your game. Screenshot: For now, this will have to stay blank.

Code Tab Splash Screen: Upload an appropriate image. Server Agent Code: Select your "SimpleAVRG.abc" file.

You will need to create a launcher for your game as well:


 * 1) Select the "Launchers" tab.
 * 2) Click on the "Create" button to get the launcher creation interface. [[Image:Stuff-Create_launcher.png|none|thumb|400px|Launcher interface.]]
 * 3) Click on the Name field and enter a name for your launcher. Something like Simple AVRG will be fine.
 * 4) Click Upload a new file in Furniture Media and find the image or SWF file for your launcher. This is what will be seen in the room when a player adds it there.
 * 5) Click Upload a new file in Thumbnail Media and find the bitmap (png, jpg or gif; max. 80x60) file for your launcher's icon. This will be shown in the shop and in the Stuff tab of players who have the launcher.
 * 6) Click on the Description field and enter a description of your launcher. This is only required if you plan to sell it in the shop.
 * 7) Confirm that you own the copyrights to the item or have authorization to upload it.
 * 8) You can then click on Save to put your launcher in your inventory for use.

First Run
Add the Simple AVRG launcher to a room and run it.



As you can see, not much happens.

While your game is still running, click its icon on the icon bar and choose "Instructions" from the menu.



In the page this opens, select the "Logs" tab. This tab gives you access to your game's server side logs. These will contain the output from your server side trace statements, among other things. Refresh until a log link appears, if one is not already present. Sometimes it takes a few minutes for a log to become available.



Follow a log link to see that log's contents:



As you can see, the trace statement from the Server class (as defined in Server.as) has run and the output has made it into the game's server side log.

What Have You Done?
You have built and uploaded a simple AVRG and confirmed that it runs on Whirled. The next step will be making it do a bit more.


 * Proceed to the next step