ActionScript Project
Project Home
About Project


Programming Projects
Game Projects
Web Programming Projects
Robotic Projects
D2D Map Editor

Other Projects

 

Instruction

Basketball It's the main character on the stage. It moves, it bounces, it rotates, it collides with objects, and it reacts to the gravity. You can drag the ball and throw it using the mouse as hard as you can. Try throwing it into the basket.
Basket You can adjust the height of the basket along the left side of the stage.
Magnet Blocks There are two magnet blocks on the left side of the stage. You can drag and place them anywhere on the stage. These magnet blocks are static and they don't move. Try to throw a ball across a magnet, and you will see the ball sticks to it. It only happens on top of the magnets. To make the shooting more challenging, place some magnet blocks near the basket.
Gravity The gravity will pull the ball but not the magnet blocks. You can change the gravity in the range from 0 to 3. Where 1 means 100% of the earth's gravity.

Basic Physics

To make the ball bounces and reacts realisticly, we need to have some basic knowledge of physics to program this interactive dynamic system with ActionScript. I used the Newton's laws for physics. In order to have the ball fall, we need to have the gravity force to pull the ball downward. The force needed to lift the ball up is depends on how hard the user throw it. When you apply a force to the ball the velocity will be created upon the ball, it will move upward and decelerate by the gravity, and when the force is finally cancelled out completely by the gravity force, the ball started to accelerate down back to the earth. So, that's all we need to have the ball move in the y-axis. The ball doesn't move by itself in the x-axis. You can throw it in the x direction. For this simple project, there is no air resistence in the air. So, the ball will not slow down before it hits the ground. We need to have a force to slow down and stop the ball when it reaches the ground. This force is called the friction. What friction does is simply deccelerate the ball in the opposite direction of where the ball moves in the x-axis. When the ball's x velocity is zero, it is completely at halt.

Now we have all the forces to move the ball. The next thing we need to consider is the collision detections. There are not much collision to detect in this project, the only collisions occur are between the ball and walls, and the ball and the blocks.

Original Idea

My original idea for this project is that user can draw on the stage and then by putting the ball on the lines that you drew, the ball will bounce or roll along the lines according to how much force you applied to it. However, I give up with this idea.

1