We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Moving images->low framerate
Page Index Toggle Pages: 1
Moving images->low framerate (Read 529 times)
Moving images->low framerate
Apr 18th, 2009, 8:41pm
 
another day another problem i cant seem to get my head around...  Wink

in my code i keep two images constantly in motion, when one disappears from the upper screen it's supposed to respawn at the bottom and go up again, while this does work the framerate drops whenever the top image is leaving the viewarea. first round doesnt seem to have the problem.

Code:

 richtung += (dr[1].speed*dr[1].direction);
 richtung1 += (dr[1].speed*dr[1].direction);  
//both start at different positions
 image(c ,0, richtung);
 image(c ,0, richtung1);  
 
 if(richtung <= (-700))   {
   richtung = 700;
 }
 if(richtung1 <= (-700))   {
   richtung1 = 700;
 }


does anyone know about this problem and how to get rid of it?

thanks  Smiley
Re: Moving images->low framerate
Reply #1 - Apr 18th, 2009, 8:50pm
 
could you post your declarations of dr[1].speed and dr[1].direction?
as the problem seems to happen when numbers go negative it could have something to do with the way it interprets this data.

did you check if the problem is actually with the frame rate? isn't there any chance the acceleration could be decreasing once numbers go negative making the images go slower while maintaining the same frame rate?

if dr[1].speed*dr[1].direction is not constant, by applying this to both images at the same time could influence the way in which they behave; for example; if the speed when the image if on the bottom of the screen is smaller than the speed on the top and the values are reset once one image gets to the bottom you would have problems.

i actually don't understand how the frame rate could decrease in this situation. sorry if this didn't help at all, but i am actually just guessing here...
Re: Moving images->low framerate
Reply #2 - Apr 19th, 2009, 5:01am
 
ok, the speed changes in floating numbers and images dont seem to like to be handled with floats. when i use int numbers it works just fine Sad too bad...

oh well, thank you for pointing me in the right direction  Smiley
Re: Moving images->low framerate
Reply #3 - Apr 19th, 2009, 12:21pm
 
hey
you're welcome. i am glad that helped.
check again the way you are manipulating the float numbers, because this could be a simple problem.
Page Index Toggle Pages: 1