I'm trying to have the Transparency for 12 objects bob between 0 and 100, so they act like lights dimming and growing fuller. Each should have a sin wave pattern: growing stronger, growing weaker, growing stronger, etc.
For this example I've only picked the 10th object.
Everything except the last few lines acts as expected.
The code:
Code: ags
Example output:
note: dir, or stardir[counter], is direction - growing weaker or stronger by having 1 or -1 added to transparency.
load out: for 10, dir 1 trans 96 <--load values into array
b4 for 10, dir 1 trans 96 <--before doing calculations
a4 for 10, dir 1 trans 97 <--after doing calculations
98 97 ? <-- is the value of object 10's transparency (that we got the value out of) equal to value 10 of the array of transparency counters, after we made it equal to it? Nope - wtf?
load back in: for 10, dir 1 trans 97 <-- put damaged value back in object 10, etc.
so 10 is now trans 98 - matching 97?
trans 98
load out: for 10, dir 1 trans 98
b4 for 10, dir 1 trans 98
a4 for 10, dir 1 trans 99
100 99 ?
load back in: for 10, dir 1 trans 99
so 10 is now trans 100 - matching 99?
trans 100. <-- loop doesn't grow weaker
load out: for 10, dir 1 trans 100
b4 for 10, dir 1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
ad infinitum
The problem seem to be, 1 is added always to object[6+y].Transparency on the last 4 Display() lines, but I can't see how. For instance, it's object[10].Transparency=stars[y], not object[10].Transparency+=stars[y], so i don't see how it could have happened.
note: 6+y just means object indexes are 6 more than the counter, so the 10th object (which is actually object 11 out of 12 not using zero index), is object[16]. I included this pointless complexity because I obviously don't know what's the code's doing, and you might :/
?
For this example I've only picked the 10th object.
Everything except the last few lines acts as expected.
The code:
function room_RepExec()
...
transCtr++;
//every 5th loop, run this code
if (transCtr > 5) {
transCtr=0;
//load out temporarily
for (int z=0;z<12;z++) {
stars[z]=object[z+6].Transparency;
if (z==10) Display("load out: for %d, dir %d trans %d",z, stardir[z], stars[z]);
}
//do calculations
for (int x=0; x<12; x++) {
if (x==10) Display("b4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
if (stars[x]+stardir[x]<0) {
stars[x]=0;
stardir[x]=1;
}
if (stars[x]+stardir[x]>100) {
stars[x]=100;
stardir[x]=-1;
}
stars[x]+=stardir[x];
if (x==10) Display("a4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
}
//load back in
for (int y=0;y<12;y++) {
object[6+y].Transparency=stars[y];
if (y==10) Display("%d %d ?",object[6+y].Transparency, stars[y]);
if (y==10) Display("load back in: for %d, dir %d trans %d",y, stardir[y], stars[y]);
if (y==10) Display("so %d is now trans %d - matching %d?",y, object[6+y].Transparency, stars[y]);
}
Display("trans %d", os11.Transparency);
}
...
Example output:
note: dir, or stardir[counter], is direction - growing weaker or stronger by having 1 or -1 added to transparency.
load out: for 10, dir 1 trans 96 <--load values into array
b4 for 10, dir 1 trans 96 <--before doing calculations
a4 for 10, dir 1 trans 97 <--after doing calculations
98 97 ? <-- is the value of object 10's transparency (that we got the value out of) equal to value 10 of the array of transparency counters, after we made it equal to it? Nope - wtf?
load back in: for 10, dir 1 trans 97 <-- put damaged value back in object 10, etc.
so 10 is now trans 98 - matching 97?
trans 98
load out: for 10, dir 1 trans 98
b4 for 10, dir 1 trans 98
a4 for 10, dir 1 trans 99
100 99 ?
load back in: for 10, dir 1 trans 99
so 10 is now trans 100 - matching 99?
trans 100. <-- loop doesn't grow weaker
load out: for 10, dir 1 trans 100
b4 for 10, dir 1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100
ad infinitum
The problem seem to be, 1 is added always to object[6+y].Transparency on the last 4 Display() lines, but I can't see how. For instance, it's object[10].Transparency=stars[y], not object[10].Transparency+=stars[y], so i don't see how it could have happened.
note: 6+y just means object indexes are 6 more than the counter, so the 10th object (which is actually object 11 out of 12 not using zero index), is object[16]. I included this pointless complexity because I obviously don't know what's the code's doing, and you might :/
