Hello, this is the second part for the jetpack game tutorial things. In this tutorial I will show how to make some platforms and walls and that. Easy as pie ![]()
Remember that this is actionscript 2!
When you’ve followed the last tutorial right, you should have a single mc on the stage called “fly” or something. That’s good. Then we have atleast something there. But, now, you should draw the ground. It should look something like this:

![]()
Select the ground, right click it and click “Convert to symbol…”. Name it whatever you want. Press Ok. Now, make the instance name of it ground. To give it a instance name, select the movie clip and bring up the properties menu for it. It looks like this:

Now it has a name, and you probably now know where to find the instance name. Good. And thats the only thing necessary to make platforms, but you need the code. Click the main timeline frame, and those who don’t know what that is, its this:

So, you can either right click it and select “Actions” or just click it and press F9. A window pops up. Paste this code into there:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | yspeed = 0; xspeed = 0; gravity = 0.2; rotationspeed = 0; power = 1.1; friction = 0.9; fly.onEnterFrame = function() { while (ground.hitTest(fly._x, fly._y, true)) { fly._y--; } while (ground.hitTest(fly._x-25, fly._y-25, true)) { fly._x++; xspeed = 0; } while (ground.hitTest(fly._x+25, fly._y-25, true)) { fly._x--; xspeed = 0; } while (ground.hitTest(fly._x, fly._y-fly._width, true)) { fly._y++; yspeed = 0; } if ((_root.ground.hitTest(fly._x, fly._y+1, true))) { yspeed = 0; } xspeed *= friction; this._x += xspeed; rotationspeed *= friction; this._rotation = 0+rotationspeed/2; this._y += yspeed; if (Key.isDown(37)) { xspeed -= power; rotationspeed += power*xspeed/2; } else if (Key.isDown(39)) { xspeed += power; rotationspeed += power*xspeed/2; } if (Key.isDown(38)) { yspeed -= power; fly._y -= 0.2; } if (yspeed<0) { yspeed *= friction; } yspeed += gravity; }; |
Now you can try the game or what you want to call it. You only have to press ctrl+return. it flies around nicely and hits the walls and stuff pretty good. It looks like this if youve done right:
There’s not much new things to explain here. As you see in the code, I’ve removed the if thing that checks if the jetpack guys _y is more than 340, and some other things.
The new stuff in the code are the while loops. They check if the fly guy hits the ground in different positions, and then resets y- or xspeed. And does fly._x–; and the others. A while loop is a super fast loop that runs as many times it can while a condition is true. But, if you use it in wrong places or in wrong ways it can easily crash your flash player.
Yup, its that easy to make a beginning to a “jet pack game”. Cheers to you all!
![]()
But, if you’re smart enough to not understand this, or cant get it to work, here’s the source.














May 19th, 2008 at 22:00:11
[...] Jetpack game - part 2 [...]
May 20th, 2008 at 10:56:32
nice, im making a similar sort of game except the wall is moving around the player and i cant get it to work properly if your willing to help answer
May 28th, 2008 at 17:11:49
Great tutorial, but I have one question: the collisions act like the platforms are a couple pixels lower than they are. Anyone know whats wrong?
June 3rd, 2008 at 21:31:39
So I did everything you said, but My fly guy goes partially into walls when colliding from the top and doesn’t go close at all when colliding from the bottom. It’s not a box shaped guy and the walls aren’t flatt. is that a problem? Can somebody help!? Please, and thanks
June 17th, 2008 at 05:17:46
cmon, its a great tutoial, plz continue this tutorial U ROCK!
June 19th, 2008 at 06:12:17
Sooo good thank you
June 19th, 2008 at 15:50:40
umm is there a way for part 3 where u can make landing spots and levels and gas and health and gas powerups and health power ups. lol a mouthful so if u can plz do
June 23rd, 2008 at 23:43:18
tnx for the tutorial i folow the steps and i do this http://amsterdam1.plunder.com/142927/jet%20pack%20adventure%20stick.swf
please do a 3 tutorial
August 17th, 2008 at 23:06:02
You must makesure that the registraction point is at the bottom of you character(jetpack in this case).
November 2nd, 2008 at 19:08:02
[...] Part 2 [...]
December 1st, 2008 at 17:58:47
it has problems on mx4 when the guy comes back down and hits the floor he can’t move then you half to restart the swf help me please
January 5th, 2009 at 14:58:25
very good
January 16th, 2009 at 19:37:08
very good, but registration
point MUST BE DOWN or it doesnt work. NICE WORK
January 25th, 2009 at 22:32:18
yeah….the flyin works but the collidin dosent…..it says ive got 7 errors in my actionscript….i copied and pasted the code…so its not typed wrong..any help?anyone?
January 29th, 2009 at 02:57:51
is this for Macromedia flash 8 cause the walls are doing anything, do u draw the walls in a new layer or in a new frame. And my thing for naming the instance is not the same? someone help plz?
January 29th, 2009 at 20:40:51
ok so now im colliding but i cant hit the cieling, it wont let it get close? someone plz help, does it matter what shape the fly thing is???
February 13th, 2009 at 13:28:54
There’s a problem with the code for the platform. It doesn’t seem to work.
Any help?
March 26th, 2009 at 21:22:55
Nice thx man
coooooooooooooooooool
May 1st, 2009 at 09:49:21
When u move it out of the screen it disapears cn u make it scroll so the guy is always in the middle