stop();
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
stage.addEventListener(Event.ENTER_FRAME, update);
//how to make the object move up / down at equal speed - see orange and banana
//How to make it rush out and up and slows down gradullay due to gravity - see strawberry and melon
//
var initialV :Number = 20;
var gravity :Number = 10;
var velocity :Number = initialV;
// v = vo - gt - v the speed at the moment, vo - initial speed, g gravity, t time passed
var t1:int = 0; //
var t2:int = 0;
var timepassed :int = 0;
//how to make it run in a bell shape? vx, vy, gravity, friction see Wmelon
var vy:Number = 10;
var friction:Number =1.8;
var vx:Number = -3;
function update (e:Event){
t2=getTimer();
timepassed = t2-t1;
t1= t2;
velocity = velocity - gravity*timepassed/1000;
//vx = vx - friction *timepassed/1000;
//trace (velocity);
vy = vy-gravity*timepassed/400;
moveTheOrange();
moveTheBanana();
moveTheStrawberry(velocity);
moveTheWatermelon(vy);
//moveTheApple(vy);
}
//var Wmovingup :Boolean= true;
function moveTheWatermelon(v:Number){
if(a1.y>=350 ){
vy = 20;
vx=-3;
if(a1.x <=50){a1.x = 500;}
if(w1.x <=100){w1.x = 550;}
}
a1.y -= v;
//trace(vy);
a1.x += vx;
w1.y -= v;
w1.x += vx;
}
var Smovingup :Boolean = true;
s1.y = 350;
function moveTheStrawberry(vy:Number){
if(s1.y>=400 ){
Smovingup = true;
velocity = 20;
}
if(s1.y <=0 ){
Smovingup=false;
}
if(Smovingup == true){
s1.y -= vy;
}else{
s1.y += vy;
}
}
var Omovingup :Boolean = true;
function moveTheOrange(){
if(o1.y>=300 ){
Omovingup = true;
}
if(o1.y <=0 ){
Omovingup=false;
}
if(Omovingup == true){
o1.y -= 5;
}else{
o1.y += 5;
}
}
b1.y = 500;
var Bmovingup :Boolean = true;
function moveTheBanana(){
if(b1.y>=400 ){
Bmovingup = true;
}
if(b1.y <=0 ){
Bmovingup=false;
}
if(Bmovingup == true){
b1.y -= 5;
}else{
b1.y += 5;
}
}
|