# Yep, more hitTest/shapeFlag problems

**URL:** <https://forum.kirupa.com/t/yep-more-hittest-shapeflag-problems/273140>\
**Category:** Uncategorized\
**Created:** [October 11, 2008, 11:59pm UTC](https://forum.kirupa.com/t/yep-more-hittest-shapeflag-problems/273140 "2008-10-11T23:59:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NuclearDuckie](https://avatars.discourse-cdn.com/v4/letter/n/43a26b/32.png) [@NuclearDuckie](https://forum.kirupa.com/u/NuclearDuckie)\
**Post date:** [October 11, 2008, 11:59pm UTC](https://forum.kirupa.com/t/yep-more-hittest-shapeflag-problems/273140/1 "2008-10-11T23:59:04Z")

</div>

Hi.  
I know there are already a lot of these kinds of threads, but I _did_ conduct a search before writing this, though I probably missed something. I’m posting this here anyway, so that I can have this problem in particular addressed, so I hope you don’t mind.

So…

I’m trying to create a Flash game engine with a wall that the character bounces off, that has so far come out like [this.](http://www.zshare.net/flash/2035290230851eae/)

Or, in image form, this:

![](http://forum.kirupa.com/uploads/kirupa/4991/c73f045427d0eb44.jpg)

The script on the ball is:

```auto
onClipEvent(load){
    speed = 1.75
    xspeed = 0
    yspeed = 0
    slow = .875
}
onClipEvent(enterFrame){
    if(Key.isDown(Key.LEFT)){
        xspeed -= speed
    }
    if(Key.isDown(Key.RIGHT)){
        xspeed += speed
    }
    if(Key.isDown(Key.UP)){
        yspeed -= speed
    }
    if(Key.isDown(Key.DOWN)){
        yspeed += speed
    }
    if(_root.sidewalls.hitTest(_x, _y, true)){
        xspeed *= -1
    }
    if(_root.updownwalls.hitTest(_x, _y, true)){
        yspeed *= -1
    }
    xspeed *= slow
    yspeed *= slow
    _x += xspeed
    _y += yspeed
}

```

And the wall instances were these:

![](http://forum.kirupa.com/uploads/kirupa/4992/4802f3ab9252db6d.jpg)  
 ![](http://forum.kirupa.com/uploads/kirupa/4993/3663558c6f0c618a.jpg)

First of all, because I’m using a shapeFlag function instead of a hitTest, because I intend to create games with sloping landscapes, the ball sinks halfway through the wall before hitting it, and I don’t know how to create more collision points in the wall.

My main problem however, is that, as you may have noticed, you can sometimes sink further than halfway through the wall, and eventually get onto the other side of it. If I could get it to keep testing the collision wherever the ball was touching the wall, I could make the wall into a kind of one-way thing, where it forces you back into the square, except I don’t know how to do that, either.

So could you help me? Or if you think that this question has already been asked, could you post a link to that thread?

Thanks. :}
