Creating generation at a set time period
Posted: Mon Nov 18, 2013 8:43 pm
I'm currently having a slight problem with a program I am creating. I need to get a random image to appear every 15 seconds but I don't know the code to get the generation to occur at the time intervals. I'm coding it on a mac and this is what I have so far.
This is the code for both generating the images and making them move. Any help on how to get the movement to occur after each time interval.
Thanks in advance for any help offered
Code: Select all
on randomgenerate
put random(3) into appearance
put random (3) into position
if appearance = 1 then
set the filename of image "Enemy" to "cartoon_shark.gif"
end if
if appearance = 2 then
set the filename of image "Enemy" to "Coral.jpg"
end if
if appearance = 3 then
set the filename of image "Enemy" to "Cartoon-Scuba-Diver-Hug.jpg"
end if
if position = 1 then
set the loc of image "Enemy" to 400,random(500)
end if
if position = 2 then
set the loc of image "Enemy" to 400, random(650)
end if
if position = 3 then
set the loc of image "Enemy" to 400, random(500)
end if
if the right of image("Enemy") < the right of this card then
set the right of image("Enemy") to the right of this card
end if
if the left of image("Enemy") < the left of this card then
set the left of image("Enemy") to the left of this card
end if
movement
end randomgenerate
on movement
put item 2 of loc of image "Enemy" into tY
move image "Enemy" to -50,tY in 10 seconds
end movement
Thanks in advance for any help offered