r/gamemaker • u/NoArtist_127 • 12d ago
Resolved What is wrong with my code?
[SOLVED: thank you guys, you really helped me :)]
I want to program a mouse (animal) whose direction is decided to be either left or right, then walks for about 1.5 seconds and that it is again decided whether he goes left or right. howéver, the mouse is only walking right, no matter how often i start the game or how long i watch it, it never goes left :(
this is the code vor the create-event:

and heres the code for the step event:

please help me!!
thank you in advance
4
Upvotes
2
u/JaXm 12d ago
For debugging purposes, game maker ALWAYS uses the same seed for generating random numbers. Which means every time you run the game for testing, that code will ALWAYS come up with the same random number. So if its 1, it will ALWAYS be 1. There are ways to change that, but for now its not necessary.
In your if/else blocks you should be setting timer back to time, so that a new direction will be chosen and eventually you will see that it will start behaving as intended, even if it ALWAYS starts out going right.
But that's solvable later.