Aug 092011
 

Series: Flash Game Programming 101, Putting It All Together, Step Nine.

I’ve taken you through an eight step process to introduce you to the world of Flash Game Development. You’ve got all the essentials to place objects on the stage, interact with them with the keyboard and mouse, detect basic collision, and add some to your game.

Now its time to put it all together in one big project. We’re going to take a two-step process for this. The first will be a basic gunner game base. You’ll have a left-right moving gun turret, and an alien pod that goes from left to right across the screen. You’ll be able to fire at the alien pod, and see the bullet move. We’ll also introduce sound and scoring into the game.

First, let’s setup the library with the elements that we need. Make a new symbol, set it as a movie clip, and draw some form of a gun turret. Make sure you set the top at Y 0, and then put it in the middle, giving the X a slightly minus setting. After that, make an alien pod, laying it out about the same way. Third we’ll need a bullet draw. After that grab yourself two sound files, and import then. Make sure you export them all to ActionScript and give them class names.

For these objects, you can use clip art, draw shapes, or make your own fancy pieces. I just draw some basic shapes for the sake of the lesson. It’s not as important what they look like, as it is where you position them in the symbol. Setting the top of them to Y 0 allow us to make the bullet look like its firing, and it will also help us position the object on the stage with the AS3 code.

Now let’s setup all the libraries that we’re going to use. They’re the same ones that you used throughout the eight steps.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.ui.Keyboard;

Next let’s declare our variables.

var myTurret:Turret = new Turret();
var myBullet:Bullet = new Bullet();
var myAlien:Alien   = new Alien();

var dispScore:TextField	   = new TextField();
var scoreFormat:TextFormat = new TextFormat();
var myScore:Number         = new Number();

var myFireBulletSound:FireBulletSound = new FireBulletSound();
var myShotAlienSound:ShotAlienSound   = new ShotAlienSound();

You can see the names here that I used for my library items that exported for ActionScript. I’ve also introduced a scoreboard, styling for the scoreboard, and a counter for the actual score. Now let’s place the initial objects on the stage.

// Setup Turret

myTurret.x = 55;
myTurret.y = 310;

addChild( myTurret );

// Setup Alien

myAlien.x = -20;
myAlien.y = 65;

addChild( myAlien );

// Setup Scoreboard
dispScore.x = 10;
dispScore.y = 10;

addChild( dispScore );

scoreFormat.font = "Arial";
scoreFormat.size = 28;
scoreFormat.bold = true;
scoreFormat.color = 0x121212;
scoreFormat.align = TextFormatAlign.LEFT;

dispScore.defaultTextFormat = scoreFormat;
dispScore.text = String( myScore );

Please take note of where I played myAlien. -20 pixels off the left side of the screen. That’s where it will start when the game starts, giving it an appearance of coming from afar to invade and destroy us. Next we need the initial event listeners.

// Stage Events
stage.addEventListener( KeyboardEvent.KEY_DOWN, moveTurret );
stage.addEventListener( KeyboardEvent.KEY_DOWN, fireBullet );

// Alien Events
myAlien.addEventListener( Event.ENTER_FRAME, moveAlien );

I’ve setup two for the keyboard. One is going to monitor the left and right arrow keys for movement, and the other will handle the spacebar for firing our bullet. The other event is to start the alien animation movement across the top of our screen. Let’s take a look at the functions now.

function moveTurret( e:KeyboardEvent )
{
	var multiplier = 10;

	switch( e.keyCode )
	{
		case Keyboard.LEFT :

			myTurret.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myTurret.x += multiplier;

			break;
	}
}

I’ve decided to go with a multiplier of 10 for the movement. As you recall from our earlier tutorial, that is how many pixels left or right we’ll move the turret.

function fireBullet( e:KeyboardEvent )
{
	switch( e.keyCode )
	{
		case 32 : // spacebar

			playSound( myFireBulletSound );

			myBullet.x = myTurret.x;
			myBullet.y = myTurret.y;

			addChild( myBullet );

			stage.removeEventListener( KeyboardEvent.KEY_DOWN, fireBullet );

			myBullet.addEventListener( Event.ENTER_FRAME, moveBullet );

			break;
	}
}

Here we have the spacebar event for firing the bullet. I like to use the switch control for all of my keyboard events, even in cases where is this just one. This gives us a framework for adding more in the future.

You’ll see in here when the spacebar is set, we play the firing sound, set the location of the bullet, which is at the top of the turret. Remember when I said its important to set the top of the turret to Y 0? This is why.

Notice the removeEventListener. We want to limit the player to firing only one bullet at a time. To do this, we need to remove the spacebar control, and then add a movement event to animate the bullet upwards. Let’s take a look at the bullet movement.

function moveBullet( e:Event )
{
	myBullet.y -= 5;

	// If we shot the alien, make it reset, add 10 to the score.
	if ( myBullet.hitTestObject( myAlien ) )
	{
		myScore += 100;

		dispScore.text = String( myScore );

		myAlien.x = -10;

                playSound( myShotAlienSound );

		resetBullet();
	}

	if ( myBullet.y < 0 )
	{
		resetBullet();
	}
}

In this function, we have multiple things going on. First, we’re moving the bullet 5 pixels at a time upwards. Then we’re doing two if conditions, with the first being a basic collision detection. If the bullet and the alien object meet, we’ll increase the score by 100, move the alien back off the screen, play a sound, and reset the bullet. Let’s take a look at that code next.

function resetBullet()
{
	myBullet.removeEventListener( Event.ENTER_FRAME, moveBullet );

	removeChild( myBullet );

	stage.addEventListener( KeyboardEvent.KEY_DOWN, fireBullet );
}

Resetting the bullet is as simple as removing the event, removing it from the stage, and adding a new event listener for the spacebar. Its the same addEventListener code as above. It will utilize the same function.

Finally, let’s take a look at the movement of the alien, and the sound playing.

function moveAlien( e:Event )
{
	myAlien.x += 2;

	if ( myAlien.x > 575 )
	{
		myAlien.x = -10;
	}
}

Moving the alien is trivial. We’re going to move it 2 pixels to the right at a time. We’re also going to check and see if goes beyond our stage, and then reset the alien back to -10 off the left of the screen, and continue on his path back across the screen.

function playSound( soundObject:Object )
{
	var channel:SoundChannel = soundObject.play();
}

Sound is just like in our earlier tutorial. A simple one line function that plays the sound you toss at it. In our case, the firing sound, and the collision sound.

Now you have a basic framework for a space invaders type game. You know how to take each of the elements from our first eight sessions and tie them together. You know how to animate multiple things at once, and how to detect when they touch. You understand how you can make a turret appear to fire a bullet.

We’re still not quite done. Notice you don’t have any boundaries to your turret. You could theoretically drive it off the right or left of the screen, and never see it again. We’ll cover that in lesson ten, and introduce you two a couple more advanced items you can put into your first complete game.

I realize I went pretty fast through the symbol setup in the beginning of this lesson. I feel by now you have a grasp on how to use that part of the flash interface. Please also keep in mind that I’m always here to answer questions and help if you get stuck. You can contact me directly, on twitter, or leave a comment here.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 10:50 PM
Aug 082011
 

Series: Flash Game Programming 101, Adding Sound, Step Eight.

Sure, there is a growing trend in flash games that suggests people don’t care about sound. I personally believe the real story is a lot of people play where they can’t turn on their sound. They’re either at work, at the library, or somewhere in public. The fact is, your game needs sound.

Adding basic sound to your game is simple. Simply grab or make two shot mp3 (or aiff) audio files, and put them in your project directory. After that, import them, and export them to ActionScript, just like you would your symbols. Give them the classnames StartSound and StopSound. Now we’re going to add some code.

import flash.media.Sound;
import flash.media.SoundChannel;

var myStopSound:StopSound       = new StopSound();
var myStartSound:StartSound	= new StartSound();

playSound( myStartSound );

function playSound( soundObject:Object )
{
	var channel:SoundChannel = soundObject.play();
}

Let’s first implement the starting sound. We’re going to attach this to our space bar, and button click to make the ball animate. We simply want to play a sound when the ball starts moving, then play one when it stops.

The first thing you’ll need to do is import the sound library, and declare your sound variables. You’ll also need to make a function to play the sound.

import flash.media.Sound;
import flash.media.SoundChannel;

var myStopSound:StopSound       = new StopSound();
var myStartSound:StartSound	= new StartSound();

function playSound( soundObject:Object )
{
	var channel:SoundChannel = soundObject.play();
}

Now we’re going to attach the sound to our start and stop events. Let’s first work with myStartSound. You’ll need to modify a couple of functions, and add one.

function buttonClicked( e:MouseEvent )
{
	playSound( myStartSound );

	stage.addEventListener( Event.ENTER_FRAME, moveBall );
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			playSound( myStartSound );

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

Take note of where we placed playSound(). Play sound will play any of your library sound files that you’ve declared in your project. In our case, we’ll be passing myStartSound and myStopSound into it. Make not of where I placed playSound( myStartSound ). I put it first in the spacebar handler, and first in the button click.

Now let’s take a look at firing the stopping sound.

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );

		playSound( myStopSound );
	}	

	myScore++;

	dispScore.text = String( myScore );

	myBall.y -= 10;
}

Since the moveBall() found is used with the keyboard and mouse events that animate the ball, we only need to put the playSound( myStopSound ) line in one place, just after we stop the ball.

Let’s put it all together.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.media.Sound;
import flash.media.SoundChannel;

var myBall:Ball 				= new Ball();
var myWall:Wall 				= new Wall();
var myLaunchButton:LaunchButton = new LaunchButton();
var dispScore:TextField			= new TextField();
var scoreFormat:TextFormat 		= new TextFormat();
var myScore:Number              = new Number();
var myStopSound:StopSound       = new StopSound();
var myStartSound:StartSound		= new StartSound();

scoreFormat.font = "Arial";
scoreFormat.size = 28;
scoreFormat.bold = true;
scoreFormat.color = 0x121212;
scoreFormat.align = TextFormatAlign.LEFT;

myBall.x = 200;
myBall.y = 350;

myWall.x = 400;
myWall.y = 200;

myLaunchButton.x = 400;
myLaunchButton.y = 350;

dispScore.x = 10;
dispScore.y = 10;

addChild( myBall );
addChild( myWall );
addChild( myLaunchButton);
addChild( dispScore);

dispScore.defaultTextFormat = scoreFormat;
dispScore.text = String( myScore );

// Stage Events
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

// Symbol Specific Events
myLaunchButton.addEventListener( MouseEvent.MOUSE_UP, buttonClicked );

myBall.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
myBall.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

function buttonClicked( e:MouseEvent )
{
	playSound( myStartSound );

	stage.addEventListener( Event.ENTER_FRAME, moveBall );
}

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

function mousePress( e:MouseEvent )
{
	myBall.startDrag();
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			playSound( myStartSound );

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );

		playSound( myStopSound );
	}	

	myScore++;

	dispScore.text = String( myScore );

	myBall.y -= 10;
}

function playSound( soundObject:Object )
{
	var channel:SoundChannel = soundObject.play();
}

Now you have the essentials of adding sound to your game. You can use a single function to play any of your library sounds. Try moving the function around and seeing where you can make it play. Test it on the mouse movement and on the keyboard functions. If you have any questions, please comment or contact me directly.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 8:27 PM
Aug 022011
 

Series: Flash Game Programming 101, Keeping & Display Scores, Step Seven.

One of the essential parts of a game is the score. It makes players feel happy, and gives them something to work at. Without a score, no one would care how far they went in half the games they played. They’d shoot a few things, and tip their hats goodbye.

One of the things I learned early on, is that adding text and manipulating it is really one of the most trivial aspects of Flash and ActionScript. It’s really just a matter of creating a text object in your code, putting it somewhere, and updating it’s value at various intervals.

import flash.text.TextField;

var dispScore:TextField			= new TextField();
var scoreFormat:TextFormat 		= new TextFormat();
var myScore:Number                      = new Number();

scoreFormat.font = "Arial";
scoreFormat.size = 28;
scoreFormat.bold = true;
scoreFormat.color = 0x121212;
scoreFormat.align = TextFormatAlign.LEFT;

dispScore.x = 10;
dispScore.y = 10;

addChild( dispScore);

dispScore.defaultTextFormat = scoreFormat;
dispScore.text = String( myScore );

Add that to the top portion of your project. That’ll setup the variables, font formatting, and place it on the stage. Next we’re going to modify the moveBall() function a little bit.

myScore++;

dispScore.text = String( myScore );

This is the part where the score actually updates. We’re having it increment one each move of the ball. In a game you may have it counting constantly at a 10+ interval. In other cases, you’ll score accordingly for a certain action within the game, such as shooting an alien ship. Let’s put this all together.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;

var myBall:Ball 				= new Ball();
var myWall:Wall 				= new Wall();
var myLaunchButton:LaunchButton = new LaunchButton();
var dispScore:TextField			= new TextField();
var scoreFormat:TextFormat 		= new TextFormat();
var myScore:Number              = new Number();

scoreFormat.font = "Arial";
scoreFormat.size = 28;
scoreFormat.bold = true;
scoreFormat.color = 0x121212;
scoreFormat.align = TextFormatAlign.LEFT;

myBall.x = 200;
myBall.y = 350;

myWall.x = 400;
myWall.y = 200;

myLaunchButton.x = 400;
myLaunchButton.y = 350;

dispScore.x = 10;
dispScore.y = 10;

addChild( myBall );
addChild( myWall );
addChild( myLaunchButton);
addChild( dispScore);

dispScore.defaultTextFormat = scoreFormat;
dispScore.text = String( myScore );

// Stage Events
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

// Symbol Specific Events
myLaunchButton.addEventListener( MouseEvent.MOUSE_UP, buttonClicked );

myBall.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
myBall.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

function buttonClicked( e:MouseEvent )
{
	stage.addEventListener( Event.ENTER_FRAME, moveBall );
}

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

function mousePress( e:MouseEvent )
{
	myBall.startDrag();
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );
	}	

	myScore++;

	dispScore.text = String( myScore );

	myBall.y -= 10;
}

Now you have all the elements to putting a scoreboard in your game. Play around with it and see what kind of ways you can utilize it. You can manipulate it in any way you want. Even overwrite it temporarily with text, and then flip it back to the number. As always, if you have any questions, post a comment or contact me directly.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 8:56 PM
Aug 012011
 

Series: Flash Game Programming 101, Animating Elements with the Mouse, Step Six.

You’ve been successful animating things based on a key press, now its time to set up a button on the stage and make the click of a mouse trigger the animation. The actual movement is the same logic, but the triggering of the event is slightly different.

The first thing we need to do it add a new symbol. Call this one LaunchButton, and draw out a small square. After that, add in code in your as3 to add it to the stage. Make sure you check off to Export it to ActionScript like the other two.

var myLaunchButton:LaunchButton = new LaunchButton();

myLaunchButton.x = 400;
myLaunchButton.y = 350;

addChild( myLaunchButton);

Next, we’ll need to add an event listener. This one is going to be a little bit different. We’re not going to attach it to the stage, we’re going to attach it to the button.

myLaunchButton.addEventListener( MouseEvent.MOUSE_UP, buttonClicked );

function buttonClicked( e:MouseEvent )
{
	stage.addEventListener( Event.ENTER_FRAME, moveBall );
}

Notice that the event function, buttonClicked(), uses the same ENTER_FRAME event that we use for our keyboard. That particular moveBall() function that it controls will work with any event that you want to interface it with.

Now go ahead and publish your project, and click your button. Notice how the ball jumps over to you, and then proceeds upwards. Your animation and mouse control are working just fine, but this may be a little goofy. This takes me back to an earlier part in our lesson where we first work with mouse control. If you recall, I mentioned you don’t really need to see the myBall.x/y coordinates to match that of the mouse. I did that so you could click anywhere on the stage, the ball would come to you, and you could drag it around.

function mousePress( e:MouseEvent )
{
	myBall.startDrag();

    myBall.x = e.stageX;
    myBall.y = e.stageY;
}

Its time to change this around. We’re going to take the mousePress control off the stage, and attach it to the ball. This will give you a true grab and drag on the ball, rather than just a click anywhere and drag. It will also keep the ball from flying towards to the button before making its way upwards.

First, let’s modify mousePress() and remove the two lines that make the ball jump to the mouse.

function mousePress( e:MouseEvent )
{
    myBall.startDrag();
}

Next, let's replace our MOUSE_DOWN and MOUSE_UP events with these.

1
myBall.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
myBall.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

Notice how we only replaced ‘stage’ with ‘myBall’? That will keep the ball drag from trigger until we actually click on it. Instead of the ball flying around the stage trying to find the mouse, we’ve given it a little independence, and normalized things quite a bit.

Let’s put it all together.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;

var myBall:Ball 				= new Ball();
var myWall:Wall 				= new Wall();
var myLaunchButton:LaunchButton = new LaunchButton();

myBall.x = 200;
myBall.y = 350;

myWall.x = 400;
myWall.y = 200;

myLaunchButton.x = 400;
myLaunchButton.y = 350;

addChild( myBall );
addChild( myWall );
addChild( myLaunchButton);

// Stage Events
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

// Symbol Specific Events
myLaunchButton.addEventListener( MouseEvent.MOUSE_UP, buttonClicked );

myBall.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
myBall.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

function buttonClicked( e:MouseEvent )
{
	stage.addEventListener( Event.ENTER_FRAME, moveBall );
}

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

function mousePress( e:MouseEvent )
{
	myBall.startDrag();
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );
	}	

	myBall.y -= 10;
}

Now you have both tools for triggering animation in your game. The mouse and keyboard. Both can be very useful depending on how you build your UI. Try new ways to utilize the mouse for triggering movement. See if you can stop the ball part way up its path. If you need any help, or have any questions, contact me directly, or comment here.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 1:34 PM
Jul 292011
 

Series: Flash Game Programming 101, Animating Elements with the Keyboard, Step Five.

One of the essential elements to a game is to have move pieces on the screen that you are not controlling. Whether they are triggered by a player action, or just generated and animated by the AS3 code, without them, your game is not a game.

We’re going to talk about making something move across the screen with the press of a key. It’s really as simple as setting up an ENTER_FRAME event, and manipulating the x or y position.

stage.addEventListener( Event.ENTER_FRAME, moveBall );

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );
	}	

	myBall.y -= 10;
}

You’ll want to set a direction, and then check to see if its crossing off into the outer limits beyond the stage, and you’ll want to tie it into a keyboard or mouse key. For the sake of this lesson, we’ll tie it into the keyboard, and take a look at more advanced methods with the mouse another day.

The first thing we need to do is open up our project, and go into the keyPress() function. In the case control, you’ll want to add a keyCode handler for the spacebar. You can find any keyCode at this web site. The spacebar is 32.

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

We’re also going to move the starting position of our ball.

myBall.x = 200;
myBall.y = 350;

Now that you have your keyCode in place and our ball re-positioned, let’s take a look at the function we’re attaching the ENTER_FRAME event to. We’re going to simply subtract from the myBall.y, moving the ball upwards. While the ball is moving, we’re going to make sure we don’t past the edge of the stage, and off the screen.

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );
	}	

	myBall.y -= 10;
}

That’s all there is too it. Each time you press your spacebar, unless the ball is at or above the Y 10 coordinate, the ball is going to move itself upwards. Let’s take a look at it all put together.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;

var myBall:Ball = new Ball();
var myWall:Wall = new Wall();

myBall.x = 200;
myBall.y = 350;

myWall.x = 400;
myWall.y = 200;

addChild( myBall );
addChild( myWall );

stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
stage.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );
stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

function mousePress( e:MouseEvent )
{
	myBall.startDrag();

    myBall.x = e.stageX;
    myBall.y = e.stageY;
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;

		case 32 : // Spacebar

			stage.addEventListener( Event.ENTER_FRAME, moveBall );

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

function moveBall( event:Event )
{
	if ( myBall.y <= 10 )
	{
		stage.removeEventListener( Event.ENTER_FRAME, moveBall );
	}	

	myBall.y -= 10;
}

Now you have a base for making things move on key press. You can fire a rocket, bullet, or send a pinball moving with the press of the spacebar. Skies the limits really for this type of activity. You could even have it spawn new items, and move them around the screen. Play around, and see what you can do. If you have any questions, contact me directly, or leave a comment.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 9:24 PM
Jul 262011
 

Series: Flash Game Programming 101, Basic Collision Handling, Step Four.

Thanks to our friends at Adobe, you don’t need to be a physics or math expert to detect when two objects in Flash collide. Sure, you can spend the time if you want, but why waste the effort with such a simple task? AS3 has a function called “hitTestObject()”. Simply put, you attach it to an object, then toss another object at it. Here’s an example.

if ( myWall.hitTestObject( myBall ) )
{
	myBall.x = 200;
	myBall.y = 200;
}

Simply put, when the ball and the wall touch, the ball resets to its starting position, 200×200. You can do whatever you want with the ball or the wall here, you don’t just have to move things around. You can make one disappear, explode, change, etc.

The first thing we’re going to do before we implement the collision is add a wall for the ball to bounce off of.

As you can see, I just added a new symbol. After that, take your rectangle tool, and draw a 125×25 rectangle at point 0,0 of the symbol, and give it a grey color. After that, add some as3 code to add it to the stage. I put this with the myBall code.

var myBall:Ball = new Ball();
var myWall:Wall = new Wall();

myBall.x = 200;
myBall.y = 200;

myWall.x = 400;
myWall.y = 200;

addChild( myBall );
addChild( myWall );

Now let’s add the collision code to our project We’re going to take this in a two part step. The first part will be what to do when moving the ball with the keyboard. After that we’ll take a look at the mouse movement. We’ll be working with the keyPress() function.

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

We’re simply taking our keyboard event function, keyPress(), and adding to the end of it. Also note that I cut the multiplier for the movement down to 2 so we can collide a little smoother, without it looking like it bounced early.

Go ahead and publish your project. Move the ball over to the wall. Notice as you touch the wall, the ball resets back to it’s starting position. Simply enough? Let’s move to part two, the mouse.

The mouse is basically the same concept. We’re going to utilize the hitTestobject() function in the same manner. The only thing that makes it more “complex” is that you need another function and event type. You’ll be attaching a new function onto MouseEvent.MOUSE_MOVE.

stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

I’ve added the event listener, and function trackMouse(). MOUSE_MOVE simply fires every time the mouse moves. You can see I’m looking for the collision between the ball and wall with the familiar if control from above. This time, instead of just jumping the ball back into place, we’re also going to turn off dragging, essentially knocking the ball out of your hand.

Let’s put it all together.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.Event;

var myBall:Ball = new Ball();
var myWall:Wall = new Wall();

myBall.x = 200;
myBall.y = 200;

myWall.x = 400;
myWall.y = 200;

addChild( myBall );
addChild( myWall );

stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
stage.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );
stage.addEventListener( MouseEvent.MOUSE_MOVE, trackMouse );

function trackMouse( e:MouseEvent )
{
	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.stopDrag();

		myBall.x = 200;
		myBall.y = 200;
	}
}

function mousePress( e:MouseEvent )
{
	myBall.startDrag();

    myBall.x = e.stageX;
    myBall.y = e.stageY;
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 2;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;
	}

	if ( myWall.hitTestObject( myBall ) )
	{
		myBall.x = 200;
		myBall.y = 200;
	}
}

Now you have a basic understanding of how to handle a collision between two objects. I’ve also shown you how you can interface them with your keyboard and mouse movements. Try expanding on this with your own project. See what other actions you can come up with inside your collection control. As always, send me an e-mail, or post a comment if you need help.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 9:26 PM
Jul 242011
 

Series: Flash Game Programming 101, Mouse Controls, Step Three.

Being able to move things around via the mouse is an important element in today’s game world. Puzzle games, strategy games, and other genres wouldn’t be the same if you were confined to a keyboard. Fortunately, working with the mouse is similar to the keyboard in ease of use.

import flash.events.MouseEvent;

stage.addEventListener( MouseEvent.MOUSE_MOVE, showMouseCoords );

function showMouseCoords( e:MouseEvent )
{
    trace( "X = " + e.stageX + ", Y = " + e.stageY + ".\n" );
}

Some of the things you can monitor are mouse button up, down, movement, in, out, leaving an area, and the wheel. For this lesson, we’re going to focus on the wheel, and dragging our ball around.

Open up your flash project. You can leave all the keyboard code in. First, add all your event listeners. You can put them immediately under your keyboard event listener. You’ll need one for MOUSE_DOWN, and MOUSE_UP.

stage.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
stage.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

Next, we’ll need to write the functions to handle each of the mouse controls. The first one, MOUSE_DOWN, will be the one that controls dragging the ball around the screen. You will be utilizing the startDrag() method, and adjusting the X and Y coordinates of the ball to stageX and stageY coordinates of the mouse.

function mousePress( e:MouseEvent )
{
	myBall.startDrag();

	myBall.x = e.stageX;
	myBall.y = e.stageY;
}

I should note one thing. You don’t need the myBall.x and y lines. I put those there so that the ball will jump to the mouse pointer when you click anywhere on the stage. The function that does all the work is startDrag(), which is built into Flash. One of the many reasons I really like AS3 and Flash is that so many things, like startDrag, collision, etc, are built into it. You don’t have to spend hours writing fancy code to do simply tasks. It just simply works.

Now that you’ve moved your ball where you want it, you need to issue a stopDrag(). This is where the mouseRelease function comes into play. When your mouse button is released, it will trigger the MOUSE_UP function, and run a single line of code.

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

Pretty simple, eh? Let’s put all the code together from our first three lessons.

import flash.events.KeyboardEvent;
import flash.events.MouseEvent;

var myBall:Ball = new Ball();

myBall.x = 200;
myBall.y = 200;

addChild( myBall );

stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );
stage.addEventListener( MouseEvent.MOUSE_DOWN, mousePress );
stage.addEventListener( MouseEvent.MOUSE_UP, mouseRelease );

function mousePress( e:MouseEvent )
{
	myBall.startDrag();

	myBall.x = e.stageX;
	myBall.y = e.stageY;
}

function mouseRelease( e:MouseEvent )
{
	myBall.stopDrag();
}

function keyPress( event:KeyboardEvent )
{
	var multiplier = 10;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;
	}
}

You now have a basic understanding and set of functions to handle all the controls in your game. You’ll be able to build a friendly user interface that can utilize both the keyboard and mouse. You should take the functions from these first three lessons now, and play around with them a bit. Try adding new keyboard key codes into the mix. See if you can do different things with the MOUSE_UP and MOUSE_DOWN events.

As always, if you get stuck on any part of this tutorial, post a comment, or contact me directly.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 10:16 AM
Jul 232011
 

Series: Flash Game Programming 101, Keyboard Controls, Step Two.

If you haven’t read the previous posts in this series, and are new to AS3, click on the Flash Game Programming 101 category over in the right hand column and start with the first. I’m taking you through baby steps that will get you started with AS3 game programming.

Open up your flash project from last time. We’re going to expand our Flash program a bit, taking away the extra balls, and adding keyboard controls so you can move the ball around. Keyboard movement in Flash is not as hard as you may think. It’s a matter of adding a keyboard event listener, and handling key codes.

import flash.events.KeyboardEvent;

stage.addEVentListener( KeyboardEvent.KEY_DOWN, keyDown );

function keyDown( event:KeyboardEvent )
{
    trace( "Key Pressed!\n" );
}

One thing to note. You can use KEY_DOWN or KEY_UP depending on the architecture of your game. I usually prefer to use KEY_UP for things like shooting a missile, but will always use KEY_DOWN for movement, so the player can simply hold a key rather than tap it.

Let’s go ahead and modify our AS3 a bit. First thing we’re going to do is take out the for loop. After that, replace the i value in x with 200, and remove the myBall.rotation line. Your code should look like this:

var myBall:Ball = new Ball();

myBall.x = 200;
myBall.y = 200;

addChild( myBall );

The next step is to add the keyboard event listener to the stage, and then build out our function to let the ball move up, down, left, and right. There are a couple of ways you can handle the keycodes inside your keyPress function. You can set up an if/else control structure, or use a switch. I much prefer using switch in this case. Its cleaner code, and easier to read and work with. You also don’t run the risk of spaghetti logic.

import flash.events.KeyboardEvent;

var myBall:Ball = new Ball();

myBall.x = 200;
myBall.y = 200;

addChild( myBall );

stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPress );

function keyPress( event:KeyboardEvent )
{
	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x--;

			break;

		case Keyboard.RIGHT :

			myBall.x++;

			break;

		case Keyboard.UP :

			myBall.y--;

			break;

		case Keyboard.DOWN :

			myBall.y++;

			break;
	}
}

Go ahead and publish your project, and run it. You’ll see the ball move a little each time you hit an arrow key. Also make note that the movement is slow. If you want to speed things up, you can add a bigger multiplier to the mix.

function keyPress( event:KeyboardEvent )
{
	var multiplier = 10;

	switch ( event.keyCode )
	{
		case Keyboard.LEFT :

			myBall.x -= multiplier;

			break;

		case Keyboard.RIGHT :

			myBall.x += multiplier;

			break;

		case Keyboard.UP :

			myBall.y -= multiplier;

			break;

		case Keyboard.DOWN :

			myBall.y += multiplier;

			break;
	}
}

So there you have it. Keyboard movement in AS3 is simple. By adding an event listener, you can write a function that will do just about anything you want. Remember, choose KEY_UP and KEY_DOWN wisely. Test both in cases where you’re not sure which to use. Keep the player in mind, and your game will be a success.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 11:05 AM
Jul 212011
 

Series: Flash Game Programming 101, Basic Setup, Step One.

I’ve had some e-mails the last couple days asking where my follow-up Ajax tutorials were. We’ve had a bit of a heat wave roll in, and honestly, its been way to hot to work hard on something like that. I’ll introduce the follow-up next week sometime. In the meantime, I’ve decided to get myself back to the beginning of relearning basic Flash and ActionScript3, and prepare to get going with Ben Davis on our game.

To give you a little background about me and my Flash programming, its been a while, but I have a bit of good history in the past. I had the pleasure of working for the team who brought you OriginalPoetry.com. We were a three man team consisting of a front end designer/developer, and two programmers. As I always do, I volunteered for one of the toughest pieces of the site, the flash games.

I started out with a bit of an easier game, and a game that was modeled after a game a book I bought, ActionScript 3.0 Game Programming University by Gary Rosenzweigh. The game’s premise was to match tiles, much like the memory card game you may (or may not have) played. I took Gary’s tutorial and concept, and was able to expand it to a four level game with leader board, scores, and custom graphics wrapped around it to fit our poetry theme.

I managed to get two more games out after that. A multiplayer “Poem Builder”, and a single personal word tile game designed to help break writer’s block. Unfortunately, I was soon shifted to a new project, and my Flash skills have laid dormant ever since.

That’s where these lesson come in.

As I walk myself through the first pieces of the game, I’m going to let you follow along. I’m going to be going rapidly from some basic things, to full-blown mini games. If you ever find it hard to jump from tutorial to tutorial, please comment, and I’ll do my best to write a follow-up filler that will keep you moving with me.

Let’s begin!

First off, let’s talking about Movie Clips. I make basically all of my usable symbols in the game Movie Clips. After you create your movie clip in your library, there are then two ways you can handle things. The first way is to drag it onto the stage, and give it an instance name. The second way is to simply use ActionScript. While I see benefits to both methods, I’m going to be mostly focusing on bringing them in through ActionScript.

Let’s take a look at setting up our first Movie Clip with ActionScript. Click on Library, then right-click in the blank area, and click on New Symbol.

Create Flash Symbol

I named my Symbol ‘Ball’, so I also named my class ‘Ball’, and then Flash automatically set it up as a MovieClip for me. Click OK, and you’ll probably get a message about no class being there for it, that’s ok, click OK for that too.

Now you’ll need to put something on it. Double click on the symbol so its open in the stage area. Now go to Import, and Import to Stage. I decided just to draw a blue circle. You can use whatever you have handy.

Now its time to get the symbol onto the stage. One of the reasons I like using AS3 to pull in add the symbols to the game is you can pull in as many instances as you want with the addChild() function. I can also do about anything else I want with it at that point. I also don’t have to spend time trying to make my stage look pretty.

var myBall:Ball = new Ball();

addChild( myBall );

Simple as that. Now you have a quick and easy method to add basic symbols to your game. Now its time to add some properties to it. Open up your Actions Frame, and click on Layer 1, Frame 1. Enter in this code.

var myBall:Ball = new Ball();

myBall.x = 200;
myBall.y = 200;
myBall.rotation = 10;

addChild( myBall );

If you publish and run, you’ll see your flash movie with the object in the center of the screen. Its kind of dull and boring, and that’s not really what flash is about, so let’s jazz it up a bit. Let’s change our AS3 render a ball every 50 pixels until we hit 400 pixels.

for ( var i = 200; i <= 400; i += 50 )
{
	var myBall:Ball = new Ball();

	myBall.x = i;
	myBall.y = 200;
	myBall.rotation = i;

	addChild( myBall );
}

Now you have a basic understanding of working with Move Clips and AS3. We’ll talk more about keyboard and mouse, more elements on the stage, and collisions coming up in the next couple days. In the meantime, if you have any questions, please comment or e-mail me.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 9:47 PM
Jul 172011
 

I can’t say this enough to people. If you truly love doing something, go do it. Don’t just settle for something else because it was easier, or available. You won’t be happy, and you won’t do a good job no matter how hard you try. Ultimately you will feel like you’re rolling a rock up hill, and no matter how hard you keep pushing, eventually you’re going to run out of energy and you won’t be able to move forward any further.

I was talking with my brother in law on Friday night after my softball game. He is a currently-laid-off-Jr Architect working at his Alma Mater teaching and helping with co-op positions. We were talking about what if he never became a licensed architect, but had a healthy, happy career doing something related with his skills. Would he be a failure? Would he be unhappy?

I was 16 years old when I went to summer camp in NY with my Church Youth Group. We were assigned a counsellor, who I remember being a great guy, but I can’t for the life of me remember his name. One of the things that I can vividly remember is him going around cabin asking everyone what they wanted to do when they get older.

It was a time in my life when I had a clear vision of what I wanted my future to be. I wanted to own a video game company that developed games. I wanted people to walk into an arcade and not be disappointed. I wanted their “nintendo” experience to be unique. I wanted to create PC games and pretend I was Ken Williams, head of the now gone Sierra On-line, Inc., creator of some of the greatest games of my childhood.

Don’t get wrong, its not that I dislike what I do for a living. In fact, I like what I do. Sometimes it can be a little dull, but then there are times when I’m engineering code, or architecting a new section of a site or system that I remember how much I enjoy the creative part of my job. That part is what keeps me doing what I do. Without it, I have a hard time moving the rock up the hill.

Getting back to the questions presented by my brother in law. I don’t think it really matters if he becomes a licensed architect or not. If he received a phone call tomorrow from a small city asking him to take on the job as the city planner, he’d most likely take the position. At that point, fast forward 30 years, and you see him retired, happy, and looking back at his life with extreme satisfaction. He original set out to get a degree, and a license, but ultimate he found the path that made him a living, and more importantly, happy.

I’ve been heavily analyzing my life lately imaging what I would think if I looked back on 10 years of working where I am now. I’ve found myself feeling a deep sense of unrest, and I can’t shake the feeling that I’m going to miss so much more. But does that really mean I find a new job and hope the next one pans out? In my case, I don’t think so.

I’ve always had an interest in video games. Going back to the late 70s when I received my Atari 2600 on Christmas. Soon after I received my first computer, a TI 99/4a. Since then, I’ve had an interest in not only playing the games, but also creating games of my own. I’ve had the pleasure of making basic games for a poetry community. I also had the pleasure of working on a BBS door game back in the early 90s. Still, it hasn’t been enough to satisfy my creative side. It has fueled it even more.

This is where I am at in the crossroads that life has presented me. I have a job that pays my bills, but leaves me little sense of satisfaction, even if I get the occasional sense of accomplishment. I’ve also always looked at accomplishment as a temporary peace in life that won’t last past the next day.

I’ve decided to venture into the game development arena. Ben and I have been working on concepts games, mostly his ideas so far. He’s also a creative thinker, and he’s tapped a stream of ideas. Ideas that we’re going to slowly turn into tangible games.

The journey has been a little up and down so far. First there was much containment, then we decided to take a trip thru all the eras, and now we’re at a full tilt. I’ve been working on concepts for a flash game with my friend Ben of PixelVolume.com for the last month or so. We’ve often wanted to build a game together. He’s even joined a local game design group out in Chicago trying to find a project to latch on to that will give him his first published game. So far nothing has worked out.

We’ve been pretty focused on basic concept items so far. We’ve made plans, and divided up the tasks. Mine is is multipart. First, I need learn more Flash and ActionScript 3. After that, I need to learn how to work better with classes. Finally, it is my task to implement the physics aspects of the game.

Thanks to a nifty framework, I think I’m finally on the right track. It has all the elements that I need built in, and will help me learn, and help our project advance in a timely manner. I decided since this is my first project in Flash where I’m under some time constraints, and its been a little while since I had to use my fancy math portion of my brain, I could use a little help.

My immediate goal isn’t necessarily to release a game that will bring retirement to my doorstep, and have me traveling around the world. Its the satisfaction of completing something that people on a mass scale will enjoy. In the interim, its also the satisfaction of being able to use my creative part of my mind, build something fun, and get back to what brought true joy to my work.

My ultimate goals are a bit more ambitious though. I wrote in a previous post that Ben and me had started to develop an RPG several years ago. We took on an enormous project with no hopes of finishing it. It was just too big, too over our heads, and we didn’t have a story in place.

That piece of the project ultimately doomed us more than the programming aspect of the game. Sure, I could have spent another two years learning Direct3D and Ben could have taken a physics class while he was still in college. I’m sure at that point we could have written several PC games that did about nothing.

A well developed story is the essential key to a good RPG. Games like Oblivion, Final Fantasy 13, Lost Odyssey, and White Knight Chronicles haven’t seen huge sales volumes because they looked pretty. They had fully developed worlds, characters, plots, and stories. One could even be bold enough to say they would be best selling fantasy novels.

So what does that have to do with our RPG adventure? I’ve spent the better part of five years developing a world, characters, and six ages/generations of history. I haven’t even told my wife, Michele, about it. I’ve been carefully jotting down notes, and writing bits and pieces as I go.

I’m currently in the process of writing a story based around this world, and six key characters. The main character, Johnny, is an archeologist and hunter. He lost his parents in an attack from something called the Duroogai, and he thinks he has enough information to get them back. Still, the problem remains, no one believes him.

Half way through 2012 I’m planning on a taking a trip to E3. I’m going to have a detailed map of the world, and a book laying out all the characters, their history, history of the world, a briefing of each age/generation, and the story itself. By then I will have a detailed list of items, a battle system, drawings, cities, and everything else you’d expect from your favorite RPG.

Every time I talk to Ben about an aspect of the Flash game, or physics, or anything game related, it makes me feel alive again. Its the part of me that I lost, and I’ve finally found it again.

If you’ve found yourself in an unsatisfied state, or just feel that you’re at that point up the mountain where you want to push on, but you simply can’t, take a step back. You need to analyze yourself, your past, and find out what that missing piece is. Whether it be something that you’ve added to your job that is interfering with your happiness, or something you’ve eliminated all together, you need to take action.

Be careful in your next move. Don’t change jobs for the sake of finding change. Don’t make a lateral move to something else that you’re unsure of. Don’t take on extra work just to see if it can fill the unknown void. You must identity your path, where you went off, and where you can get back on.

If you don’t love what you’re doing, change it. If you can’t change it, look at it, analyze it, and find out what’s missing. Until you do that, you’ll be burning energy, and ultimate the rock you’re pushing will fall back down the hill, and run you over.

Dan Joseph is a Software Engineer/Architect.  

You can follow him on twitter @iamdanjoseph.  

If you wish to contact him, please click the contact page,
and fill out the form.
 Posted by at 10:34 PM