• 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!

problem with level

N

nessabby1

Guest
Help! the levels arent changing when the player reaches the score. it remains the same level
and i added a level sprite that displays Level1 Level 2, etc. it pops up fine when on level 1. then i notice on level 2 and sprite still remains as level 1.
heres my code
in step event:
n=global.level;


if (n==1)
{s=1
image_index=0;}
if (n==2)
{s=1
image_index=1;}
if (n==3)
{s=1
image_index=2;}
if (n==4)
{s=1
image_index=3;}
if (n==5)
{s=1
image_index=4;}
if (n==6)
{s=1
image_index=5;}
if (n==7)
{s=1
image_index=6;}
if (n==8)
{s=1
image_index=7;}
if (n==9)
{s=1
image_index=8;}
if (n==10)
{s=1
image_index=9;}
if (n==11)
{s=1
image_index=10;}
if (n==12)
{s=1
image_index=11;}
if (n=13)
{s=1
image_index=12;}
if (n==14)
{s=1
image_index=13;}
if (n==15)
{s=1
image_index=14;}

if (s=1)
{
image_alpha+=0.2
if image_alpha>1
image_alpha=1
r++
if r>50{
r=0
s=0}
}else{image_alpha=0}

and in create event:
sprite_index=sp_levelnum;
image_speed=0;
image_alpha=0;
s=0;
r=0;
 

jo-thijs

Member
You can shorten the step event to:
Code:
n = global.level;
if n >= 1 && n < 16 && frac(n) == 0 {
    s = 1;
    image_index = n - 1;
}

if s == 1 {
    image_alpha = min(image_alpha + 0.2, 1);
    if ++r > 50 {
        r = 0;
        s = 0;
    }
} else
    image_alpha = 0;
As to your issue, can you tell us the value of global.level? (actually verify it works correctly, not just say what it is supposed to do)
 
Top