Author & File Information


Submitted: 03/08/2009 | 01:44PM EST

File Info: Game | 330.8 KB | Add Game to Favorites

Genre: Tutorial

Current Score: 3.60 / 5.00

285 votes | 1,285 views

Click an icon to vote on this!

You are not logged in.


Related Submissions

Submissions by Kwing: View all 73 of this author's submissions

Users who liked this also enjoyed:


Author Comments

The movie you're about to see is the finished product. You can create this by making a Movie Clip ball and separate Movie Clips for walls and ground (with respective instance names). Put this script on the ball, and read the // for explanations.

onClipEvent(load){//Apply the following script once (hence 'load')
_root.grav=0;//Recognize the instance 'grav' as a rational number
_root.xmove=0;//Recognize the instance 'xmove' as a rational number
}//Terminate the handler
onClipEvent(enterFrame){/
/Apply this script constantly
this._y+=_root.grav;//Mak e the ball fall at 'grav'
_root.grav+=1;//Make 'grav' increment by 1; you can change the number
this._x+=_root.xmove;//Ma ke the ball move forward at 'xmove'
if(_root.ground.hitTest(_
x,_y,true)){//If this hits the ground do the following
_root.grav*=-1;//Multiply 'grav' by -1, which will make the ball bounce
}//Terminate the if statement
//OPTIONAL SCRIPT!! The following script is optional. Add a Movie Clip with the instance name 'restart' if you want it to do something.
if(_root.restart.hitTest(
_x,_y,true)){//If this hits the restart barrier
this._x=265;//Set the ball's X to 265
this._y=190;//Set the ball's Y to 190
_root.grav=0;//Sets 'grav' to 0
_root.xmove=0;//Sets 'xmove' to 0
}//Terminate the if statement
//WARNING! The optional script stops here! Everything below is essential!
if(_root.walls.hitTest(_x ,_y,true)){//If the ball hits the walls
_root.xmove*=-1;//Multipl y 'xmove' by -1 which will make the ball bounce sideways
}//Terminate the if statement
if(Key.isDown(Key.LEFT)){
//If the left key is pressed
_root.xmove-=1;//Decrease 'xmove' by 1, which will eventually result in 'negative-positive' movement, making the ball move left
}//Terminate the if statement
if(Key.isDown(Key.RIGHT))
{//If the right key is pressed
_root.xmove+=1;//Incremen t 'xmove' by 1, which will result in an eventual rightwards movement
}//Terminate the if statement
if(!Key.isDown(Key.RIGHT)
&&!Key.isDown(Key.LEFT)&&
_root.xmove>0){//If right nor left are pressed and 'xmove' is a positive number do the following
_root.xmove-=1;//Decrease xmove by 1, which will bring the ball to a horizontal standstill
}//Terminate the if statement
if(!Key.isDown(Key.RIGHT)
&&!Key.isDown(Key.LEFT)&&
_root.xmove<0){//If right nor left are pressed and 'xmove' is negative
_root.xmove+=1;//Increase xmove by 1, which will bring the ball to a horizontal standstill
}//Terminate the if statement
if(_root.xmove>15){//If 'xmove' is greater than 15
_root.xmove=15;//Set the speed back to 15, which caps the speed
}//Terminate the if statement
if(_root.xmove<-15){//If 'xmove' is less than -15
_root.xmove=-15;//Set the speed up to -15, which caps the speed
}//Terminate the if statement
}//Terminate the handler

6 reviews | Log in to write a review | Share this!

The people have spoken

Average Score: 7.0 / 10

Score: 3
Lifes-a-Bitch

"Incredibly flawed"

date: October 19, 2009

For something as simple as this, your script is far too long and unneccessary (sp?).
This could easily be written 1/2 or 1/4 of what you have there. Also, the script could easily be cleaned up by having alot of the script on the walls and using tellTarget(_root.ball){ to change the variables. also, you could of threw in some nice easy trig in there to make the angles more fluent. Also, why is it that with the Gravity modifier at 1 the ball continues to rise? You need to re-read your script and fix it... And possibly slice and dice it.

Rate this review:
Helpful!
Useless.
Flag as abusive.
No users have weighed in on this review.

Score: 9
erickthesonicfan

"It looks pretty nice."

date: September 9, 2009

I was wondering, if you could make a rolling physics tutorial (like a ball rollwing down a slope) if you did so, i would be so thankful :)

Rate this review:
Helpful!
Useless.
Flag as abusive.
No users have weighed in on this review.

Score: 10
swarm420

"Good tutorial"

date: March 8, 2009

Good tutorial, now is the code you posted pure code or is it with some info on what does what?

Also, HOW DID YOU MANAGE TO WRITE ALL THAT CODE?!?!

I fall asleep after ten liens of animation code... So, just wondering... >_> <_<

March 25, 2009

Author's Response:

The // cancels any following script, so it has a description but also can be copy/pasted. Yeah, I wrote all the code. Only about half of it is original, though, because some of the functions are just left/right duplicates.

Rate this review:
Helpful!
Useless.
Flag as abusive.
People aren't in agreement over whether this is helpful or not.

Score: 10
PlasticFisherMen

"Very helpful!"

date: March 8, 2009

Very helpful tutorial , that helped me out a lot , keep up the excellent work!

March 8, 2009

Author's Response:

:D Thanks!

Rate this review:
Helpful!
Useless.
Flag as abusive.
People find this review helpful!

Score: 3
KaosKilla9231

"Ummm..."

date: March 8, 2009

Not Really Too Fun Or Imaginative..Only Cause I've Seen These All Over The Net.

The Ball Ocasionally Dissapers And Sometimes Stops In General...

March 8, 2009

Author's Response:

I know there are glitches; it's an engine, nothing more.

Rate this review:
Helpful!
Useless.
Flag as abusive.
People think this is a useless review.