Prototype RPG Game – Part 2

January 3rd, 2010

A while ago I posted a Prototype RPG Game using the Sandy engine. Well, today I am not going to share the code, but how I managed to make it (I spent about 1 hour on it)… and you will probably slap your head and then go crazy making your own 3D prototype RPG game.

I suggest you go check it out first before you continue reading.

Looking at the level, you will see that there are cubes on a plane; or blocks on the ground if you prefer to call it. Also, moving your character around the stage you will notice that the blocks are randomly placed, yet evenly spaced. It’s almost like a grid of cubes/blocks on the X and Z axis. Hopefully that makes sense.

So how do you think I am managed to do the collision detection with the character? Some physics library like JigLib? No. That could have been possible, sure, but that also would have required more files, reading another documentation, praying flash doesn’t use more memory (haha, yeah right!), just to do some collision detection for some cubes.

So what did I do? I use the classic tiled based approach to accomplish this!

Go look at the Prototype RPG Game again and you will see it. I have had a lot of time developing tiled based games for fun (not any published though, ahh!) and a good amount of time on Tonypa’s tutorials on how to make the classic engine in flash. One day I decided it would be nice to make a 3D rpg game using flash, but I didn’t know how to do any collision detection… and that’s when I thought of combining the two.

The rpg prototype I presented has the camera behind the character and above the head. Its easy to change the camera to be above the character instead to give it the grand theft auto 1 and 2 game style approach. Or you can make an isometric game if you position the camera probably – and let the 3D engine do the depth sorting for you ;). Or you can make a 3D like mario platformer game. You may even be able to make a FPS (first person shooter) like this… just a thought though.

I am almost certain that most of the tutorials on Tonypa’s site can be used to make a tiled based 3D game. You would just need to rule out one of axises when doing collision detection, like I did in the prototype game. I used the Y axis for only setting the cubes and planes, then I used the X and Z axis to check for the tile collisions with the hero/character. For a mario like platformer, you wouldn’t use the Z axis and just use the X and Y axis.

A final note before you get started: don’t forget to adjust the code to consider the center points of the objects. For example, in a tiled based game the center point (or registered point) is the top left corner, the plane or a cube using anything is in the middle.

Again, I will share the code of what I done soon.

Share your thoughts on what you would now you know about this, lack for a better for word, trick.

AS3 > Flash > RPG