Hi I got this function that I want to turn into arrays, but don't know how.
int transparent2, fadespeed2, fadecounter2, fadelimit2, fadeout = 0; // Fade Out
//----------------------------------------------------------------
Object *fadeobj2; // Fade Out
//----------------------------------------------------------------
function FadeObjectOut (Object *objectpoint,int value,int speed) {
Ã, if (fadeout) return 1; //aborts if fadeout is currently being executed
Ã, fadeobj2 = objectpoint;
Ã, transparent2 = fadeobj2.Transparency;
Ã, fadeout = 1;
Ã, fadespeed2 = speed;
Ã, fadecounter2 = speed;
Ã, fadelimit2 = value;
} // function end
//----------------------------------------------------------------
function repeatedly_execute_always() {
// fade object out
Ã, if (fadeout) {
Ã, Ã, if (transparent2 < fadelimit2) {
Ã, Ã, Ã, fadecounter2 --;
Ã, Ã, Ã, if (fadecounter2 < 0) {
Ã, Ã, Ã, Ã, fadecounter2 = fadespeed2;
Ã, Ã, Ã, Ã, transparent2 ++;
Ã, Ã, Ã, Ã, fadeobj2.Transparency = transparent2;
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, } else fadeout = 0;
Ã, Ã, }
//----------------------------------------------------------------
//----------------------------------------------------------------
function on_event (EventType event, int data) {
Ã, if (event == eEventLeaveRoom && fadeout) {
Ã, fadeout = 0;Ã, //reset, so won't crash in next room
Ã, fadeobj2.Transparency = 0;
Ã, }
//----------------------------------------------------------------
} // function on_event end
I can set the first bit:
int transparent2[10], fadespeed2[10], fadecounter2[10], fadelimit2[10], fadeout = 0; // Fade Out
//----------------------------------------------------------------
Object *fadeobj2[10]; // Fade Out
//----------------------------------------------------------------
But how do you assign each array element, so when a figure is added it fills the first array, but when a second is added it then fills the second element and so on?
any ideas would be grateful
I recommend having fadeout as an array, too. Then, when you run FadeObjectOut:
int i=0;
while (i<10 && fadeout[i]) {
i++;
}
if (i==10) Display("Error, reached max number of fading objects!");
// your existing code in here, with lots of "[i]" added...
and in rep_ex:
int i=0;
while (i<10) {
if (fadeout[i]) {
// your existing code in here, with lots of "[i]" added...
}
i++;
}
I've put a module together (http://www.geocities.com/nikmallon/FadeArray.zip), which also includes a FadeIn function - Lazarus has said (via PM) that it basically works OK. It needs a bit of tweaking, for example an error message like SSH has would probably be useful.