# Character won't bounce off walls

**URL:** https://forum.kirupa.com/t/character-wont-bounce-off-walls/304627
**Category:** Uncategorized
**Created:** [February 10, 2010, 11:15pm UTC](https://forum.kirupa.com/t/character-wont-bounce-off-walls/304627 "2010-02-10T23:15:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![smeared](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@smeared](https://forum.kirupa.com/u/smeared)
#### Post date: [February 10, 2010, 11:15pm UTC](https://forum.kirupa.com/t/character-wont-bounce-off-walls/304627/1 "2010-02-10T23:15:52Z")

</div>

I can only get my character to bounce off of walls above him, and to the left of him! when going right or down, he just goes right through… I tried a lot of combinations. Little push in the right direction please?

```auto

private function loop(e:Event) : void {
		
			
			//if (goingLeft) this.animGus.gotoAndPlay(51);
			//if (goingRight) this.animGus.gotoAndPlay(52);
			//this.animGus.gotoAndPlay(52);
			//trace(i **** );
			
			
			//Direction
			
			
			
			//Key commands
			
			if (key.isDown(Keyboard.LEFT)) {
				if (!goingLeft) this.animGus.gotoAndPlay(26);
				goingLeft = true;
				goingRight = false;
				vx -= xSpeed;
				
			} else if (key.isDown(Keyboard.RIGHT)) {
				if (!goingRight) this.animGus.gotoAndPlay(1);
				goingRight = true;
				goingLeft = false;
				vx += xSpeed;

			} else {
				if (goingRight) this.animGus.gotoAndStop(52);
				if (goingLeft) this.animGus.gotoAndStop(51);
				goingLeft = false;
				goingRight = false;
				vx *= friction;
				
			}
			
			if (key.isDown(Keyboard.UP)) {
				
				vy -= ySpeed;
			
			} else if (key.isDown(Keyboard.DOWN)) {
			
				vy += ySpeed;
			
			} else {
			
				vy *= friction;
			
			}
			
			
			/*if(vx > 0 && i **** ) {
				vx *= -1;
			} else if (vx < 0 && i **** ) {
				vx *= 1;
			}
			
			if(vy >0 && i **** ) {
				vy *= 1;
			} else if (vy >0 && i **** ) {
				vy *= -1;
			}*/
			
			if(i **** ) {
				if (vx > 0) {
					vx *= 1;
				} else if (vx < 0) {
					vx *= -1;
				}
				if (vy > 0) {
					vy *= 1
				}else if(vy < 0) {
					vy *= -1;
				}
				
			}
			trace("vx = "+vx);
			trace("vy = "+vy);
			
			this.x += vx;
			this.y += vy;
			}

```
