Art-Based RPG Tutorial

Art-Based RPG Tutorial

Part One :rd:

     Here it is. Something most of you guys have been waiting for. How to create an Art-Based RPG. Again, I’ll be using my lovable character : Marz to instead of walking around in a tile based environment, will now walk around in an art based landmass. Is it harder than tiles? Actually I found it to be easier to code for an art-based rpg instead of a tile-based.

     So what’s the big difference? Well that I will cover when I write my tile-based vs art-based rpg tutorial. But for now, let’s just worry about how we are going to work with an art-based rpg.

     In Part One we are going to discuss what it takes to make the hit boundries for a art-based rpg. The fact that it’s almost as simple as tile-based to make these hitBoundries is something to attest to. But before we get into that, let’s look at what we are going to be creating.

http://www.mentalconcepts.com/game/art_walking.swf

Note : At 100% jpeg quality and the code involved, the movie still stays around 50-60 kbs. Not too shabby.

     Now, here is the interesting part. What does it involve? Well, my character already knows how to walk around, so we shouldn’t have to go over that again. But in case you need a piece of code, here is my function that allows my character to walk and walk with animation as well. You can find more out about this function in my original rpg game programming tutorial.



MovieClip.prototype.moveMan = function(moveX, moveY, facing)
{
	if(_global.aniMation == 5)
	{
		_global.aniMation = 1;
	}
	else
	{
		_global.aniMation++;
	}
	currentFacing = (facing * 5) + _global.aniMation;
	this.gotoAndStop(currentFacing);
	this._x += moveX;
	this._y += moveY;
}

_root.onEnterFrame = function()
{
	// Walking Script for Marz
	
	if(Key.isDown(Key.DOWN))
	{
		if(!walkingMarz.testLimits(0, 5))
		{
			walkingMarz.moveMan(0, 5, 0);
		}
	}
	else if(Key.isDown(Key.UP))
	{
		if(!walkingMarz.testLimits(0, -5))
		{
			walkingMarz.moveMan(0, -5, 1);
		}
	}
	else if(Key.isDown(Key.RIGHT))
	{
		if(!walkingMarz.testLimits(5, 0))
		{
			walkingMarz.moveMan(5, 0, 2);
		}
	}
	else if(Key.isDown(Key.LEFT))
	{
		if(!walkingMarz.testLimits(-5, 0))
		{
			walkingMarz.moveMan(-5, 0, 3);
		}
	}
}


     Now. In this you will see another function. The testLimits function. This function allows us to test for boundries. But first, let’s check out the boundries for the art-based RPG above.

     OOoo… Let’s check out the function that tests our limits in this now.


MovieClip.prototype.testLimits = function(xdisplacement, ydisplacement)
{
	ydisplacement += 20;
	for(var i in _root.limits)
	{
		if(_root.limits*.hitTest(this._x+xdisplacement, this._y+ydisplacement, true))
		{
			return true;
		}
	}
	return false;
}

     This allows a quick and easy system to be made. You can create a whole messload of boundries, place them inside of a movieClip named limits, and this function will rotate through them all to make sure you are hitting them correctly. The returning result will tell you if they run into a wall : true or if they don’t run into a wall : false.

     Now… A couple of the variables you see in this might look a little bit awkward. Lemme explain. I am using this variable to check and see if I should move the character, so I use the testLimits function with an xdisplacement / ydisplacement factor to allow me to check ahead of my character. You can change around these values to change where you want your character to be tested. There are a whole sleugh of options available.

     Hopefully you guys took in the ease of using those functions. As always, if you have any questions post here or PM me :slight_smile: Peace