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?
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;
}