NOTE: I have moved the flash movie to the bottom of the post so it doesn't overlap the sidebar
I know what you're thinking..."That's a Teenage Mutant Ninja Turtle isn't it?"
The reason for this is that I am focusing on the code and redoing the graphics will be very time consuming and pointless if I can retrieve them from my broken laptop. As the amount of frames of this game sprite match the amount of frames I want for my character it is perfect for mapping out the code and getting an idea of how it will run. I have spent hours and hours working on the code over the past few days. I found a useful tutorial at:
http://www.mrsunstudios.com/2008/08/tutorial-create-a-platform-game-in-as3/
That came in handy for getting the gravity working right. The majority of my time has been spent getting the animations right. It seems like a simple task getting the character to move, however I had various problems. For example, As the character animation function was set to recall on every frame, the character would never move past the first frame. I solved this (eventually) by making a few variables;
var standFrame:uint = 1;
var walkFrame:uint = 13;
var jumpFrame:uint = 24;
(these set the initial frame of each type of animation)
var standFrameStart:uint = 1;
var walkFrameStart:uint = 13;
var jumpFrameStart:uint = 24;
(these set the definite start frame of each type of animation)
var standFrameEnd:uint = 13;
var walkFrameEnd:uint = 24;
var jumpFrameEnd:uint = 31;
(these set the definite end frame of each animation
Then what I had to do was create another function that was recalled on each frame to calculate what the frame should be and counteract the 1 i was having problems with, here's a bit of it:
mcDevil.addEventListener (Event.ENTER_FRAME, frameProgression);
function frameProgression(event:Event):void{
if (standFrame <= standFrameEnd && standWalkJump == 1){
standFrame ++ ;
}
if (standFrame >= standFrameEnd && standWalkJump == 1){
standFrame = standFrameStart;
}
Then instead of having the animation go repeatedly to frame 1 for example, i linked it to the current frame variable because it added 1 to the frame value every frame then went back to the start when it reached the end. I know it sounds complicated but thats because it is. I spent a while getting it right!! I also had to set up a few conditional commands to make it jump to the right loop. I did this by creating an variable called standWalkJump with a value of either: 1(stand), 2(walk), 3(jump).
Then I made a few conditions, so "if the right key is pressed and the character isn't jumping then standWalkJump = 1(stand" this is the code for that:
if (rightKeyIsDown && mainJumping == false){
standWalkJump = 2;
jumpFrame = jumpFrameStart;
standFrame = standFrameStart;
}
I know at the moment there isn't much of a game as such, but I thought I would show my progress, as I feel that I have reached a massive milestone. I am also getting much better at flash and really starting to get to grips with how things work.
NEXT: I am going to try scan in my sketches later on and show the progression from paper to 2D image to 3D image. I might even start sketching out my jumping animation as it would be nice to see him move again!
Sunday, 20 December 2009
Play My Game!! (So far)
Posted by lco1987 at 03:23
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment