# Platform irregular hittest

**URL:** <https://forum.kirupa.com/t/platform-irregular-hittest/286632>\
**Category:** Uncategorized\
**Created:** [April 17, 2009, 9:47pm UTC](https://forum.kirupa.com/t/platform-irregular-hittest/286632 "2009-04-17T21:47:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr\_Pancake](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mr\_Pancake](https://forum.kirupa.com/u/Mr_Pancake)\
**Post date:** [April 17, 2009, 9:47pm UTC](https://forum.kirupa.com/t/platform-irregular-hittest/286632/1 "2009-04-17T21:47:00Z")

</div>

Im making a platformer, the hittest for the floor needs to be moer advanced so i can add more graphics to the ground movieclip instead of making sepperate movieclips with sepperate instances.

i saw a piece of code somewhere that uses FOR loop. isn’t there a simpler code to make irregular hittest?

here’s my actionscript and file:

```auto
jump = 0;
grav = 1;
gravspeed = 1;
onEnterFrame = function () {
    //set gravity on
    if (_root.grav == 1) {
        gravspeed = gravspeed*1.2;
        _root.player._y += gravspeed;
    }
    //clear gravity if player hits ground  
    if (_root.player.hitTest(_root.g)) {
        gravspeed = 1;
        jumpheight = 1;
        jump = 0;
        grav = 0;
    } else {
        grav = 1;
    }
    //move right
    if (Key.isDown(Key.RIGHT)) {
        _root.g._x -= 5;
    }
    //move left 
    if (Key.isDown(Key.LEFT)) {
        _root.g._x += 5;
    }
    //set jump 
    if (Key.isDown(Key.SPACE)) {
        _root.jump = 1;
        _root.grav = 1;
    }
    //jump motion 
    if (_root.jump == 1) {
        _root.player._y -= 20;
        gravspeed = gravspeed*1.1;
        _root.player._y += gravspeed;
    }
    //set max gravity 
    if (gravspeed>=15) {
        gravspeed = 15;
    }
};

```

file: [http://www.glennhofman.nl/gammetsest.fla](http://www.glennhofman.nl/gammetsest.fla)

thanks in advance
