• 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 Need to shorten this code

Bukmand

Member
Code:
if Index=0 {
    for (i=0; i<Pressed; i+=1)
    {
        if Pressed=0 Sum=gAnswer[2]*gAnswer[3];
        if Pressed=1 Sum=gAnswer[2]*gAnswer[3]*gAnswer[4];
        if Pressed=2 Sum=gAnswer[2]*gAnswer[3]*gAnswer[4]*gAnswer[5];
        if Pressed=3 Sum=gAnswer[2]*gAnswer[3]*gAnswer[4]*gAnswer[5]*gAnswer[6];
        getType[2]=Sum;
    }
}
How to make it shorter?
 
J

Jaqueta

Guest
Not sure if this is going to work, but I think this is the right direction:

Code:
if Index=0
{
   Sum=gAnswwer[2];
   for(i=1; i<=Pressed; i+=1)
   {
      Sum*=gAnswer[i+2];
   }
   getType[2]=Sum;
}
 
Top