Create a flash draw game like Line Rider or others - part 5

Finally this tut has its 5th part.

You should read steps 1 to 4 before continuing with this one, although this time it's not so important, because before to approach the "running car" I am going to explain the "walking man" on a line.

The same kind of gamestyle you can find in draw play 1 and 2.

Believe or not, this is an important step to understand before adventuring into running cars.

Now, let's start.

I said we are going to see a man walking on a line we created.

As usual the "line" is instanced as terrain while the code I am showing is the one in the "player" object... yes, that red box is supposed to be the player...

The player is falling

The first thing to do is determine when the player is falling and when the player isn't falling. If you think about the real world, a man is falling when there is no ground under his feet. Or when he's so drunk. Or both. But at the moment we are only interested about the ground.

So, let's translate real world physics into actionscript:

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4. }
  5. onClipEvent (enterFrame) {
  6.     if (_root.go) {
  7.         yspeed += gravity;
  8.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  9.             _y--;
  10.             yspeed = 0;
  11.         }
  12.         _y += yspeed;
  13.     }
  14. }

Line 2: Set the gravity at 0.2

Line 3: Set the yspeed (vertical speed) to zero

Line 6: Checks if _root.go is true. This is true once the "go" button is pressed. It's not important for the game, I put it just to make the movie wait for a user input before starting.

Line 7: Gravity calls... yspeed is increased by gravity value.

Line 8: Performing a hit test between the terrain and the _x, _y+_height/2 spot. Since the anchor point of the player is on its center, you can easily understand the spot is located in the middle on the bottom side. Basically, the player's feet.

Line 9: raising the player of one pixel (obviously, since the player must be sunk at the moment)

Line 10: set yspeed to zero (no need to fall if we are sunk into the ground)

Line 12: add yspeed to _y position

Look at the movie:

The player is not stable to the ground. Maybe the floor is too hot, maybe the code has something to be fixed.

The problem is that once the player touches the ground, I continue adding yspeed to _y position, so the player sinks a bit into the ground. Then, the while loop raises him a bit, just to watch him sinking again. That's why the player seems to flick.

The player is falling - part 2

I need a hack to tell the "physics engine" to stop considering yspeed if the player has its feet on the ground

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4. }
  5. onClipEvent (enterFrame) {
  6.     if (_root.go) {
  7.         yspeed += gravity;
  8.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  9.             _y--;
  10.             yspeed = 0;
  11.         }
  12.         if (!_root.terrain.hitTest(_x, _y+_height/2+1, true)) {
  13.             _y += yspeed;
  14.         } else {
  15.             yspeed = 0;
  16.         }
  17.     }
  18. }

Lines 12-13: The yspeed value is added to _y (old line 12) only if the player is in the air. Look at the +1 in the _y+_height/2+1. I need to "forecast" next player's position and if I find it will be in the ground, then I stop considering the gravity. Otherwise lines 14-15 set yspeed to zero.

Now the player is falling in the right way.

Let's make him walk now.

The player is moving

To make the player move, we need to check if some keys are pressed and manage the x speed according to the key pressed.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4.     xspeed = 1;
  5. }
  6. onClipEvent (enterFrame) {
  7.     if (_root.go) {
  8.         if (Key.isDown(Key.LEFT)) {
  9.             _x -= xspeed;
  10.         }
  11.         if (Key.isDown(Key.RIGHT)) {
  12.             _x += xspeed;
  13.         }
  14.         yspeed += gravity;
  15.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  16.             _y--;
  17.             yspeed = 0;
  18.         }
  19.         if (!_root.terrain.hitTest(_x, _y+_height/2+1, true)) {
  20.             _y += yspeed;
  21.         } else {
  22.             yspeed = 0;
  23.         }
  24.     }
  25. }

Line 3: Set x speed to 1

Lines 8-10: If the left key is pressed, I move the player xspeed pixels to the left

Lines 11-13: Same thing with the right arrow key

Now the player can walk!!

But... try to walk to the left margin of the stage... or to the right one... you may notice there is a hard slope, but the player walks on it as if it was a plain ground. That's not realistic!!

The player is moving - part 2

In order to make the player stop walking when on a too hard slope, we have to define a "knee" point. If the "knee" hits the ground, it means the ground is a hard slope, or a stair, o whatever thing the player can't climb.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4.     xspeed = 1;
  5. }
  6. onClipEvent (enterFrame) {
  7.     if (_root.go) {
  8.         if (Key.isDown(Key.LEFT)) {
  9.             if (!_root.terrain.hitTest(_x-_width/2, _y+_height/4, true)) {
  10.                 _x -= xspeed;
  11.             }
  12.         }
  13.         if (Key.isDown(Key.RIGHT)) {
  14.             if (!_root.terrain.hitTest(_x+_width/2, _y+_height/4, true)) {
  15.                 _x += xspeed;
  16.             }
  17.         }
  18.         yspeed += gravity;
  19.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  20.             _y--;
  21.             yspeed = 0;
  22.         }
  23.         if (!_root.terrain.hitTest(_x, _y+_height/2+1, true)) {
  24.             _y += yspeed;
  25.         } else {
  26.             yspeed = 0;
  27.         }
  28.     }
  29. }

Line 9: Before moving the player to the left, I assure his "knee" (located to the leftmost side of the square at a quarter height of the player) is not touching the ground.

Line 14: Same thing with the right side.

Now the player cant' walk on slopes!! Now we want the player to jump

The player is jumping

To make the player jump, I am going to check if the SPACE key is pressed

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4.     xspeed = 1;
  5. }
  6. onClipEvent (enterFrame) {
  7.     if (_root.go) {
  8.         if (Key.isDown(Key.LEFT)) {
  9.             if (!_root.terrain.hitTest(_x-_width/2, _y+_height/4, true)) {
  10.                 _x -= xspeed;
  11.             }
  12.         }
  13.         if (Key.isDown(Key.RIGHT)) {
  14.             if (!_root.terrain.hitTest(_x+_width/2, _y+_height/4, true)) {
  15.                 _x += xspeed;
  16.             }
  17.         }
  18.         if (Key.isDown(Key.SPACE)) {
  19.             yspeed = -5;
  20.         }
  21.         yspeed += gravity;
  22.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  23.             _y--;
  24.             yspeed = 0;
  25.         }
  26.         if ((!_root.terrain.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) {
  27.             _y += yspeed;
  28.         } else {
  29.             yspeed = 0;
  30.         }
  31.     }
  32. }

Lines 18-20: If the SPACE key is pressed, the yspeed is set to -5 (since yspeed is affected by gravity, a negative value will make the player fly).

Line 26: In the if statement I add a check: If the yspeed is less than zero (player jumping) I add the yspeed to _y even if the player is not going to touch the ground. Without that condition, the player will never jump.

Look at our jumping player!

Again, it's not over... as you can see, if you press SPACE while the player is in the air, the player will jump again, and again... you can make the player fly and I don't want it.

The player is jumping - part 2

I need a variable to decide if the player can jump or not. Basically, a player can always jump execpt when he is already jumping

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     gravity = 0.2;
  3.     yspeed = 0;
  4.     xspeed = 1;
  5.     jumping = 0;
  6. }
  7. onClipEvent (enterFrame) {
  8.     if (_root.go) {
  9.         if (Key.isDown(Key.LEFT)) {
  10.             if (!_root.terrain.hitTest(_x-_width/2, _y+_height/4, true)) {
  11.                 _x -= xspeed;
  12.             }
  13.         }
  14.         if (Key.isDown(Key.RIGHT)) {
  15.             if (!_root.terrain.hitTest(_x+_width/2, _y+_height/4, true)) {
  16.                 _x += xspeed;
  17.             }
  18.         }
  19.         if ((Key.isDown(Key.SPACE)) and (!jumping)) {
  20.             yspeed = -5;
  21.             jumping = 1;
  22.         }
  23.         yspeed += gravity;
  24.         while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
  25.             _y--;
  26.             yspeed = 0;
  27.             jumping = 0;
  28.         }
  29.         if ((!_root.terrain.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) {
  30.             _y += yspeed;
  31.         } else {
  32.             yspeed = 0;
  33.             jumping = 0;
  34.         }
  35.     }
  36. }

Line 5: initializing a variable to tell the player is not jumping

Line 19: Added the control if the player is NOT jumping when SPACE key is pressed.

Line 21: Set the jumping variable to 1. Actually, the player is jumping (so he can't jump anymore until he touches the ground)

Lines 27 and 33: Set the jumping variable to zero. When the player is hitting the terrain, or when the player is about to hit the terrain, he is not jumping, or the jump is over.

There are some other things to fix but at the moment it's over.

Download the full source codes and give me feedback

Websites of Interest: casino game

Improve the blog rating this post
Tell me what do you think about this post. I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (10 votes, average: 3.6 out of 5)
Loading ... Loading ...

» Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.

96 Responses to “Create a flash draw game like Line Rider or others - part 5”

  1. Alex on March 31st, 2007 1:21 am

    NICE JOB
    A

  2. Alec on March 31st, 2007 5:15 am

    Thank you so much!
    Your tutorials are some of the best on the net…
    This Line Rider game is something I’ve been wanting to build since I started with Flash…
    Your Actionscript explanations are thourogh and clear; and the game I made with parts one through four has been played for hours by both my sisters… I usually create an obstacle course, and let my sisters find their way around it…
    One thing I’m trying to learn to do is influence the “ball” with the arrow keys. I’ve managed to add a “reset ball” button which resets the ball and allows you to add terrain. A “line erasing” tutorial would be great also…
    Keep up the great work and simple tutorials!
    -Alec

  3. Alec on March 31st, 2007 6:03 am

    Oh… Wow! I did this tutorial and input
    if (Key.isDown(Key.RIGHT)) {
    _x = xspeed;
    into the ball code; right after the collision code for the first tutorials… Now, by pressing the up key while close to the ground, the ball flies far higher than before. This is useful for annoying spots where the ball is stuck behind a wall or in a crevice…

  4. mousey on March 31st, 2007 10:47 am

    very cool.

  5. george on March 31st, 2007 4:30 pm

    Thanks man. i made a sweet game because the tutoirals you have explain everything clearly.

    can you add a part 6 and make an erase button to delete some lines without eraseing them all?

    cool

    :)

  6. george on March 31st, 2007 4:33 pm

    Woops. almoast forgot.

    i made a “free play” part in thr game other than the levels.

    can you tell me the code to move theexit with the arrow keys.
    i copied the code for movement from my “hero” game (one of the tut’s u poasted very cool) but it dosent work.

    HELP ME lol

    :)

  7. srikant on March 31st, 2007 5:29 pm

    which version of flash player is required to develop this

  8. And Mar on March 31st, 2007 9:47 pm

    Awesome tute!

    In your next one I would really love to see how to make the car/ rectangle rotate so both wheels would be on line.

  9. abhilash on April 1st, 2007 8:13 am

    excellent!!
    can’t wait for next!!

  10. bigbill on April 1st, 2007 2:57 pm

    Excellent however im using your coding but I’m still seeming to get the bobbing action in certain areas?

  11. Alec on April 1st, 2007 10:30 pm

    I have a question for anyone who reads this… Thanks in advance…
    How would I code the exit point to take the playhead to the next frame? I would really like to know this because then I can have levels. I’ve seriously tried everything, but even without the “stop code” the ball freezes on the exit point.

  12. abhilash on April 3rd, 2007 12:04 pm

    in reply for alec:
    its simple, copy the below code for ball
    onClipEvent(enterFrame) {
    if (_root.exit.hitTest(_x, _y, true)) {

    _root.gotoAndPlay(FRAMENUMBER)
    }
    replace FRAMENUMBER by the frame you want to go.
    I’m not sure it will work but still you can try.

  13. hasna on April 4th, 2007 1:46 pm

    george: make a button in the exit mc with this action script:

    on (press) {
    drag = true;
    }
    on (release) {
    drag = false;
    }

    and on the exit mc put this code:

    onClipEvent (load) {
    drag = false;
    }
    onClipEvent (enterFrame) {
    if (drag == true) {
    this._x = _root._xmouse;
    this._y = _root._ymouse;
    }
    }

  14. .Kada$h on April 5th, 2007 8:41 pm

    That’s so cooool
    You’re really good at it
    I’d like to be as fantastic as you are :D
    I also have MFP 8 I’ve just downloaded it and like now I don’t know what to do with it ^^ I’m learing how to use it :D
    I used Adobephotoshop before…
    .Cheers

  15. frefwiea on April 7th, 2007 12:45 am

    abhalisha i enterd the action script an**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 17: ‘else’ encountered without matching ‘if’
    } else {

    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 74: Unexpected ‘}’ encountered
    }

    **Error** Scene=Scene 1, layer=Layer 2, frame=2:Line 17: ‘else’ encountered without matching ‘if’
    } else {

    Total ActionScript Errors: 3 Reported Errors: 3
    d it didnt work it said

  16. name on April 11th, 2007 3:57 am

    i was wanting to make a game sorta diffrent to this were u can move but without gravity as if your looking for a birds eye view.

    you can move all derections but cant go through lines. sort of like whats happening here but i dont know how to do it could you help me?

    it a bit hard to explain lol soz if this makes no sense :S

  17. eblup on April 13th, 2007 1:51 am

    hey iam kinda mad at you because you kinda coppyed my code but o well. my code:

    onClipEvent (load) {
    j = 0;
    c = 1;
    }

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    if (c > 0) {
    j = -6;
    this._y -= 6;
    c = 0;
    }
    }
    }

    onClipEvent (enterFrame) {
    if (j > 3) {
    j = 3;
    }
    }

    onClipEvent (enterFrame) {
    if(_root.ground.hitTest(_x (_width/2),_y,true)){
    _root.ground._x = 10;
    }
    if(_root.ground.hitTest(_x-(_width/2),_y,true)){
    _root.ground._x -= 10;
    }
    if(_root.ground.hitTest(_x,_y (_height/2),true)){
    _y -= 3;
    j = 0;
    c = 1;
    }else{
    j = 1;
    this._y = j;
    }
    if(_root.ground.hitTest(_x,_y-(_height/2),true)){
    j = 3;
    }
    }

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    _root.ground._x -= 6;
    _xscale = 100;
    _root.guy.gotoAndStop(2);
    }else if (Key.isDown(Key.LEFT)) {
    _root.ground._x = 6;
    _xscale = -100;
    _root.guy.gotoAndStop(2);
    }else{
    _root.guy.gotoAndStop(1);
    }
    }

    can you try to make it so when he goes up a hill he tilts like in fancy pants advinture

    plz reply

  18. eblup on April 13th, 2007 2:12 am

    i used youre code with my code to make

    onClipEvent (load) {
    j = 0;
    c = 1;
    }

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    if (c > 0) {
    j = -6;
    this._y -= 6;
    c = 0;
    }
    }
    }

    onClipEvent (enterFrame) {
    if (j > 3) {
    j = 3;
    }
    }

    onClipEvent (enterFrame) {
    if(_root.ground.hitTest(_x (_width/2),_y,true)){
    _root.ground._x = 5;
    }
    if(_root.ground.hitTest(_x-(_width/2),_y,true)){
    _root.ground._x -= 5;
    }
    while(_root.ground.hitTest(_x,_y (_height/2),true)){
    _y–;
    j = 0;
    c = 1;
    }
    if(!_root.ground.hitTest(_x,_y (_height/2),true)){
    j = 1;
    _y = j;
    }
    if(_root.ground.hitTest(_x,_y-(_height/2),true)){
    j = 3;
    }
    }

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    _root.ground._x -= 5;
    _xscale = 100;
    _root.guy.gotoAndStop(2);
    }else if (Key.isDown(Key.LEFT)) {
    _root.ground._x = 5;
    _xscale = -100;
    _root.guy.gotoAndStop(2);
    }else{
    _root.guy.gotoAndStop(1);
    }
    }

  19. sirus on April 16th, 2007 12:06 am

    are u making a next part or is this the last?

  20. Emanuele Feronato on April 16th, 2007 12:30 pm

    It’s not the last… a lot more will come.

  21. madpassion on April 17th, 2007 4:22 am

    help meee..lol…i got lost on the very first step :( .Im not that experienced.

  22. Jesuson on April 18th, 2007 1:53 am

    THANK YOU !!!!
    I want to tell u how useful are your tutorials.
    I start to learn actionscript with them and I have beem trying to complete the develop of a game like line rider since some weeks ago.
    After try to write the script for collisions using the hitTest in all the ways I have found a better method in a flash called attractors.
    I´m next to coplete the game. Here I write the links for “attractos” and for my “line cross rider” preview.

    http://www.thecleverest.com/content/attractors.swf

    http://denvish.net/ulf/180407/4978_Line_Cross _Rider_beta4.php

  23. Blarg on April 22nd, 2007 10:39 pm

    Hey, Love your tutorials. But i was wondering, are you going to do a tutorial on how to make a game like the one on this page? http://www.playgamesclub.com/online-games/puzzles–brain-online-games/free-rider.html

    Thanks for your work so far and I’ll be waiting for a reply.

  24. Emanuele Feronato on April 22nd, 2007 11:30 pm

    I think it’s simpler than LR.

    A good idea for an intermediate step, I’ll try to do something like this.

  25. Blarg on April 22nd, 2007 11:52 pm

    Ok, thanks very much. BTW, is there any way to use the script you have provided, along with the drawing script, to make a basic game like the draw play? because i’ve been trying and it’s not really working… I’m really not the best at Actionscript.

  26. Blarg on April 23rd, 2007 2:18 am

    And, if you dont mind me asking, when do you think you’ll have your next tutorial out?

  27. crawfy on May 12th, 2007 8:01 pm

    Hi, I’m new to actionscript, and I was wondering if you could publish a script to tell me how, that if you press space when you’re already in the air, it makes no difference, you start descending after hitting the space bar once.

  28. crawfy on May 12th, 2007 8:06 pm

    oops, sorry, you already do it

    could you do something for a scrolling screen please?

  29. doom boy on May 13th, 2007 2:43 pm

    Please can you make a tutorial on how to make a game like adventure quest

  30. Grifo on May 20th, 2007 3:37 am

    Hi Emanuele.
    You’re great at Code(and you’ve got the biggest patience I’ve ever seen too).
    I was wondering, how do you estabilish the player’s position
    over the platforms, after he jumps from beneath one of them?
    I saw lots of people doing this, and lots of mistakes as a result. Do you simply estabilish a fixed position one some part of the square

  31. Grifo on May 20th, 2007 3:37 am

    Hi Emanuele.
    You’re great at Code(and you’ve got the biggest patience I’ve ever seen too).
    I was wondering, how do you estabilish the player’s position
    over the platforms, after he jumps from beneath one of them?
    I saw lots of people doing this, and lots of mistakes as a result. Do you simply estabilish a fixed position one some part of the square

  32. Tim on June 6th, 2007 1:29 am

    Um…when can we expect part 6? i’ve been waiting for quite a long time and would love to know how to continue making the game.

  33. Ryan on June 7th, 2007 11:43 pm

    That would be nice. If he does make another, my guess would be it would be near the end of june.

  34. Ryan on June 7th, 2007 11:44 pm

    Yah, will there be a part six? Are you making one? Please post a reply for us.

  35. Emanuele Feronato on June 7th, 2007 11:59 pm

    Sure, I am working on it

  36. Art on June 8th, 2007 8:15 pm

    Emanuele your the best, now I can program really well because
    of your tutorials. I’m kinda knew to actionscript.

    What dose this operator do?” while () {} “

  37. crawfy on June 11th, 2007 6:52 pm

    hi, ur great.

    i wondered if in the next part you will be including screen follow.

    please do.

    cud someone show me how to go back to the start point on collision with, for example, spikes? creatin a platform game

  38. Art on June 13th, 2007 9:28 pm

    Hi

    crawfy, you wanted to know how to restart a players position, here:

    _root.spike.hitTest(_x, _y, true){
    _x = 5
    _y = 5
    }

    or for the hitTest you can use this:

    _root.spike.hitTest(this){}

  39. Art on June 18th, 2007 11:32 pm

    Very cool tutorial,
    what dose this code mean though? :

    while () {}

    thanks in advance :)

  40. Mitch on June 19th, 2007 9:33 pm

    How do you make the square adjacent to the line? the bottom of the square says flash and does not go flat with the line? can you tell me?

  41. tim on June 20th, 2007 10:38 pm

    how could i remove the line after i drew it?

  42. person on June 21st, 2007 8:59 pm

    your tutorials are the best, I come to this site all the time to see when part 6 is done.

  43. s0daplayer on June 23rd, 2007 12:46 am

    Adventure quest can’t be made purely with flash doom boy, you need to set up and server and create a few php scripts and some databases. which take lots of money.

  44. crawfy on June 24th, 2007 7:38 pm

    thanks art

  45. luciano on June 24th, 2007 7:43 pm

    line rider 1.

  46. Chad Horton on June 25th, 2007 9:07 pm

    I am trying to reach you about business opportunities

  47. badri on July 12th, 2007 10:58 am

    iam seen your tutorials it is very nice but now iam in learning stage. Will you please give me some simple and best examples which I can understand easily thankyou

  48. some1 on July 21st, 2007 1:27 am
  49. Marius on July 26th, 2007 4:19 pm

    Hi

    Just found your tutorial and it’s awsome, thank you! When does tutorial number 6 come? I’d love to see another part of this great tutorial…

  50. Redoox on July 27th, 2007 4:49 pm

    Good and clear tut.

    But it made me wonder how far that “nice red block” actually can jump!!

    you can try it out yourself: :P
    http://redox.awardspace.com/sports/pituushyppy.html
    Same keys as in this tutorial..just jump on to red line..and..oh well,that was it.

    (yep,I was bored…)

  51. Emanuele Feronato on July 27th, 2007 5:05 pm

    10.323

  52. SHIV on August 25th, 2007 2:29 pm

    hi
    very nic tut man
    can u explain how to make guns and all
    like a movieclip gun which has a bullet movieclip or something. PLS.
    with limited ammunation and special effects while shooting like black smoke or sparks or somethin like that.

  53. SHIV on August 25th, 2007 3:10 pm

    hi emanuele,
    pls explain how to create a game like mortal kombat in which 2 guys fight (player 1 and player 2) using diff powers. And some powers can only b used when there is a graph full or something.
    ALSO
    explain how to make a graph which indicates score or life instead of dynamic textboxes.

  54. don on August 26th, 2007 8:32 pm

    i dont get it at all

  55. John on August 29th, 2007 6:16 pm

    Hi! I am making a game for commercial purposes, and I was wondering if these action scripts for the flash draw game are copyrighted, or are they free to use for my game. If I could use them, I would be happy to site this website in the game, if you want. thanks!

  56. Emanuele Feronato on August 29th, 2007 6:29 pm

    Feel free to use the script as you want, thank you for giving me a credit, once completed send me the game and I’ll publish on my site.

  57. dfahasdfh on September 1st, 2007 12:30 am

    i’ve been waiting for part 6 for almost half a year, do you know when it will be done? thanks

  58. Maggot on September 19th, 2007 10:27 pm

    Thank’s
    I’m just starting with flash and i really have to admit that you’re tutorials are the clearest and most explained i could find on the net.

  59. Jeffrey on October 28th, 2007 1:54 am

    I DOWNLOADED YOUR “FULL SOURCE CODES” AND THEY CRASHED FLASH!!!!!

  60. olli on November 14th, 2007 11:16 pm

    ok….why the hell when i click download all sources i get all the pictures ive ever seen on the internet,all my friends bebo/myspace pics,i have got MILLIONS i want a fucking good explanation cuz i am pissed off.i want to know how u got all of my m8s pics aswell onto my laptop.REPLY.

  61. Emanuele Feronato on November 14th, 2007 11:22 pm

    I think it’s something on your computer.

  62. Shadow Scythe on November 28th, 2007 12:46 am

    I’ve been making a platformer where I can just draw a terrain with the paintbrush tool and my character (currently a square) will be able to walk and climb around on it. Hopeuffly, these tutorials might help me program working slopes. Right now they work… sort of. I’ll try to get some better guidance from your codes. Which are totally awesome, by the way.

  63. Cory on November 29th, 2007 1:15 am

    Very nice man. Except one thing….. if you don’t jump but instead WALK off the platform, you can still jump… midair. Very well explained… thx.

  64. Riccardo on December 31st, 2007 4:07 pm

    hey cory, that’s not hard to solve.
    in my game i’ve added a “collision” boolean.
    whenever gravity is applied, collision goes false, when it’s not it goes true.

    so if you go off a platform, the boolean will go false, and you won’t be able to jump, since in my game the jumping code is like this:

    if (Key.isDown(Key.SPACE)&& collision==true)

  65. Cory on January 3rd, 2008 9:57 pm

    I was just saying… besides, there’s a FAR easier way.

    onClipEvent(enterFrame){
    if(yspeed>0.1 or yspeed<-0.1){
    jumping2=1;
    }else{
    jumping2=0;
    }
    if(Key.isDown(Key.SPACE) and jumping2==0){
    yspeed=-4;
    }
    }

    Emanuele, you should add that to the tutorial. Also, you should change the gravity to make it larger and the jump speed to make it like -6, so that it remains the same jump height, but it makes it so that the player gets less jump time, making it look more realistic.

  66. Cory on January 3rd, 2008 10:06 pm

    Art Said: Very cool tutorial,
    what dose this code mean though? :

    while () {}

    thanks in advance :)

    that command is like the *for* instance, but instead of manipulating a variable, it just does it until the condition isn’t correct anymore.

    For example, in this it says:

    while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
    _y–;
    yspeed = 0;
    }

    think of it like this. UNTIL that condition ISN’T right, do the action. Hope that helps.

  67. Stu on February 3rd, 2008 6:30 pm

    could you make it so if the man is on the slope, he then is leaning as if he was on the slope.

    if that makes sence…

  68. David on February 5th, 2008 6:08 pm

    Hey! I really like you’r tutorials, but I tried to add

    this.gotoAndStop(2);

    as in

    if(Key.isDown(Key.RIGHT)){
    this.gotoAndStop(2);

    But that didn’t really work… Could you help me a bit? I want a animation that is on frame 2 of the “guy” movieclip to start when you hit the key right. Also you should make a key setup “tutorial” so that you can use w a s d etc.

  69. ises on February 5th, 2008 7:05 pm

    great tutorial !!! thank u so much, it’s really help me.

  70. EagleVision on February 16th, 2008 7:53 pm

    When are you going to make more tutes?

    Are you going to continue this? Reply please! :D

  71. quick on February 19th, 2008 5:13 pm

    I want to see that too.

  72. Grayson on February 29th, 2008 4:12 am

    make it a button then put for the script
    on(rollover){gotoAndPlay(*)}

    * = the number of the frame you want to goto
    but you will have to edit this so that when the block rolls over it goes to the next frame
    cause the script there will make it so when the mouse rolls over it goes to the next frame adn we dont want that sry if this didnt help much cause i am still editing the code so that the blob is what needs to go ovewr it

  73. philman(nameguy on March 21st, 2008 11:08 pm

    I deleted the CreateEmptyMovieclip and made a movieclip with the terrain name & stuff, but when I draw, it draws really far away to the bottom right of the mouse. HELP PLZ???!!?!?!!!!!?!?!?!?!

  74. AirData on March 27th, 2008 8:29 pm

    Like a few others here, I’d like to know how to make the “hero” rotate naturally as it moves up hills and down hills. Like if the box was a car the “hero” would rotate.

  75. bram on April 2nd, 2008 8:23 pm

    Hi, first of all, thanks for this amazing tutorial :D

    But I have one question,
    I made a terrain which is bigger than the window, and I want prevent the character walks out of the window. I want the terrain also to move when the character is almost out of the window.

    I dont know if my question is clear because my English is pretty bad :s
    But maybe an example will help, everyone knows the supermario game I suppose…
    Well, in supermario the terrain also moves, supermario is always centerred in the window.

    I hope someone can help me :)
    –bram–

  76. Flashycool on April 15th, 2008 11:16 pm

    Bram,
    All you need to do is

    onClipEvent (enterFrame) {
    if (_root.go) {
    if (Key.isDown(Key.LEFT)) {
    if (!_root.terrain.hitTest(_x-_width/2, _y+_height/4, true)) {
    _x -= xspeed;
    //this is where you change
    _root._x += xspeed;
    }
    }

    when will the next tut be out?!

  77. Ryan on April 20th, 2008 7:57 pm

    Great tutorial - my only problem is that the ball won’t stop bouncing. Does anyone have the code to stop the ball from bouncing like in real life? Many thanks if anyone is talented enough to help. :)

  78. Muhammad on April 29th, 2008 11:16 pm

    is there any way top print all tutorials form 1 to 5 because its hard to read all of them and do some reasearch along like if i want know what are parameters of sin in flash i am not opening flash again agian Right plus if i have papers i will be able to read anywhere and anyway so plsz reply also reply on email
    My Web fire08.110mb.com

  79. sem on May 4th, 2008 12:26 am

    i hope this works

  80. rick on May 13th, 2008 3:25 am

    hi,my name is rick roberts & i am intersested in learing how to create my own video game one day & i would like to say that this is the best tutorial i have seen in a long time & i have seen alot of them i am a rookie when it comes to creating but i do understand what to do.i would like to ask if you can, can you please try to explain to me more of how to work this because i understood alot of whet you put on the tutrial but some it it just didnt make sense or it cold be because i have only been doing this stuff for like two months lol.well anyway if you can please try to help me out i would apprciate it alot thank you rick!!!

  81. Muhammad on May 15th, 2008 11:26 pm

    Nice I This Part Was Easy IF Compare To previous parts hey explain previous parts more

  82. beau on May 22nd, 2008 10:00 am

    hey do you hav a code to change the lines color?i cant find 1….

  83. Alec on June 1st, 2008 12:29 am

    im a different alec

    how do you make the exit goto the next frame?

  84. Tiago on July 10th, 2008 4:17 pm

    is there any chances to do this tutorial for a “online players” like.. http://www.ff0000.com/ ?

  85. jonathan sario on July 15th, 2008 7:52 am

    Hi.

    I’d like to say that I really like this tutorial and that it would help me make my own side scrolling computer game in flash.

    Unlike most platformer tutorials that only handle flat platforms, this one can be made to handle not just slopes but also oddly shaped platforms.

    I used to use “if” statements for hittests but now I know “while” statements work better.

    Thanks.

  86. paul on July 17th, 2008 8:18 pm

    Hi,
    I love this tutorial and its a great tool to know how to “draw” on the screen.

    My question is, how do you save it now?
    you mentioned in part 1 that you would tell us in part 2 how to save, but I never saw it.

    Can anyone tell me how to save the drawing?
    i am familiar with php/xml and the likes, but code and function wise i wouldnt know where to start

    thx in advance

  87. al on August 23rd, 2008 1:48 am

    ummm… what are we posting these actionscript codes on.

  88. erick on September 2nd, 2008 7:36 pm

    no entendi ,si se hablar ingles, very well i need to say but, no se que es eso de actionscript el codigo donde lo pego o que hago con ese codigo lo pego en los fremas de macromedia flash o que? que hago!

  89. Xodus on September 3rd, 2008 7:23 am

    erick’s translation (with Google Translator)

    not understanding, if we speak English, very well but i need to say, not what do you mean, actionscript code where you hit or what I do with this code hit in the Fremen of Macromedia’s Flash or what? I do!

  90. enrique carrillo on September 12th, 2008 5:31 am

    i wil like to make a game please

  91. bgfdtbhs on September 21st, 2008 7:58 pm

    I made a game with this code, it works fine. However, I want to add a zoom, a scroll, and a change line color function (I could probably figure that one out). To give whoever responds to this an idea, I have no preset lines. I have a draggable exit, a car for the player (who can’t move himself) and a large blank background.

Leave a Reply




Trackbacks

  1. Create a flash draw game like Line Rider or others - part 1 at Emanuele Feronato on March 31st, 2007 12:13 am

    [...] March 31st update: part 5 released March 4th update: part 4 released February 17th update: part 3 released February 3rd update: part 2 released [...]

  2. Create a flash draw game like Line Rider or others - part 2 at Emanuele Feronato on March 31st, 2007 12:14 am

    [...] March 31st update: part 5 released March 4th update: part 4 released February 17th update: part 3 released [...]

  3. Create a flash draw game like Line Rider or others - part 3 at Emanuele Feronato on March 31st, 2007 12:14 am

    [...] March 31st update: part 5 released March 4th update: part 4 released [...]

  4. Create a flash draw game like Line Rider or others - part 4 at Emanuele Feronato on March 31st, 2007 12:15 am

    [...] March 31st update: part 5 released [...]

  5. Create a flash artillery game - step 2 at Emanuele Feronato on May 25th, 2007 5:30 pm

    [...] Line 57: Init enemy yspeed at zero. It’s obvious that I won’t move the enemy with a motion guide but with pure actionscript, just in case tomorrow I would like to change the terrain. I am using some of the basics explained in the tutorial called Create a flash draw game like Line Rider or others - part 5 so give it a look if you haven’t done it yet. [...]