SOLVED -Parabolic Movement

Started by Baron, Sun 02/01/2011 04:26:22

Previous topic - Next topic

Baron

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:

Code: ags

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.

DoorKnobHandle

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.

Baron


SMF spam blocked by CleanTalk