Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package{
- import flash.events.*;
- import flash.display.*;
- import flash.utils.*;
- public class physicsTest extends MovieClip{
- public var listPosY:Array=new Array(6);
- public var timer:Timer =new Timer(10);
- public function physicsTest(){
- listPosY[0]=0;
- listPosY[1]=50;
- listPosY[2]=100;
- listPosY[3]=150;
- listPosY[4]=200;
- listPosY[5]=250;
- timer.addEventListener(TimerEvent.TIMER, updateFxn);
- }
- /*update, lol*/
- public function updateFxn(event:Event):void
- {
- listPosY=listPosY.map(wrap(addVerticalVelocity(g(1))));
- trace(listPosY);
- }
- /*wrap function taken from that site you showed me so I could avoid errors.*/
- public function wrap(f:Function):Function
- {
- return(
- function( x : *, index : int, array : Array ) : *
- {
- return f( x )
- }
- )//end return
- }
- /*addVertical velocity should be adding the velocity of the current moment to the base position in yPosArray*/
- public function addVerticalVelocity(value:Number):Function
- {
- return(
- function(y:int, index:int, array:Array):Number{
- return (y+value);
- }
- )//end return
- }
- /*this function should apply g to the velocity, with the argument used (1, in this instance) and adding gravity to it*/
- public function g(value:Number):Function
- {
- return(
- function(y:int, index:int, array:Array):Number
- {
- return(value+.098);
- }
- )//end return
- }
- }
- }
Add Comment
Please, Sign In to add comment