Code Help


dpoarch

Member
Joined
Dec 26, 2004
Messages
196
Age
37
Location
california
Website
Visit site
graph = ((graph - 94)+1) % 11 +94;

is the line of code I am using to desplay an animation. If I am right this means that it will desplay files 94-105. for some reason the first loop through displays 90, 92, and then 94-105. After the first loop it continues to display 94-105 it only display the first 2 the first time through. Is my thinking of this line incorrect or am i doing something else wrong?
 
What is the initial value of "graph" ? 93 should be good if you change the code a little bit :

graph = ((graph - 94) % 12 +94;

12 and not 11 (from 94 to 105, there is 12 frames)

first value = ((93-94)+1) % 12 +94 = 94
second : ((94-94)+1)%12+94 = 95
...
last : ((105-94)+1)%12+94=94

let's simplify x-94+1 == x-93:

graph = (graph - 93) % 12 +94;

but I prefer :

if (++graph>105) graph=94;

or

graph = graph==105?94:graph+1;

is it possible in fenix ?
 
rtb7 posted on Sep 21 2005 at 08:35 AM said:
What is the initial value of "graph" ? 93 should be good if you change the code a little bit :

graph = ((graph - 94)+1) % 12 +94;

12 and not 11 (from 94 to 105, there is 12 frames)

first value = ((93-94)+1) % 12 +94 = 94
second : ((94-94)+1)%12+94 = 95
...
last : ((105-94)+1)%12+94=94

let's simplify x-94+1 == x-93:

graph = (graph - 93) % 12 +94;

but I prefer :

if (++graph>105) graph=94;

or

graph = graph==105?94:graph+1;

is it possible in fenix ?
btw, as you're simplifying ot to -93, you can at once simplify it to -9, because 84%12 =0 ;)
and indeed, if(++graph>105)graph=94;end; is probably better :)
 
Last edited by a moderator:
Not much too say for me, but would have done it this way:

if(graph<94 or graph==105)graph=94;end;
if(graph<105)graph++;end;

One more line but it should do the same thing.
 
Back
Top