Windows error sprite_index = choose

Den5599

Member
"sprite_index = choose(Spr_asteroid_med, Spr_asteroid_small,Spr_asteroid_huge ); " it works incorrectly. the first sprite is always shown 2 times, and the last one in the list is not shown at all. who knows what the problem is?

If you duplicate the second sprite, then everything is shown correctly: "sprite_index = choose(Spr_asteroid_med, Spr_asteroid_small, Spr_asteroid_small, Spr_asteroid_huge );
 

TsukaYuriko

☄️
Forum Staff
Moderator
Did you call randomize(); when the game starts? Otherwise, you'll get the exact same random results every time the game runs in debug mode.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Is the problem resolved now? I'm unsure based on your reply. If not, please define "does not work at all".
 

TsukaYuriko

☄️
Forum Staff
Moderator
Not "repeat", but "define", as in "describe in greater detail". We can't help you based on a problem description of "doesn't work".
 

EvanSki

Raccoon Jam Host
GML:
randomize(); //remove this when you build the game and release it
sprite_index = choose(Spr_asteroid_med, Spr_asteroid_small, Spr_asteroid_huge);
//might want to make the sprites all a single sprite and change the image_number instead
//but It depends on your animations for the sprites
 

TsukaYuriko

☄️
Forum Staff
Moderator
Based on the last reply I suspect the function call choose() was replaced with the function call randomize(), which is not at all what you suggested of course.
Right. It didn't even occur to me that that's how my instructions could have been interpreted.

@Den5599
To make it clearer, then, my suggestion was to call randomize(); at the start of the game. This has nothing to do with the code being discussed and that code should not be modified at all (as seen in @EvanSki's example).

GML:
randomize(); //remove this when you build the game and release it
Actually don't remove it, as there's no need to do so.
 

Den5599

Member
Greetings. Sorry, I do not speak English, this is probably why there was a misunderstanding. I'll try to figure it out. Thanks for all the information provided.
 
Top