# Walls not blocking movement well

**URL:** https://forum.kirupa.com/t/walls-not-blocking-movement-well/328892
**Category:** flash
**Created:** [June 28, 2012, 9:56pm UTC](https://forum.kirupa.com/t/walls-not-blocking-movement-well/328892 "2012-06-28T21:56:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ragnoroct](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@Ragnoroct](https://forum.kirupa.com/u/Ragnoroct)
#### Post date: [June 28, 2012, 9:56pm UTC](https://forum.kirupa.com/t/walls-not-blocking-movement-well/328892/1 "2012-06-28T21:56:18Z")

</div>

What’s wrong with this code?  
It glitches when I try different sides.  
when I move “this.” I’m moving the map so the character looks like he is moving.

```auto
for (var i:int=0; i<fixedObjects.length; i++)
            {
                //verticle
                if ((char.rightside > fixedObjects*.leftside) && (char.leftside < fixedObjects*.rightside))
                {

                    if ((char.bottomside > fixedObjects*.topside) && (char.topside < fixedObjects*.topside))
                    {
                        //top walls
                        trace("topblocked");
                        this.y = this.y + (char.bottomside - fixedObjects*.topside);
                        char.y = fixedObjects*.topside - charH;
                        downArrow = false;
                        break;
                    }
                    else
                    {
                        //bottom walls
                        if ((char.topside < fixedObjects*.bottomside) && (char.bottomside > fixedObjects*.bottomside))
                        {
                            trace("bottomblocked");
                            this.y = this.y - (fixedObjects*.bottomside - char.topside);
                            char.y = fixedObjects*.bottomside + charH;
                            upArrow = false;
                            break;
                        }
                        else
                        {

                            //horizontile walls checking
                            if ((char.bottomside > fixedObjects*.topside) && (char.topside < fixedObjects*.bottomside))
                            {
                                // left wall
                                if ((char.rightside > fixedObjects*.leftside) && (char.leftside < fixedObjects*.leftside))
                                {
                                    trace("leftblocked");
                                    this.x = this.x + (char.rightside - fixedObjects*.leftside);
                                    char.x = fixedObjects*.leftside - charW;
                                    rightArrow = false;
                                    break;
                                }
                                else
                                {
                                    trace("other");
                                    //right wall
                                    if ((char.leftside < fixedObjects*.rightside) && (char.rightside > fixedObjects*.rightside))
                                    {
                                        trace("rightblocked");
                                        this.x = this.y - (char.leftside - fixedObjects*.rightside);
                                        char.x = fixedObjects*.rightside;
                                        leftArrow = false;
                                        break;
                                    }
                                }
                            }

                        }

                    }

```
