dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Plaatform game help with walls

  1. #1
    theSWEEN thesween's Avatar
    Join Date
    Nov 2005
    Location
    Hertfordshire, England
    Posts
    305

    Plaatform game help with walls

    Hello!! I don't know if anyone remembers the attached? Part of the platform game tutorials. At the moment the ball passes straight through the platforms. Anyone know how to modify it so the ball cannot pass through it?

    I'm trying to create slopes for a character to walk down and walk up.. and using this code walking down isn't too bad, but walking up won't work at all as the character just walks straight through the slope.

    Cheers
    Steve
    Attached Files Attached Files

  2. #2
    theSWEEN thesween's Avatar
    Join Date
    Nov 2005
    Location
    Hertfordshire, England
    Posts
    305
    The code is as follows:

    onClipEvent (load) {
    jumpping = true;
    }
    //Makes The character jump
    onClipEvent (enterFrame) {
    if (jumpping) {
    this._y -= jumpp;
    jumpp -= .5;
    if (jumpp<0) {
    falling = true;
    }
    if (jumpp<-15) {
    jumpp = -15;
    }
    }
    if (_root.platform.hitTest(this._x, this._y, true) && falling) {
    jumpp = 0.000000000000000000000000000000001;
    jumpping = true;
    falling = false;
    }


    if (Key.isDown(Key.RIGHT)) {
    //edit the number to make him walk faster
    this._x += 5;
    // Makes the Character move left.
    } else if (Key.isDown(Key.LEFT)) {
    //edit the number to make him walk faster
    this._x -= 5;
    }

    if (Key.isDown(Key.UP)) {
    JUMPing = true;
    }
    if (JUMPing) {
    this._y -= JUMP;
    //kind of like gravity the higher it is the lower it bounces.
    JUMP -= .5;
    if (JUMP<5) {
    //makes it smoothly come down after its reached the maximum bounce hight.
    if (JUMP<-10) {
    JUMP = -10;
    }
    }
    //Helps him land on the platform when he falls.
    if (_root.platform.hitTest(this._x, this._y, true)) {
    //Jumping Hight
    JUMP = 15;
    JUMPing = false
    //End jumping Code
    }

    if (Key.isDown(Key.UP)) {
    FALL = true;
    }
    if (FALL) {
    this._y -= FALL;
    //kind of like gravity the higher it is the lower it bounces.
    FALL -= .5;
    if (FALL<5) {
    //makes it smoothly come down after its reached the maximum bounce hight.
    if (FALL<-10) {
    FALL = -10;
    }
    }
    //Helps him land on the platform when he falls.
    if (_root.platform.hitTest(this._x, this._y, true)) {
    //Jumping Hight
    FALL = .00001;
    FALL = true
    //End jumping Code
    }
    }
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center