Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Baron on Sun 02/01/2011 04:26:22

Title: SOLVED -Parabolic Movement
Post by: Baron on Sun 02/01/2011 04:26:22
Greetings tech savvy Forumites,

    I'm trying to script parabolic movement.  It seemed simple enough in my head, and I've come up with a forumula that suits my purposes on paper, but I just can't seem to get AGS to give me the two thumbs up.  The basis of my code:


while (cPrincess.x < 650){
   cPrincess.x ++;
   princessy = (0.004 * cPrincess.x * cPrincess.x) - (2.56 * cPrincess.x) + 650; //****
   cPrincess.y = FloatToInt (princessy, eRoundNearest);
   Wait (1);
 }


  In theory the princess moves one pixel to the right every game loop, and her y coordinates are calculated by the standard y= ax2 + bx + c formula.  Princessy is a float, since usually the formula won't return an integer.  I then attempt to  take that float and update the princess's y coordinate, and update the screen with Wait.  The problem is AGS throws me an error saying Cannot convert float to int for the asterisked line.  I've tried creating float variables for all of the contents (princess.x, a, b, c) but it still thinks there's an int involved somewhere and I'm just not getting what it's asking for.  Am I messing up my syntax or misunderstanding how the float data type works?  Any help would be appreciated.
Title: Re: Parabolic Movement
Post by: DoorKnobHandle on Sun 02/01/2011 04:39:10
Hope I'm not misunderstanding at almost 6 in the morning but try changing the "+ 650;" into "+ 650.0;" and surround each one of the three "cPrincess.x" with "IntToFloat ( cPringcess.x )" and it should solve that compile error.
Title: Re: Parabolic Movement
Post by: Baron on Sun 02/01/2011 23:51:45
Awesome -thanks.