I need to make asteroids that fall from the sky, hit the floor and come back up. This is what I have been currently working on but I don't see what is wrong.
if asteroidstate = 0
//randomize values
randomxhigh = getspritex(hoop)
randomx = Random(0,randomxhigh)
//reset y coordinate
randomy = -430
//reset position
SetSpritePosition(asteroid,randomx,randomy)
//reset timer
ResetTimer()
//new state
asteroidstate = 1
endif
if asteroidstate = 1
//asteroidmovement
asteroidx = asteroidx - GetFrameTime() * 60
asteroidy = asteroidy + GetFrameTime() * 300
SetSpritePosition(asteroid,asteroidx,asteroidy)
if GetSpriteCollision(asteroid,ground)
//size value
asteroidsize = asteroidsize + GetFrameTime() * 300
//set size
SetSpriteSize(asteroid,100-asteroidsize,100-asteroidsize)
if asteroidsize < 100
SetSpritePosition(asteroid,500,-430)
asteroidstate =0
endif
endif
endif
global randomxhigh as integer = 0
global randomx as integer = 0
global asteroidtimer as integer = 0
global asteroidx as float = 0
global asteroidy as float = 0
global asteroidsize as float = 0
global asteroidstate as integer = 0
I want to make it so that when the asteroid hits the ground, it shrinks and then gets placed back up, with a random x coordinate so every time it falls it falls again on a different x position.
If anyone can help me improve my code I would really appreciate it. Thank you.