Hi,
I'm making a simple game in Flash using AS3. So far I've created a ball character which the player controls with the arrow keys, it has acceleration, friction and mavity.
What I want to do next is create a maze like level, so I'm trying to make it so when the player touches the wall / level it doesn't go through it and bounces off in the opposite direction.
I've managed to get a function working that detects the collisions:
This function runs on every frame using:
Player is the ball and level1_wall is the wall. It outputs "Collision" when the ball touches the wall so I know it's working.
Next I need a way to stop the ball going through the wall, and also a way to make it bounce off in the opposite direction that it hit.
So I'm stuck with that, can anyone offer any assistance?
P.S. I suck at programming in general.
I'm making a simple game in Flash using AS3. So far I've created a ball character which the player controls with the arrow keys, it has acceleration, friction and mavity.
What I want to do next is create a maze like level, so I'm trying to make it so when the player touches the wall / level it doesn't go through it and bounces off in the opposite direction.
I've managed to get a function working that detects the collisions:
Code:
private function wall_block(e:Event) : void
{
if (Player.hitTestObject(level1_wall))
{
trace("Collision");
}
} //end wall_block()
This function runs on every frame using:
Code:
addEventListener(Event.ENTER_FRAME, wall_block);
Player is the ball and level1_wall is the wall. It outputs "Collision" when the ball touches the wall so I know it's working.
Next I need a way to stop the ball going through the wall, and also a way to make it bounce off in the opposite direction that it hit.
So I'm stuck with that, can anyone offer any assistance?
