• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM counter variable

F

fxokz

Guest
So basically i think image_speed is causing problems in my game so im trying to remove it by adding a counter variable instead. The problem is keeping track of multiple counters So far i have a variable in my create event called "counter" but what if i need more counters? do I have to keep initializing variables in the create event or is there a way to make it more easier?
 
G

GRArthas

Guest
you just make more variables in the create event with different names example: counter_imgSpeed but if you use these variables in more than one object you can either use global. for your variables for example global.counter or just make a script and put them all there and call them in the create event
 
P

PWL

Guest
You can also create an array of counters.
I'm thinking something along these lines:

Code:
/// CREATE
for(var i=0; i<10; i++){
    counter[i] = 0;
}

/// STEP
for(var i=0; i<10; i++){
    counter[i]++;
}
And then add macros/constants that give a description for the numbers 0-9. That way you can get them like this:
Code:
counter[COUNTER_IMGINDEX] = 0;
 
Top