Trying to create randomly generated background with different speeds

C

CheeseWithMe

Guest
Hello! My code creates a random background when X = 0. However it only works if I am using factors of my W resolution 1280, otherwise it will not generate any background. I tried instead of _x == 0 , _x <= 0 but it didn't work.
Code:
            global.spd = -5;
Step Event in a obj_control:
Code:
//Change Backgrounds

              if  (background_x[1] == 0)
             { background_index[0] = choose(bck_2,bck_1)
             background_x[0] = 1280 }
             else
             if (background_x[0] == 0)
             { background_index[1] = choose(bck_2,bck_1)
             background_x[1] = 1280 }
Creation Code in the room:

Code:
// Backgrounds

             background_index[0] = bck_1;
             background_hspeed[0] = global.spd ;

             background_index[1] = choose(bck_2,bck_1)
             background_hspeed[1] = global.spd ;
             background_x[1] = 1280
             background_y[1] = 0
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Do:

if floor(background_x[1]) == 0

GM uses floats so it is i¡entirely possible that the x position is NEVER exactly equal (although using <= should have worked )
 
C

CheeseWithMe

Guest
Do:

if floor(background_x[1]) == 0

GM uses floats so it is i¡entirely possible that the x position is NEVER exactly equal (although using <= should have worked )
Hey! Sorry I didn't saw your post, somehow I haven't got any alerts, I tried with floor but is still doesn't work, I am an idiot and probably I did something wrong, although I checked everything numerous times.
It worked with help from Paijaus.
 
Top