I would like to demonstrate how to make my version of an Astrolander game. My version consists just the basics of movement through space, collision detection with the ground, and collision detection with the platform which you must land softly and vertically or your ship will crash. Hopefully with this basic tutorial you will be able to grasp the concept and expand more ideas into this type of game. So lets begin by setting up the 3 movie clips we will be using, the Rocket, the Ground/Level, and the Platform.
This tutorial is continuing from last one posted here: RPG Character Movement – Part 1
In the last tutorial we talked about basic movement and key detection. This time we are going to cover Hero walking animation and collision detection.
First, lets begin opening our Hero movie clip set in the Library. Highlight both the left and right circled arms and convert it to a movie clip. Give the movie clip the name “arms” since this movie clip are the arms of our Hero. In the “arms” movie clip, create a tween for each of the circled arms, moving them back and forth of each other to represent the moving arms of our Hero when walking.
This Actionscript 3 class is very useful for just about any game you are developing in Flash. I made this “SmashCam” class based off of Colin Moock’s vCam. I was really impressed by what it can do for animators in Flash and it inspired me to use it for developers who make Flash games. The vCam isn’t really complicated a script, it is very straight forward – its a real clever script on how to use a movie clip as a camera. Let me show you what the script does in action, move the blue circle with arrow keys around the stage.
The SmashCam is actually set right now to focus and maintain the square and circle in the center of the stage as the two movie clips move around and about. But in this example only the blue circle is moving. The green painted clouds on the stage are there to help you see that blue circle is moving and the stage is enlarging and shrinking to the affect coming from the SmashCam.
I won’t go into too much detail on how to setup the .fla to have the circle move around stage, since that tutorial is in my last post, but I will show how to set up the SmashCam. This is what is you need to do:
// SmashCam(display_container:MovieClip, target1:MovieClip, target2:MovieClip, [width:int = 600, [height:int = 450]]);
var camera:SmashCam = new SmashCam(this, Circle, Square);
Thats it. The SmashCam takes three required parameters, the
target2, and two optional parameters
height (the default width is 600, and default height is 450). You can also set up the SmashCam’s minimum and maximum width and height of how far it should scale the
display_container like so:
camera = new SmashCam(this, Circle, Square, 550, 400);
camera.min_width = 200;
camera.min_height = 150;
camera.max_width = 2000;
camera.max_height = 1500;
All that is left to explain is the calculation of the SmashCam executed every frame. To do so, in the main game loop add this line of code:
I will let you do the rest of the experimenting and looking into of what the SmashCam Class is really doing. I appreciate any feedback on improvements or better alternatives. Or if you have questions, I will do my best to explain. Thanks and have fun!
Today I am going to share a small sample of RPG type character movement using Flash Actionscript 3. I will say up front, this sample will look very boring, but this tutorial is for Actionscript 3 beginners. However, I will continue to build examples and more tutorials off this one. I also would like to point out that I will be writing this code in the main time line, which is something you should try not to do in Actionscript 3. So why am I writing the code on the main time line? In honesty, this is how I begin to program in Actionscript 3 to help understand the newer syntax and different structure and event handling and everything Actionscript 3 has to offer from Actionscript 2. I also would like to point out that I am not going to discuss all the syntax throughly (for the most part, but I will try my best), because if you want to program games, you will have to do some research and testing on “hows” and “whys” and “what the…?”.
So lets begin with the sample of what you will have by the end of this tutorial:
Just last week, a company from Russia called “Alternativa” released a 3D engine developed in Flash using the new Actionscript language, Actionscript 3. This 3D engine packs a powerful punch for what is capable of doing. To name a few: dynamic lighting and shadows, bum mapping, parallax mapping, automatic UV-mapping, sprite lighting, texture objects, animation system, 3D-objects interactivity, and many more. Tracking back as far as their blog lets me, the company and team have worked on this engine for over 2 years, and it currently on version 5.0.1. Very impressive if you ask me.
Well I downloaded the files to see what magic I can do. The files come in a SWC format to prevent you from peeking around in their code. Also with SWC, you need to manually place the files in the Configuration/Components directory of where you have Flash installed on your computer. After restarting Flash, I opened the Components tab and placed the packages in my Library, created a new Actionscript file, and got to work on some fun 3D stuff. Moving from 2D to 3D takes a little more thinking power, but it was a whole lot of fun doing so! Anyways, enough boring talk, let me show you what I accomplished over the past of days:
A – move left
D – move right
W – move forward
S – move backward
SPACE – jump
MOUSE – click and drag to look around
Its a small city with random color building blocks and cones. I also made sidewalks to give it a more city feeling ;). Not too much to show, I know, but again, its a new 3D engine that just came out so there is much to learn.