rem check for screen res
if check display mode(640,480,32)=1
set display mode 640,480,32
else
set display mode 640,480,16
endif
sync on
sync rate 30
color backdrop 0
hide mouse
`***************************Load in all the graphics*****************
load image "craft4.bmp",1
load image "misile.bmp",84
load image "Level_change.bmp",202
` ***********Spacseship co-ordinates
craftx=50:crafty=200
REM << these will be the variables used to move the missle, must needs to prepare them >>>>>>>>>>>>>>>>
missle_x# = 570
missle_y# = 390
` ***********Constant
Player_Craft=1
` *************************** position enemy misiles
REM << I have placed the missle at same coords as before, except I used the new position variables >>>>>>>>>>>>>
sprite 113,missle_x#,missle_y#,84
sprite 114,missle_x#-100,missle_y#-100,84
`**************************** Place the Invisiable markers for misiles
sprite 150,400,60,202
`//////////////// Start of Main Game Loop ////////////////////////////////////////////////////
do
`************** KEY DIRECTIONs
REM Upkey to move space ship Up
if UPKEY()=1 and crafty>100
dec crafty,5
endif
REM Downkey to move space ship Down
if DOWNKEY()=1 and crafty<400
inc crafty,5
endif
REM Leftkey to move space ship Up
if LEFTKEY()=1 and craftx>10
dec craftx,5
endif
REM Rightkey to move space ship Down
if RIGHTKEY()=1 and craftx<400
inc craftx,5
endif
if craftx>=missle_x# and craftx<=missle_x# and crafty<missle_y# then launchmissle()
remstart
if SPRITE EXIST(Player_Craft)
Collision_Number=SPRITE COLLISION(Player_Craft,0)
REM << the next line of code will set a 'launch' to a value of 1 in referance(boolean) that the rocket needs to be launched >>>>>>>>>>>>>>>>>>
if Collision_Number = 150 and launch = 0
launch = 1
REM << I am using PASTE SPRITE to move the missle image(more framerate than SPRITE),so the sprite needs to be hidden first >>>>>>>>>>>>>>>>>
hide sprite 113
endif
endif
remend
REM << this next function will move the missle object upwards when the variable 'launch' is set to a value 1 >>>>>>>>>>>>>>>>>
if launch = 1 then missle_y# = launchmissle(missle_x#,missle_y#)
REM << stop the missle movement and reposition the missle where it was before once it leaves the screen >>>>>>>>>>>>>>
if missle_y# < -42
REM << reset 'launch' to 0 to end missle flight >>>>>>>>>>>>>>>>>
launch = 0
REM << reset rocket's position(which isn't linked to the actual sprite, which never accually moved since I used PASTE) and show it's sprite once again >>>>>>>>>>>>>>>>>>
missle_y# = 390
show sprite 113
endif
`******************** UPDATE OBJECTS *****************************
sprite Player_Craft,craftx,crafty,Player_Craft
SYNC
REM << I have added clear screen for the text which will be displayed for a period of time, while the rocket is moving >>>>>>>>>>>>>>>>
cls
LOOP
REM << the new launch missle function;I must recieve the current value of the missle'd y position >>>>>>>>>>>>>>>>>>>>
function launchmissle(x#,y#)
REM << for added physics affects, I have included a variable which will increase the speed of the missle's movement by so much each loop >>>>>>>>>>>>>>>>>
inc movespeed#,10
REM << here I subtract 'movespeed' from missle_y# to move the missle up at a gradually increasing speed >>>>>>>>>>>>>>>>>>>>>>>>
dec y#,movespeed#
REM << here the text will be displayed for as long as this function runs >>>>>>>>>>>>>>>>>>>
ink rgb(255,0,0),0
text 530,460,"Launch Missle"
REM << paste missle sprite at coords >>>>>>>>>>>>>>>>>
paste sprite 113,x#,y#
REM << if rocket goes above screen,reset values for next launch >>>>>>>>>>>>>>>>>>>>>>>
if y# < -42 then movespeed# = 0
REM << y coords of the missle will be recieved every loop and then changed, so I must also update them by returning the new missle_y# value to itself >>>>>>>>>>>>>>>>>>>
endfunction y#
Where am i going wrong here?