• Advertisement
Sign in to follow this  

Trying to figure out gallons used in a car simulator

This topic is 3182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on a Car System Simulator for educational use in Tech. Ed. classes. My partner and I are using Adobe Director 11.5 and I'm using the Lingo scripting language to code all the functionality for the 'game.' I've run into a problem, though, regarding the interaction between the gas gauge and the variable that keeps track of how many gallons of gas have been used. I've got a few variables: gallonsUsed milesTraveled mpg Now, every time a gallon of gas is used I would like the needle on the gas gauge to rotate -12 degrees, I've got that part down. What I can't seem to figure out is how to get the simulator to detect when it passed the next "threshold" of the gallons, when a full gallon of gas has been used. The milesTraveled is a float with 4 decimal points due to our math (.5 real time = 1 minute game time) which is why I can't really use the mod operator (milesTraveled mod mpg)

Share this post


Link to post
Share on other sites
Advertisement

while(milesTraveled - (gallonsUsed * mpg) > mpg){
gallonsUsed++;
MoveGasGauge();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement