Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 03:58
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  Physics headache!
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Physics headache!  (Read 1365 times)
Nik
Server what's that
*
Posts: 40


View Profile Email
« on: 11/02/05, 07:27 »

Hi,

I have a script here and I can't get the vertical travel to work the way I want it to.

I want the _y movement to be more natural so the ball arcs up and then down.

At the moment I have the ball drop out of the 'air' when it's horizontal movement has
stopped.

Here's my code:

fire = function(){
var xmov:Number = thrust;
var ymov:Number = 0;
var gravity:Number=2;
var u:Number=.95;
var accel:Number=u*gravity;
var decay:Number=0.2;
this.onEnterFrame=function(){
   //move us forward and up and trace distance
   if(Math.abs(xmov)>=Math.abs(accel)){
      if(xmov>0){
         xmov -=accel;
         ymov -=0.003;
         //trace(xmov);
         _root.distance += 1;
         _root.btn_reStart._visible = false;
      }else if(xmov<0){
            xmov+=accel;
            
         }
      }else{
         //we have stopped
         xmov=0;
         //check for the floor and bounce off it.
         if(ball._y >50){
      ball._y = 50;
      ymov *= -1*decay;
      _root.btn_reStart._visible = true;
   }

      }
      //move the background
      _root.land._x+=xmov;
      ball._y += ymov;
      //if we have stopped moving forward drop.
      if(xmov >0){
      
      ball._y+=ymov;
      }else{
         ymov+=gravity;
         ball._y+=ymov;
      }
}
};

Any help would be fantastic thanks!

Nik
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 11/03/05, 05:51 »

Oh, phisycs and Math ... there are tons of resources around the web, is just the rigth way of use algorithms. Some long thread with formulas and links: http://www.flashkit.com/board/archive/index.php/t-281136.html

Jorge
Logged

Nik
Server what's that
*
Posts: 40


View Profile Email
« Reply #2 on: 11/04/05, 11:20 »

Thanks for the response, I got some reading in and I'm now
officially sick of bouncing, throwing and colliding balls!!

I have different ideas on what I want to do with the physics
but I appreciated your reply.

Thank you!

Nik (off learning trig now...)
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything