Dear All,
I am current doing this game for my course final project and is stuck.
My bloody spacecraft doesn't take off after the first time round. I have screen through my code and is total out of my wits. I really need your help to tell me what have I done wrong that my ship is not flying after the first take off.
I am a novice coder so the code may be very untidy to most of you out there but I've tried my best to keep them in order.
To keep it short and simple, this is what my ship is suppose to do:--
1. When game start at every level, the space ship is supposed to be landed on a Moon. (Success)
2. When I hit the space bar, it supposed to fly off. (Success)
3. When collide with a moon, it supposed to land on the moon. (Success).
And the loop goes on.
Appearently, after my spacecraft took off and landed on a moon, it fails to take off again. I don't know why.
Please kindly tell me so that I can get it done.
There are a few bitmaps and a bgm which I can't attached here. If you guys need them to run the game, please mail me at alexander@yahoo.com.sg
Thanks.
REM Project: Galactic Mail
REM Created: 09/Jul/2008 20:28:22
REM
REM ***** Main Source File *****
REM
`--- (A) Declaring global variables for game. These variables can be accessed anywhere in the game ---
`A1. Images and Sprites Constants
`A1.1. Background Images
Global IMG_Background as Word = 1000
`A1.2. Game Title Image and Sprite
Global IMG_Title as Word = 2000
Global SPR_Title as Word = 2000
`A1.3. Moon Image and Sprite
Global IMG_Moon as Word = 3000
DIM SPR_Moon(14)
SPR_Moon(0)=3000 :`Special Moon for Landed Space-Craft
SPR_Moon(1)=3001
SPR_Moon(2)=3002
SPR_Moon(3)=3003
SPR_Moon(4)=3004
SPR_Moon(5)=3005
SPR_Moon(6)=3006
SPR_Moon(7)=3007
SPR_Moon(8)=3008
SPR_Moon(9)=3009
SPR_Moon(10)=3010
SPR_Moon(11)=3011
SPR_Moon(12)=3012
SPR_Moon(13)=3013 :`This moon works hand-in-hand with SPR_Flying and Special Moon during the beginning of every level
`A1.4. Asteroid Image and Sprite
DIM IMG_Asteroid(12)
IMG_Asteroid(0)=4000
IMG_Asteroid(1)=4001
IMG_Asteroid(2)=4002
IMG_Asteroid(3)=4003
IMG_Asteroid(4)=4004
IMG_Asteroid(5)=4005
IMG_Asteroid(6)=4006
IMG_Asteroid(7)=4007
IMG_Asteroid(8)=4008
IMG_Asteroid(9)=4009
IMG_Asteroid(10)=4010
IMG_Asteroid(11)=4011
DIM SPR_Asteroid(12)
SPR_Asteroid(0)=4000
SPR_Asteroid(1)=4001
SPR_Asteroid(2)=4002
SPR_Asteroid(3)=4003
SPR_Asteroid(4)=4004
SPR_Asteroid(5)=4005
SPR_Asteroid(6)=4006
SPR_Asteroid(7)=4007
SPR_Asteroid(8)=4008
SPR_Asteroid(9)=4009
SPR_Asteroid(10)=4010
SPR_Asteroid(11)=4011
`A1.5. Space-craft Image and Sprite
Global IMG_Landed as Word = 5000
Global SPR_Landed as Word = 5000
Global IMG_Flying as Word = 6000
Global SPR_Flying as Word = 6000
`A1.6 Explosion Image and Sprite
Global IMG_Explosion as Word = 7000
Global SPR_Explosion as Word = 7000
`A2. Audio and Sound Effects
`A2.1. Background Music
Global MUS_Background as Word = 1000
`A2.2 Sound for Spacecraft Safe-Landing on Moon
Global SND_Landed as Word = 1000
`A2.3 Sound for Spacecraft crashing with Asteroid
Global SND_Explosion as Word = 2000
`A3. Player-object's X and Y position
Global LandedX# as Float
Global LandedY# as Float
Global FlyingX# as Float
Global FlyingY# as Float
`A4. Game Objects
`There is no need for creating game object for 2D games in DarkBASIC.
`--- (B) Initializing the Screen Display ---
Hide Mouse
Set Display Mode 640,480,32
`B1. Load and Looping of Background Music for game
Load Music "GalacticMail_Resources\Audio&Sound\Music.mid",MUS_Background
Loop Music MUS_Background
`B2. Creating Asteroid Sprite
`B2.1. Loading Asteroid Image
Set Image Colorkey 0,0,0
Create Animated Sprite SPR_Asteroid(0), "GalacticMail_Resources\Visual\Asteroid.bmp",12,15,IMG_Asteroid(0)
`B2.2. Clone Asteroid sprites
For a = 4001 to 4011
Clone Sprite SPR_Asteroid(0), a
Next a
`B3. Load Moon Image
Set Image Colorkey 7,255,54
Load Image "GalacticMail_Resources\Visual\Moon.bmp",IMG_Moon
`B4. Load Game Title
Set Image Colorkey 64,128,0
Load Image "GalacticMail_Resources\Visual\Title.bmp",IMG_Title
`remstart
`B5. Load Landed Spacecraft Image
Set Image Colorkey 0,255,0
Load Bitmap "GalacticMail_Resources\Visual\Landed.bmp",IMG_Landed
Landed_x1#=0
Landed_y1#=0
Landed_x2#=48
Landed_y2#=48
For Image_Landed = 5001 to 5012
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Landed_x1#=0
Landed_y1#=48
Landed_x2#=48
Landed_y2#=96
For Image_Landed = 5013 to 5024
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Landed_x1#=0
Landed_y1#=96
Landed_x2#=48
Landed_y2#=144
For Image_Landed = 5025 to 5036
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Landed_x1#=0
Landed_y1#=144
Landed_x2#=48
Landed_y2#=192
For Image_Landed = 5037 to 5048
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Landed_x1#=0
Landed_y1#=192
Landed_x2#=48
Landed_y2#=240
For Image_Landed = 5049 to 5060
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Landed_x1#=0
Landed_y1#=240
Landed_x2#=48
Landed_y2#=288
For Image_Landed = 5061 to 5072
Get Image Image_Landed,Landed_x1#,Landed_y1#,Landed_x2#,Landed_y2#
Landed_x1# = Landed_x1#+48
Landed_x2# = Landed_x2#+48
Next Image_Landed
Delete Bitmap IMG_Landed
`B6. Load Flying Spacecraft Image
Set Image Colorkey 0,255,0
Load Bitmap "GalacticMail_Resources\Visual\Flying.bmp",IMG_Flying
Flying_x1#=0
Flying_y1#=0
Flying_x2#=48
Flying_y2#=48
For Image_Flying = 6001 to 6012
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Flying_x1#=0
Flying_y1#=48
Flying_x2#=48
Flying_y2#=96
For Image_Flying = 6013 to 6024
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Flying_x1#=0
Flying_y1#=96
Flying_x2#=48
Flying_y2#=144
For Image_Flying = 6025 to 6036
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Flying_x1#=0
Flying_y1#=144
Flying_x2#=48
Flying_y2#=192
For Image_Flying = 6037 to 6048
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Flying_x1#=0
Flying_y1#=192
Flying_x2#=48
Flying_y2#=240
For Image_Flying = 6049 to 6060
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Flying_x1#=0
Flying_y1#=240
Flying_x2#=48
Flying_y2#=288
For Image_Flying = 6061 to 6072
Get Image Image_Flying,Flying_x1#,Flying_y1#,Flying_x2#,Flying_y2#
Flying_x1# = Flying_x1#+48
Flying_x2# = Flying_x2#+48
Next Image_Flying
Delete Bitmap IMG_Flying
`B7. Load Explosion Image
Set Image Colorkey 0,0,0
Load Bitmap "GalacticMail_Resources\Visual\Explosion.bmp",IMG_Explosion
Explosion_x1#=0
Explosion_y1#=0
Explosion_x2#=64
Explosion_y2#=64
For Image_Explosion = 7001 to 7009
Get Image Image_Explosion,Explosion_x1#,Explosion_y1#,Explosion_x2#,Explosion_y2#
Explosion_x1# = Explosion_x1#+64
Explosion_x2# = Explosion_x2#+64
Next Image_Explosion
Delete Bitmap IMG_Explosion
`B8. Initializing Landed and Flying variables for Spacecraft
Landed=0
Flying=0
`B9. Arrays for check if Spacecraft safely landed on moon
HitMoon=0
Safe=0
`remstart
DIM Safe(12)
Safe(1)=0
Safe(2)=0
Safe(3)=0
Safe(4)=0
Safe(5)=0
Safe(6)=0
Safe(7)=0
Safe(8)=0
Safe(9)=0
Safe(10)=0
Safe(11)=0
Safe(12)=0
`remend
`B10. Arrays for checking if Spacecraft crashes with asteroids
DIM HitAsteroid(12)
HitAsteroid(1)=0
HitAsteroid(2)=0
HitAsteroid(3)=0
HitAsteroid(4)=0
HitAsteroid(5)=0
HitAsteroid(6)=0
HitAsteroid(7)=0
HitAsteroid(8)=0
HitAsteroid(9)=0
HitAsteroid(10)=0
HitAsteroid(11)=0
HitAsteroid(12)=0
`B11. Check if Spacecraft crashes with asteroid
Explode=0
Image_Explode=1
`B12. Initialize various sub-routine branches
Loading=1
Level001=0
Level002=0
Level003=0
`B13. Initialize various Asteroids sprites starting positions
`Initialize SPR_Asteroid(1) starting position
Asteroid_x0# = 48 : Asteroid_y0# = 208
`Initialize SPR_Asteroid(2) starting position
Asteroid_x1# = 32 : Asteroid_y1# = 368
`Initialize SPR_Asteroid(3) starting position
Asteroid_x2# = 144 : Asteroid_y2# = 80
`Initialize SPR_Asteroid(1) starting position
Asteroid_x3# = 240 : Asteroid_y3# = 272
`Initialize SPR_Asteroid(2) starting position
Asteroid_x4# = 288 : Asteroid_y4# = 64
`Initialize SPR_Asteroid(3) starting position
Asteroid_x5# = 304 : Asteroid_y5# = 146
`Initialize SPR_Asteroid(1) starting position
Asteroid_x6# = 384 : Asteroid_y6# = 160
`Initialize SPR_Asteroid(2) starting position
Asteroid_x7# = 464 : Asteroid_y7# = 336
`Initialize SPR_Asteroid(3) starting position
Asteroid_x8# = 464 : Asteroid_y8# = 416
`Initialize SPR_Asteroid(1) starting position
Asteroid_x9# = 480 : Asteroid_y9# = 80
`Initialize SPR_Asteroid(2) starting position
Asteroid_x10# = 592 : Asteroid_y10# = 128
`Initialize SPR_Asteroid(3) starting position
Asteroid_x11# = 592 : Asteroid_y11# = 320
`B14. Initialize various Moon sprites starting postions
`. Initialize SPR_Moon(0) starting Position : `Special Moon for Landed Space-Craft
Moon_x0# = 592 : Moon_y0# = 32
`Initialize SPR_Moon(1) starting Position
Moon_x1# = 48 : Moon_y1# = 128
`Initialize SPR_Moon(2) starting Position
Moon_x2# = 48 : Moon_y2# = 304
`Initialize SPR_Moon(3) starting Position
Moon_x3# = 80 : Moon_y3# = 432
`Initialize SPR_Moon(4) starting Position
Moon_x4# = 144 : Moon_y4# = 176
`Initialize SPR_Moon(5) starting Position
Moon_x5# = 208 : Moon_y5# = 48
`Initialize SPR_Moon(6) starting Position
Moon_x6# = 240 : Moon_y6# = 384
`Initialize SPR_Moon(7) starting Position
Moon_x7# = 304 : Moon_y7# = 160
`Initialize SPR_Moon(8) starting Position
Moon_x8# = 384 : Moon_y8# = 320
`Initialize SPR_Moon(9) starting Position
Moon_x9# = 146 : Moon_y9# = 64
`Initialize SPR_Moon(10) starting Position
Moon_x10# = 448 : Moon_y10# = 144
`Initialize SPR_Moon(11) starting Position
Moon_x11# = 528 : Moon_y11# = 320
`Initialize SPR_Moon(12) starting Position
Moon_x12# = 560 : Moon_y12# = 208
`Initialize SPR_Moon(13) starting Position : `This moon works hand-in-hand with SPR_Flying and Special Moon during the beginning of every level
Moon_x13# = 576 : Moon_y13# = 432
`Initialize Landed Space-Craft starting position
LandedX = 36 : LandedY = 36
Sync On
Sync Rate 35
`--- (C) Various Branches for actual Game-Play ------
_TitlePage:
`--- Load Background Image ---
Load Bitmap "GalacticMail_Resources\Visual\Background.bmp",IMG_Background
Background_x1=0
Background_x2=640
Background_y1=0
Background_y2=480
Background001= 1000
Get Image Background001, Background_x1,Background_y1,Background_x2,Background_y2
Delete Bitmap IMG_Background
do
cls
IF Loading=1
`Draw Background Image onto screen
`Set Current Bitmap IMG_Background
Paste Image Background001, 0,0
remstart
BGM_Exist = Music Exist(MUS_Background)
BGM_Looping = Music Looping(MUS_Background)
BGM_Volume = Music Volume(MUS_Background)
Print
Print Space$(06); "BGM Exist= "; BGM_Exist
Print
Print Space$(06); "BGM Looping= "; BGM_Looping
Print
Print Space$(06); "BGM Volume= "; BGM_Volume
Print
remend
`Draw SPR_Asteroid(0) Sprite onto screen
Asteroid_x0# = Asteroid_x0#-3
Asteroid_y0# = Asteroid_y0#+3
IF Asteroid_x0# < 0 THEN Asteroid_x0# = 640
IF Asteroid_y0# > 480 THEN Asteroid_y0# = 0
Play Sprite SPR_Asteroid(0),1,180,50
Sprite SPR_Asteroid(0),Asteroid_x0#,Asteroid_y0#,IMG_Asteroid(0)
`Draw SPR_Asteroid(5) Sprite onto screen
Asteroid_x5# = Asteroid_x5#+3
Asteroid_y5# = Asteroid_y5#+3
IF Asteroid_x5# > 640 THEN Asteroid_x5# = 0
IF Asteroid_y5# > 480 THEN Asteroid_y5# = 0
Play Sprite SPR_Asteroid(5),1,180,50
Sprite SPR_Asteroid(5),Asteroid_x5#,Asteroid_y5#,IMG_Asteroid(0)
`Draw SPR_Asteroid(8) Sprite onto screen
Asteroid_x8# = Asteroid_x8#-3
Asteroid_y8# = Asteroid_y8#-3
IF Asteroid_x8# < 0 THEN Asteroid_x8# = 640
IF Asteroid_y8# < 0 THEN Asteroid_y8# = 480
Play Sprite SPR_Asteroid(8),1,180,50
Sprite SPR_Asteroid(8),Asteroid_x8#,Asteroid_y8#,IMG_Asteroid(0)
`Draw SPR_Asteroid(9) Sprite onto screen
Asteroid_x9# = Asteroid_x9#+3
Asteroid_y9# = Asteroid_y9#-3
IF Asteroid_x9# > 640 THEN Asteroid_x9# = 0
IF Asteroid_y9# < 0 THEN Asteroid_y9# = 480
Play Sprite SPR_Asteroid(9),1,180,50
Sprite SPR_Asteroid(9),Asteroid_x9#,Asteroid_y9#,IMG_Asteroid(0)
`Draw Game Title Sprite onto screen
Sprite SPR_Title,80,80,IMG_Title
`Draw SPR_Moon(3) Sprite onto screen
Moon_x3# = Moon_x3#+3
Moon_y3# = Moon_y3#-3
IF Moon_x3# > 640 THEN Moon_x3# = 0
IF Moon_y3# < 0 THEN Moon_y3# = 480
Sprite SPR_Moon(3),Moon_x3#,Moon_y3#,IMG_Moon
`Draw SPR_Moon(7) Sprite onto screen
Moon_x7# = Moon_x7#-3
Moon_y7# = Moon_y7#-3
IF Moon_x7# < 0 THEN Moon_x7# = 640
IF Moon_y7# < 0 THEN Moon_y7# = 480
Sprite SPR_Moon(7),Moon_x7#,Moon_y7#,IMG_Moon
`Draw SPR_Moon(12) Sprite onto screen
Moon_x12# = Moon_x12#-3
Moon_y12# = Moon_y12#+3
IF Moon_x12# < 0 THEN Moon_x12# = 640
IF Moon_y12# > 480 THEN Moon_y12# = 0
Sprite SPR_Moon(12),Moon_x12#,Moon_y12#,IMG_Moon
center text 320,400,"Press <ENTER> to Play"
IF Returnkey()=1 THEN Loading=0
EndIF
IF Loading=0
Delete Sprite SPR_Title : Delete Image IMG_Title
Delete Image Background001 : Level001=1
EndIF
IF Level001=1 THEN GOTO _LevelOne
Sync : `This line very important! MUST PUT AT THE END OF EVERY BRANCH!!!
loop
_LevelOne:
`--- Load Background Image ---
Load Bitmap "GalacticMail_Resources\Visual\Background.bmp",IMG_Background
Background_x1=0
Background_x2=640
Background_y1=0
Background_y2=480
Background001= 1000
Get Image Background001, Background_x1,Background_y1,Background_x2,Background_y2
Delete Bitmap IMG_Background
do
cls
IF Level001=1
`Draw Background Image onto screen
Paste Image Background001, 0,0
`Draw SPR_Asteroid(0) Sprite onto screen
Asteroid_x0# = Asteroid_x0#+3
Asteroid_y0# = Asteroid_y0#+3
IF Asteroid_x0# > 640 THEN Asteroid_x0# = 0
IF Asteroid_y0# > 480 THEN Asteroid_y0# = 0
Play Sprite SPR_Asteroid(0),1,180,50
Sprite SPR_Asteroid(0),Asteroid_x0#,Asteroid_y0#,IMG_Asteroid(0)
`Draw SPR_Asteroid(5) Sprite onto screen
Asteroid_x5# = Asteroid_x5#-3
Asteroid_y5# = Asteroid_y5#+3
IF Asteroid_x5# > 640 THEN Asteroid_x5# = 0
IF Asteroid_y5# > 480 THEN Asteroid_y5# = 0
Play Sprite SPR_Asteroid(5),1,180,50
Sprite SPR_Asteroid(5),Asteroid_x5#,Asteroid_y5#,IMG_Asteroid(0)
`Draw SPR_Asteroid(8) Sprite onto screen
Asteroid_x8# = Asteroid_x8#-3
Asteroid_y8# = Asteroid_y8#-3
IF Asteroid_x8# < 0 THEN Asteroid_x8# = 640
IF Asteroid_y8# < 0 THEN Asteroid_y8# = 480
Play Sprite SPR_Asteroid(8),1,180,50
Sprite SPR_Asteroid(8),Asteroid_x8#,Asteroid_y8#,IMG_Asteroid(0)
`Draw SPR_Asteroid(9) Sprite onto screen
Asteroid_x9# = Asteroid_x9#-3
Asteroid_y9# = Asteroid_y9#-3
IF Asteroid_x9# < 0 THEN Asteroid_x9# = 640
IF Asteroid_y9# < 0 THEN Asteroid_y9# = 480
Play Sprite SPR_Asteroid(9),1,180,50
Sprite SPR_Asteroid(9),Asteroid_x9#,Asteroid_y9#,IMG_Asteroid(0)
`Draw SPR_Moon(1) Sprite onto screen
Moon_x1# = Moon_x1#+3
Moon_y1# = Moon_y1#-3
IF Moon_x1# > 640 THEN Moon_x1# = 0
IF Moon_y1# < 0 THEN Moon_y1# = 480
Sprite SPR_Moon(1),Moon_x1#,Moon_y1#,IMG_Moon
`Draw SPR_Moon(3) Sprite onto screen
Moon_x3# = Moon_x3#-3
Moon_y3# = Moon_y3#+3
IF Moon_x3# < 640 THEN Moon_x3# = 6400
IF Moon_y3# > 480 THEN Moon_y3# = 0
Sprite SPR_Moon(3),Moon_x3#,Moon_y3#,IMG_Moon
`Draw SPR_Moon(4) Sprite onto screen
Moon_x4# = Moon_x4#-3
Moon_y4# = Moon_y4#-3
IF Moon_x4# < 0 THEN Moon_x4# = 640
IF Moon_y4# < 0 THEN Moon_y4# = 480
Sprite SPR_Moon(4),Moon_x4#,Moon_y4#,IMG_Moon
`Draw SPR_Moon(6) Sprite onto screen
Moon_x6# = Moon_x6#-3
Moon_y6# = Moon_y6#+3
IF Moon_x6# < 0 THEN Moon_x6# = 640
IF Moon_y6# > 480 THEN Moon_y6# = 0
Sprite SPR_Moon(6),Moon_x6#,Moon_y6#,IMG_Moon
`Draw SPR_Moon(7) Sprite onto screen
Moon_x7# = Moon_x7#+3
Moon_y7# = Moon_y7#+3
IF Moon_x7# > 640 THEN Moon_x7# = 0
IF Moon_y7# > 480 THEN Moon_y7# = 00
Sprite SPR_Moon(7),Moon_x7#,Moon_y7#,IMG_Moon
`Draw SPR_Moon(9) Sprite onto screen
Moon_x9# = Moon_x9#-3
Moon_y9# = Moon_y9#+3
IF Moon_x9# < 0 THEN Moon_x9# = 640
IF Moon_y9# > 480 THEN Moon_y9# = 0
Sprite SPR_Moon(9),Moon_x9#,Moon_y9#,IMG_Moon
`Draw SPR_Moon(12) Sprite onto screen
Moon_x12# = Moon_x12#-3
Moon_y12# = Moon_y12#-3
IF Moon_x12# < 0 THEN Moon_x12# = 640
IF Moon_y12# < 0 THEN Moon_y12# = 480
Sprite SPR_Moon(12),Moon_x12#,Moon_y12#,IMG_Moon
`remstart
Landed=1
IF Landed=1
HitMoon=1
Safe=1
`Draw SPR_Moon(0) Sprite onto screen : Special Moon for Landed Space-Craft : Draw HERE to put it on top of every other sprites
Moon_x0# = Moon_x0#+3
Moon_y0# = Moon_y0#+3
IF Moon_x0# > 640 THEN Moon_x0# = 0
IF Moon_y0# > 480 THEN Moon_y0# = 0
Sprite SPR_Moon(0),Moon_x0#,Moon_y0#,IMG_Moon
`Draw SPR_Landed Sprite onto screen
LandedX# = Moon_x0#+6 : LandedY# = Moon_y0#+6
IF LandedX# < 0 THEN LandedX# = 640
IF LandedX# >640 THEN LandedX# = 0
IF LandedY# < 0 THEN LandedY# = 480
IF LandedY# > 480 THEN LandedY# =0
IF Image_Landed < 5001 THEN Image_Landed = 5072
IF Image_Landed > 5072 THEN Image_Landed = 5001
IF Leftkey()=1 THEN Image_Landed = Image_Landed+1
IF Rightkey()=1 THEN Image_Landed = Image_Landed-1
Sprite SPR_Landed, LandedX#,LandedY#,Image_Landed
`THIS SPACEKEY PART VERY IMPORTANT!!! DON'T PUT THESE LINES ANYWHERE ELSE!!!
IF Spacekey()=1
CurrentX$ = str$(LandedX#)
CurrentY$ = str$(LandedY#)
FlyingX# = val(CurrentX$)
FlyingY# = val(CurrentY$)
Flying=1
EndIF
EndIF
IF Flying=1
Landed=0
HtMoon=0
Safe=0
`Draw SPR_Flying Sprite onto Screen
Image_Flying = Image_Landed+1000
`--- Codes that makes the Spacecraft flies ---
`Setting Moving Direction at 0 degree
IF Image_Flying = 6001
FlyingX# = FlyingX#+4 : FlyingY# = FlyingY#
EndIF
`Setting Moving DIrection at 5 degree
IF Image_Flying = 6002
FlyingX# = FlyingX#+3.8888888
FlyingY# = FlyingY#-0.2222222
EndIF
`Setting Moving DIrection at 10 degree
IF Image_Flying = 6003
FlyingX# = FlyingX#+3.6666666
FlyingY# = FlyingY#-0.4444444
EndIF
`Setting Moving DIrection at 15 degree
IF Image_Flying = 6004
FlyingX# = FlyingX#+3.4444444
FlyingY# = FlyingY#-0.6666666
EndIF
`Setting Moving DIrection at 20 degree
IF Image_Flying = 6005
FlyingX# = FlyingX#+3.2222222
FlyingY# = FlyingY#-0.8888888
EndIF
`Setting Moving DIrection at 25 degree
IF Image_Flying = 6006
FlyingX# = FlyingX#+3
FlyingY# = FlyingY#-1
EndIF
`Setting Moving DIrection at 30 degree
IF Image_Flying = 6007
FlyingX# = FlyingX#+2.8888888
FlyingY# = FlyingY#-1.2222222
EndIF
`Setting Moving DIrection at 35 degree
IF Image_Flying = 6008
FlyingX# = FlyingX#+2.6666666
FlyingY# = FlyingY#-1.4444444
EndIF
`Setting Moving DIrection at 40 degree
IF Image_Flying = 6009
FlyingX# = FlyingX#+2.4444444
FlyingY# = FlyingY#-1.6666666
EndIF
`Setting Moving DIrection at 45 degree
IF Image_Flying = 6010
FlyingX# = FlyingX#+2.2222222
FlyingY# = FlyingY#-1.8888888
EndIF
`Setting Moving DIrection at 50 degree
IF Image_Flying = 6011
FlyingX# = FlyingX#+2
FlyingY# = FlyingY#-2
EndIF
`Setting Moving DIrection at 55 degree
IF Image_Flying = 6012
FlyingX# = FlyingX#+1.8888888
FlyingY# = FlyingY#-2.2222222
EndIF
`Setting Moving DIrection at 60 degree
IF Image_Flying = 6013
FlyingX# = FlyingX#+1.6666666
FlyingY# = FlyingY#-2.4444444
EndIF
`Setting Moving DIrection at 65 degree
IF Image_Flying = 6014
FlyingX# = FlyingX#+1.4444444
FlyingY# = FlyingY#-2.6666666
EndIF
`Setting Moving DIrection at 70 degree
IF Image_Flying = 6015
FlyingX# = FlyingX#+1.2222222
FlyingY# = FlyingY#-2.8888888
EndIF
`Setting Moving DIrection at 75 degree
IF Image_Flying = 6016
FlyingX# = FlyingX#+1
FlyingY# = FlyingY#-3
EndIF
`Setting Moving DIrection at 80 degree
IF Image_Flying = 6017
FlyingX# = FlyingX#+0.8888888
FlyingY# = FlyingY#-3.2222222
EndIF
`Setting Moving DIrection at 85 degree
IF Image_Flying = 6018
FlyingX# = FlyingX#+0.6666666
FlyingY# = FlyingY#-3.4444444
EndIF
`Setting Moving Direction at 90 degree
IF Image_Flying = 6019
FlyingX# = FlyingX# : FlyingY# = FlyingY#-4
EndIF
`Setting Moving DIrection at 95 degree
IF Image_Flying = 6020
FlyingX# = FlyingX#-0.6666666
FlyingY# = FlyingY#-3.4444444
EndIF
`Setting Moving DIrection at 100 degree
IF Image_Flying = 6021
FlyingX# = FlyingX#-0.8888888
FlyingY# = FlyingY#-3.2222222
EndIF
`Setting Moving DIrection at 105 degree
IF Image_Flying = 6022
FlyingX# = FlyingX#-1
FlyingY# = FlyingY#-3
EndIF
`Setting Moving DIrection at 110 degree
IF Image_Flying = 6023
FlyingX# = FlyingX#-1.2222222
FlyingY# = FlyingY#-2.8888888
EndIF
`Setting Moving DIrection at 115 degree
IF Image_Flying = 6024
FlyingX# = FlyingX#-1.4444444
FlyingY# = FlyingY#-2.6666666
EndIF
`Setting Moving DIrection at 120 degree
IF Image_Flying = 6025
FlyingX# = FlyingX#-1.6666666
FlyingY# = FlyingY#-2.4444444
EndIF
`Setting Moving DIrection at 125 degree
IF Image_Flying = 6026
FlyingX# = FlyingX#-1.8888888
FlyingY# = FlyingY#-2.2222222
EndIF
`Setting Moving DIrection at 130 degree
IF Image_Flying = 6027
FlyingX# = FlyingX#-2
FlyingY# = FlyingY#-2
EndIF
`Setting Moving DIrection at 135 degree
IF Image_Flying = 6028
FlyingX# = FlyingX#-2.2222222
FlyingY# = FlyingY#-1.8888888
EndIF
`Setting Moving DIrection at 140 degree
IF Image_Flying = 6029
FlyingX# = FlyingX#-2.4444444
FlyingY# = FlyingY#-1.6666666
EndIF
`Setting Moving DIrection at 145 degree
IF Image_Flying = 6030
FlyingX# = FlyingX#-2.6666666
FlyingY# = FlyingY#-1.4444444
EndIF
`Setting Moving DIrection at 150 degree
IF Image_Flying = 6031
FlyingX# = FlyingX#-2.8888888
FlyingY# = FlyingY#-1.2222222
EndIF
`Setting Moving DIrection at 155 degree
IF Image_Flying = 6032
FlyingX# = FlyingX#-3
FlyingY# = FlyingY#-1
EndIF
`Setting Moving DIrection at 160 degree
IF Image_Flying = 6033
FlyingX# = FlyingX#-3.2222222
FlyingY# = FlyingY#-0.8888888
EndIF
`Setting Moving DIrection at 165 degree
IF Image_Flying = 6034
FlyingX# = FlyingX#-3.4444444
FlyingY# = FlyingY#-0.6666666
EndIF
`Setting Moving DIrection at 170 degree
IF Image_Flying = 6035
FlyingX# = FlyingX#-3.6666666
FlyingY# = FlyingY#-0.4444444
EndIF
`Setting Moving DIrection at 175 degree
IF Image_Flying = 6036
FlyingX# = FlyingX#-3.8888888
FlyingY# = FlyingY#-0.2222222
EndIF
`Setting Moving Direction at 180 degree
IF Image_Flying = 6037
FlyingX# = FlyingX#-4 : FlyingY# = FlyingY#
EndIF
`Setting Moving DIrection at 185 degree
IF Image_Flying = 6038
FlyingX# = FlyingX#-3.8888888
FlyingY# = FlyingY#+0.2222222
EndIF
`Setting Moving DIrection at 190 degree
IF Image_Flying = 6039
FlyingX# = FlyingX#-3.6666666
FlyingY# = FlyingY#+0.4444444
EndIF
`Setting Moving DIrection at 195 degree
IF Image_Flying = 6040
FlyingX# = FlyingX#-3.4444444
FlyingY# = FlyingY#+0.6666666
EndIF
`Setting Moving DIrection at 200 degree
IF Image_Flying = 6041
FlyingX# = FlyingX#-3.2222222
FlyingY# = FlyingY#+0.8888888
EndIF
`Setting Moving DIrection at 205 degree
IF Image_Flying = 6042
FlyingX# = FlyingX#-3
FlyingY# = FlyingY#+1
EndIF
`Setting Moving DIrection at 210 degree
IF Image_Flying = 6043
FlyingX# = FlyingX#-2.8888888
FlyingY# = FlyingY#+1.2222222
EndIF
`Setting Moving DIrection at 215 degree
IF Image_Flying = 6044
FlyingX# = FlyingX#-2.6666666
FlyingY# = FlyingY#+1.4444444
EndIF
`Setting Moving DIrection at 220 degree
IF Image_Flying = 6045
FlyingX# = FlyingX#-2.4444444
FlyingY# = FlyingY#+1.6666666
EndIF
`Setting Moving DIrection at 225 degree
IF Image_Flying = 6046
FlyingX# = FlyingX#-2.2222222
FlyingY# = FlyingY#+1.8888888
EndIF
`Setting Moving DIrection at 230 degree
IF Image_Flying = 6047
FlyingX# = FlyingX#-2
FlyingY# = FlyingY#+2
EndIF
`Setting Moving DIrection at 235 degree
IF Image_Flying = 6048
FlyingX# = FlyingX#-1.8888888
FlyingY# = FlyingY#+2.2222222
EndIF
`Setting Moving DIrection at 240 degree
IF Image_Flying = 6049
FlyingX# = FlyingX#-1.6666666
FlyingY# = FlyingY#+2.4444444
EndIF
`Setting Moving DIrection at 245 degree
IF Image_Flying = 6050
FlyingX# = FlyingX#-1.4444444
FlyingY# = FlyingY#+2.6666666
EndIF
`Setting Moving DIrection at 250 degree
IF Image_Flying = 6051
FlyingX# = FlyingX#-1.2222222
FlyingY# = FlyingY#+2.8888888
EndIF
`Setting Moving DIrection at 255 degree
IF Image_Flying = 6052
FlyingX# = FlyingX#-1
FlyingY# = FlyingY#+3
EndIF
`Setting Moving DIrection at 260 degree
IF Image_Flying = 6053
FlyingX# = FlyingX#-0.8888888
FlyingY# = FlyingY#+3.2222222
EndIF
`Setting Moving DIrection at 265 degree
IF Image_Flying = 6054
FlyingX# = FlyingX#-0.6666666
FlyingY# = FlyingY#+3.4444444
EndIF
`Setting Moving Direction at 270 degree
IF Image_Flying = 6055
FlyingX# = FlyingX# : FlyingY# = FlyingY#+4
EndIF
`Setting Moving DIrection at 275 degree
IF Image_Flying = 6056
FlyingX# = FlyingX#+0.6666666
FlyingY# = FlyingY#+3.4444444
EndIF
`Setting Moving DIrection at 280 degree
IF Image_Flying = 6057
FlyingX# = FlyingX#+0.8888888
FlyingY# = FlyingY#+3.2222222
EndIF
`Setting Moving DIrection at 285 degree
IF Image_Flying = 6058
FlyingX# = FlyingX#+1
FlyingY# = FlyingY#+3
EndIF
`Setting Moving DIrection at 290 degree
IF Image_Flying = 6059
FlyingX# = FlyingX#+1.2222222
FlyingY# = FlyingY#+2.8888888
EndIF
`Setting Moving DIrection at 295 degree
IF Image_Flying = 6060
FlyingX# = FlyingX#+1.4444444
FlyingY# = FlyingY#+2.6666666
EndIF
`Setting Moving DIrection at 300 degree
IF Image_Flying = 6061
FlyingX# = FlyingX#+1.6666666
FlyingY# = FlyingY#+2.4444444
EndIF
`Setting Moving DIrection at 305 degree
IF Image_Flying = 6062
FlyingX# = FlyingX#+1.8888888
FlyingY# = FlyingY#+2.2222222
EndIF
`Setting Moving DIrection at 310 degree
IF Image_Flying = 6063
FlyingX# = FlyingX#+2
FlyingY# = FlyingY#+2
EndIF
`Setting Moving DIrection at 315 degree
IF Image_Flying = 6064
FlyingX# = FlyingX#+2.2222222
FlyingY# = FlyingY#+1.8888888
EndIF
`Setting Moving DIrection at 320 degree
IF Image_Flying = 6065
FlyingX# = FlyingX#+2.4444444
FlyingY# = FlyingY#+1.6666664
EndIF
`Setting Moving DIrection at 325 degree
IF Image_Flying = 6066
FlyingX# = FlyingX#+2.6666666
FlyingY# = FlyingY#+1.4444444
EndIF
`Setting Moving DIrection at 330 degree
IF Image_Flying = 6067
FlyingX# = FlyingX#+2.8888888
FlyingY# = FlyingY#+1.2222222
EndIF
`Setting Moving DIrection at 335 degree
IF Image_Flying = 6068
FlyingX# = FlyingX#+3
FlyingY# = FlyingY#+1
EndIF
`Setting Moving DIrection at 340 degree
IF Image_Flying = 6069
FlyingX# = FlyingX#+3.2222222
FlyingY# = FlyingY#+0.8888888
EndIF
`Setting Moving DIrection at 345 degree
IF Image_Flying = 6070
FlyingX# = FlyingX#+3.4444444
FlyingY# = FlyingY#+0.6666666
EndIF
`Setting Moving DIrection at 350 degree
IF Image_Flying = 6071
FlyingX# = FlyingX#+3.6666666
FlyingY# = FlyingY#+0.4444444
EndIF
`Setting Moving DIrection at 355 degree
IF Image_Flying = 6072
FlyingX# = FlyingX#+3.8888888
FlyingY# = FlyingY#+0.2222222
EndIF
`--- Wraping the Flying Spacecraft to secreen ---
IF FlyingX# < 0 THEN FlyingX# = 640
IF FlyingX# >640 THEN FlyingX# = 0
IF FlyingY# < 0 THEN FlyingY# = 480
IF FlyingY# > 480 THEN FlyingY# =0
`--- Ensuring the Flying Spacecraft rotates properly on screen ---
IF Image_Flying < 6001 THEN Image_Flying = 6072
IF Image_Flying > 6072 THEN Image_Flying = 6001
IF Leftkey()=1 THEN Image_Flying = Image_Flying+1
IF Rightkey()=1 THEN Image_Flying = Image_Flying-1
`--- Changing the sprite of Landed Spacecraft to Flying Spacecraft ---
Sprite SPR_Flying,FlyingX#,FlyingY#,Image_Flying
Show Sprite SPR_Flying
`--- Deleting unwanted sprites when flying ---
Hide Sprite SPR_Landed
Hide Sprite SPR_Moon(0)
`--- Changing Flying Spacecraft to Landed Spacecraft (Not working...) ---
For Saved = 1 to 12
HitMoon = Sprite Collision(SPR_Flying,SPR_Moon(Saved))
IF HitMoon > 0
SPR_Moon(Hide) = SPR_Moon(Saved)
Safe = 1
Exit
EndIF
Next Saved
IF Safe=1
Moon_x0# = Sprite X(SPR_Moon(Hide))
Moon_y0# = Sprite Y(SPR_Moon(Hide))
remstart
CurrentX$ = str$(FlyingX#)
CurrentY$ = str$(FlyingY#)
LandedX# = val(CurrentX$)
LandedY# = val(CurrentY$)
remend
Show Sprite SPR_Moon(0)
Set Sprite Priority SPR_Moon(0),1
Show Sprite SPR_Landed
Set Sprite Priority SPR_Landed,2
`Hide Sprite SPR_Moon(Hide)
Hide Sprite SPR_Flying
Flying=0
Landed=1
EndIF
remstart
For hit = 0 to 11
hitnum = Sprite Hit(SPR_Flying, SPR_Asteroid(hit))
IF hitnum>0 then exit
Next hit
Crashed=hitnum
IF Crashed=1 && Landed=0 && Explode=0
ExplosionX# = Sprite X(Crashed)
ExplosionY# = Sprite Y(Crashed)
Explode=1
EndIF
IF Explode=1
Sprite SPR_Explosion,ExpolsionX#,ExplosionY#,Image_Explode
Show Sprite SPR_Explosion
`scale sprite 5,50
Image_Explode = Image_Explode+1
IF Image_Explode>9
Explode=0
Image_Explode=1
Flying=0
Hide Sprite SPR_Explosion
Sprite Crashed,-100,-100,Crashed+20
sprite 4,-100,-100,30
ExplosionX#=-100
Crashed=0
Goto _TitlePage
EndIF
EndIF
remend
ENDIF
print
Print
Print Space$(06); "Landed: "; Landed
Print
Print Space$(06); "Flying: "; Flying
Print
Print Space$(06); "Safe: "; Safe
Print
Print Space$(06); "HitMoon: "; HitMoon
Print
Print Space$(06); "Safe(1): "; Safe(1)
print
Print Space$(06); "Safe(2): "; Safe(2)
print
Print Space$(06); "Safe(3): "; Safe(3)
print
Print Space$(06); "Safe(4): "; Safe(4)
print
Print Space$(06); "Safe(5): "; Safe(5)
print
Print Space$(06); "Safe(6): "; Safe(6)
print
Print Space$(06); "Safe(7): "; Safe(7)
print
Print Space$(06); "Safe(8): "; Safe(8)
print
Print Space$(06); "Safe(9): "; Safe(9)
print
Print Space$(06); "Safe(10): "; Safe(10)
print
Print Space$(06); "Safe(11): "; Safe(11)
print
Print Space$(06); "Safe(12): "; Safe(12)
`remend
EndIF
`IF SpaceKey()=1 THEN Level001=0
IF Level001=0
Delete Image Background001 : Level002=1
EndIF
IF Level002=1 THEN GOTO _LevelTwo
Sync : `This line very important! MUST PUT AT THE END OF EVERY BRANCH!!!
loop