code:
Code: Select all
on MoveAst
put (item two of loc of _gAsteroidID + 658) into _tYcoord
move _gAsteroidID to (item one of loc of _gAsteroidID) , _tYcoord in 7 sec without waiting
dispatch EndOfLife to _gAsteroidID in 7 sec {I'd like to add parameters here}
end MoveAst
on EndOfLife pAstID pAstNum
if the bottom of pAstID is 645
then
delete variable _gAstList[pAstID]
delete pAstID
else
send EndOfLife to _gAsteroidID in one tick with pAstID , pAstNum
end if
end EndOfLife
Code: Select all
--Vars--
global _gAsteroidBaseName
global _gAsteroidNumber
global _gNameingState
global _gCurrentAstroidName
global _gAsteroidID
global _gIconID
global _gAstList
--methods--
on CreateAsteroid
put "Asteroid_" into _gAsteroidBaseName --setsThe base name for each astroid made ["Asteroid_XX"]
put AsteroidNameMaker() into _gCurrentAstroidName --calls the name making function in a var
create invisible graphic _gCurrentAstroidName --creats new graphic w/ the name stored in the var
put the long ID of graphic _gCurrentAstroidName into _gAsteroidID --stores the ID of the newly made asteroid
put _gAsteroidID into _gAstList[_gAsteroidNumber]
add 1 to _gAsteroidNumber --adds 1 to the var for the next asteroid made
end CreateAsteroid
on SetAstPropoties
put the long ID of ChooseIcon() into _gIconID --calls the icon chooser function and stores it in a var
set the backgroundPattern of _gAsteroidID to the id of _gIconID --changes the icon of the asteroid
set the opaque of _gAsteroidID to true
set the colorOverlay of _gAsteroidID to false
set the lineSize of _gAsteroidID to 0
set the lockloc of _gAsteroidID to true
set the width of _gAsteroidID to 100
set the height of _gAsteroidID to 100
set the left of _gAsteroidID to (random(220))
set the bottom of _gAsteroidID to 0
set the visible of _gAsteroidID to true
end SetAstPropoties
on MoveAst
put (item two of loc of _gAsteroidID + 658) into _tYcoord
move _gAsteroidID to (item one of loc of _gAsteroidID) , _tYcoord in 7 sec without waiting
dispatch EndOfLife to _gAsteroidID in 7 sec _gAsteroidID , (_gAsteroidNumber - 1)
end MoveAst
on CheckCollisons
repeat for each element _tLine in _gAstList
if intersect (_gAsteroidID , _tLine , "pixels") and _gAsteroidID <> _tLine
then
put "yes" into _tToDel
end if
end repeat
if _tToDel is "yes"
then
delete variable _gAstList[(_gAsteroidNumber - 1)]
delete _gAsteroidID
else
MoveAst
end if
end CheckCollisons
on EndOfLife pAstID pAstNum
if the bottom of pAstID is 645
then
delete variable _gAstList[pAstID]
delete pAstID
else
send EndOfLife to _gAsteroidID in one tick with pAstID , pAstNum
end if
end EndOfLife
--functions--
function AsteroidNameMaker
if _gNameingState is not "passedIf" --checks if this the first time an asteriod is made
then
put 0 into _gAsteroidNumber --resets the var
put "passedIf" into _gNameingState
end if
return (_gAsteroidBaseName & _gAsteroidNumber) --returns the name
end AsteroidNameMaker
function ChooseIcon
put the long ID of img "asteroidOne" into _tImage[1]
put the long ID of img "asteroidTwo" into _tImage[2]
return _tImage[random(2)] --chosses one of the (2) images
end ChooseIcon