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

Referring to subimage?

I

itameio

Guest
So basically, what i want to do is to randomly change the sub image of a certain object when the game starts with one that is between "image0" and "image5".

how can i do that?, what type of code would i need?.
 
E

Ethanicus

Guest
You would use the irandom_range() function. Something like image_index=irandom_range(0,5)

irandom_range() returns an integer number between two numbers.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Don't forget to set image_speed to 0 as well, otherwise the sprite will animate like normally.
 
S

Snail Man

Guest
To automatically make it randomize to any sub image (no matter how many there are), you can use
Code:
image_index = irandom(image_number-1))
Edit: fixed. I always forget irandom does that -_-
 
Last edited by a moderator:
I

itameio

Guest
i was using a different sprite for the sub images, but thanks for reminding me of this!.
 
Top