Search code examples
randomdrawgame-maker

Game Maker, Draw Command is drawing infinitely?


So I have 20 variables named fact[x] where x is from 0 to 19. I have this command under the Left_Released in an object called randomf:

if instance_exists(facts) {
with facts {instance_destroy()} 
}
instance_create(x,1395,facts)

facts (object) has this code under draw:

draw_set_font(FedraS)
draw_set_colour(c_white)
draw_set_halign(fa_center)
draw_text_ext(room_width/2,y,randomf.fact[irandom(19)],48,room_width-32)

What is happening is that whenever I'm clicking on the object, it draw a random fact and then deletes it and then draws the next fact endlessly. Where am I going wrong?

thanks.


Solution

  • Okay I solved it, apparently the Draw function is called every step and not just once. I just used a variable called cast = irandom(19).