| 
      
        | Posted: 09:52pm 06 Jul 2020 |  |  |  |  Lunar converted. Use 5.05.04b3d just posted to correct minor colour issue
 
 
 'Lunar Lander for Colour Maximite v4.0'
 option legacy on
 Option Base 1
 Clear
 'Array declaration
 Dim Tevel(MM.HRes)
 Dim BoosterSpr(2)
 Dim ExplodeSpr(5)
 Dim PlatformLSpr(5)
 Dim PlatformRSpr(5)
 Dim FootPix(2)
 'Set 240 x 216 8 colours resolution
 mode 5
 'We get the Sprites from file
 'Drive "b:"
 Sprite Load "Lunar.spr"
 'Sprite declaration
 LanderSpr = 1
 BoosterSpr(1) = 2 : BoosterSpr(2) = 3
 For a = 1 To 5
 ExplodeSpr(a) = a + 3
 PlatformLSpr(a) = a + 8
 PlatformRSpr(a) = a + 13
 Next a
 FootPix(1) = 0 : FootPix(2) = 0
 '1st animated Sprite per type
 PlatFormSprNum = 1
 NextPlatSprnum=2
 ExplodeSprNum = 1
 BoosterSprNum = 1
 'Set the Joystick pin's
 'PIN 11 = UP (Booster)
 SetPin 11,din,pullup
 'PIN 13 = LEFT
 SetPin 13,din,pullup
 'PIN 12 = RIGHT
 SetPin 12,din,pullup
 'Set some variables
 Booster = 0
 LemSpeed = 0.1
 SpeedX = 0.0
 Fuel = 25.0
 Gravity = 1.63
 GoRight = 0 : GoUp = 0 : GoLeft = 0
 Score = 0
 PixLeft = 0
 PixRight = 0
 GMx = MM.HRes - 1
 GMy = MM.VRes - 1
 Print @(70,100) "Press a key to Start"
 Do While (Inkey$ = "") And (Pin(11) = 1) And (Pin(13) = 1) And (Pin(12) = 1)
 Loop
 Cls
 'Randomize Timer
 'Landing platform position
 Platformx = Int(Rnd * (GMx -60)) + 20
 Platformy = Int(Rnd * 80) + (GMy - 80)
 'Here we draw the terrain and the Landing platform
 Sprite show PlatformLSpr(PlatFormSprNum) , Platformx , Platformy,1
 Sprite show PlatformRSpr(PlatFormSprNum) , Platformx + 16, Platformy,1
 'Terrain at Left from the platform
 py = Platformy + (Rnd * 7) - 3
 For a = Platformx - 1 To 0 Step - 1
 py = py + (Rnd * 7) - 3
 Line (a,GMy) - (a,py),3
 Tevel(a) = py
 Next a
 'Terrain at Right from the platform
 py = Platformy + (Rnd * 7) - 3
 For a = Platformx + 33 To GMx
 py = py + (Rnd * 7) - 3
 Line (a,GMy) - (a,py),3
 Tevel(a) = py
 Next a
 'Terrain under the platform
 For a = Platformx To Platformx + 32
 Line (a,GMy) - (a,Platformy + 6),3
 Next a
 'LEM position at start
 LemX = Rnd * (GMx - 60) + 20
 LemY = Rnd * 50 + 25
 'Show the LEM
 Sprite show LanderSpr , LemX , LemY,1
 BoosterWas1 = 0
 'Initialise the platform sprite counter
 PlatformCount = 0
 'Next load's will be from drive "a:"
 Mod_is_playing = 0
 Timer = 0
 'Main program loop
 Do While 1
 'Read the buttons
 keypressed = keydown(1)
 If (Pin(11) = 0) Or keypressed = 128) Then GoUP = 1
 If (Pin(12) = 0) Or keypressed = 131) Then GoRight = 1
 If (Pin(13) = 0) Or keypressed = 130) Then GoLeft = 1
 '
 'Test if we are over the platform
 If LemY > (Platformy - 17) Then
 'Test if we have landed or Collided
 If (LemX >= Platformx) And (Lemx < (Platformx + 16)) Then
 'Landing test
 If LemSpeed <= 2.0 Then
 If Mod_is_playing = 1 Then
 Play Stop
 EndIf
 play modfile "landed.mod"
 Print @(75,50) "Successfully Landed"
 Pause 2000
 Run
 Else
 If BoosterWas1 = 1 Then
 Sprite hide BoosterSpr(BoosterSprNum)
 EndIf
 If Mod_is_playing = 1 Then
 Play Stop
 EndIf
 Play modfile  "explode.mod"
 Sprite hide LanderSpr
 For a = 1 To 5
 Sprite show ExplodeSpr(a) , LemX , LemY,1
 Pause 100
 Sprite hide ExplodeSpr(a)
 Next a
 Print @(80,50) "You Crashed !!!"
 Pause 2000
 Run
 EndIf
 EndIf
 EndIf
 'We check collision with the Terrain
 FootPix(1) = Pixel(LemX,LemY + 16)
 FootPix(2) = Pixel(LemX + 15,LemY + 16)
 If (FootPix(1) <> 0) Or (FootPix(2) <> 0) Then
 If BoosterWas1 = 1 Then
 Sprite hide BoosterSpr(BoosterSprNum)
 EndIf
 Sprite hide LanderSpr
 If Mod_is_playing = 1 Then
 Play Stop
 EndIf
 Play modfile "explode.mod"
 For a = 1 To 5
 Sprite show ExplodeSpr(a) , LemX , LemY,1
 Pause 100
 Sprite hide ExplodeSpr(a)
 Next a
 Print @(80,50) "You Crashed !!!"
 Pause 2000
 Run
 EndIf
 If Timer >= 100 Then
 'Timer routine every 100mS
 PlatformCount = PlatformCount + 1
 Recompute
 Redraw
 Timer = 0
 EndIf
 Loop
 
 Sub Recompute
 'This part is executed every 100mS
 LEMSpeed = LEMSpeed + (Gravity * 0.1)
 If (GoUP = 1) And (Fuel > 0) Then
 LemSpeed = LemSpeed - (Gravity * 0.2)
 Fuel = Fuel - 0.3
 GoUp = 0
 Booster = 1
 Else
 Booster = 0
 EndIf
 If (GoRight = 1) And (Fuel > 0) Then
 Vx = Vx + 0.1
 Fuel = Fuel - 0.1
 GoRight = 0
 EndIf
 If (GoLeft = 1) And (Fuel > 0) Then
 Vx = Vx - 0.1
 Fuel = Fuel - 0.1
 GoLeft = 0
 EndIf
 'Record the LEM position
 OldLemX = Int(LemX) : OldLemY = Int(LemY)
 LemY = Int(LemY + LemSpeed)
 LemX = Int(LemX + Vx)
 'Clip the LEM in the screen
 If LemX > (GMx - 17) Then LemX = GMx - 17
 If LemX < 5 Then LemX = 5
 If LemY > (GMy - 17) Then LemY = GMy - 17
 If LemY < 50 Then LemY = 50
 End Sub
 
 Sub Redraw
 'This part is executed every 100mS
 Print @(0,0) "Speed " @(35,0) Str$(Int(LemSpeed)) + " "
 Print @(100,0) "Fuel "@(135,0) Str$(Int(Fuel)) + " "
 'Check if we have to erase the booster
 If BoosterWas1 = 1 Then
 Sprite hide BoosterSpr(BoosterSprNum)
 BoosterWas1 = 0
 Else
 If Mod_is_playing = 1 Then
 Play Stop
 Mod_is_playing = 0
 EndIf
 EndIf
 'We redraw the LEM
 Sprite show LanderSpr , LemX , LemY,1
 ' Draw the Booster if needed
 If Booster = 1 Then
 If Mod_is_playing = 0 Then
 Play modfile "turbine.mod"
 Mod_is_playing = 1
 EndIf
 BoosterSprNum = BoosterSprNum + 1
 If BoosterSprNum > 2 Then BoosterSprNum = 1
 Sprite show BoosterSpr(BoosterSprNum) , LemX + 5 , LemY + 12,1
 Booster = 0
 BoosterWas1 = 1
 EndIf
 'Cycle the platform Sprites evey 300mS
 If PlatformCount = 3 Then
 Sprite swap PlatformRSpr(PlatFormSprNum),PlatformRSpr(NextPlatSprnum)
 Sprite swap PlatformLSpr(PlatFormSprNum),PlatformLSpr(NextPlatSprnum)
 PlatFormSprNum = PlatFormSprNum + 1
 If PlatFormSprNum > 5 Then PlatFormSprNum = 1
 NextPlatSprnum = NextPlatSprnum + 1
 if NextPlatSprnum > 5 then NextPlatSprnum = 1
 PlatformCount = 0
 EndIf
 End Sub
 
 Sprite file
 
 
 16,18
 22222222
 2111111112
 216666666612
 21666111166612
 2266613333166622
 2116613333166112
 2666613333166662
 2116662222666112
 2666111111116662
 1111 111111 1111
 222  1111  222
 22        22
 2          2
 2          2
 222        222
 664646
 466464
 6464
 66
 
 
 
 
 
 
 
 
 
 
 
 
 466464
 644646
 4646
 46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 6
 
 64    6 4
 4466
 664646
 6 6644646
 4 646666
 6  6646 6
 4
 4  6
 
 
 
 
 4   6
 6 4     6
 6    6     4
 4
 64    6 466
 4    6666  6
 6666666
 6446446466
 4666646646 6
 6646666 6
 6646
 6 46 466  4
 4  6
 6 4       6
 
 
 64   6
 6 6      466
 6 44     4 4
 4 444 6
 66    664
 4   66666 6
 6  6666
 644 4  466
 466664 646 6
 6    66 6666 6
 4   66464
 66   466  4
 4      4
 6 46     6
 
 
 4      6
 46 6      446
 6 6
 464
 6     64
 4         6
 6   6 6
 64 6   66
 4       4  4
 6 6  6     6
 4    6 64
 6   46   46
 4
 46     6
 
 
 4
 4  46
 
 6
 6       4
 
 4
 4 6        6
 4
 6
 4
 4
 6  4 6
 4
 
 3222222222222222
 2222222222222222
 1277744447777444
 1277744447777444
 1222222222222222
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3222222222222222
 2222222222222222
 1277774444777744
 1277774444777744
 1222222222222222
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3222222222222222
 2222222222222222
 1247777444477774
 1247777444477774
 1222222222222222
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3222222222222222
 2222222222222222
 1244777744447777
 1244777744447777
 1222222222222222
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3222222222222222
 2222222222222222
 1244477774444777
 1244477774444777
 1222222222222222
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 2222222222222223
 2222222222222222
 4777744447777421
 4777744447777421
 2222222222222221
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 2222222222222223
 2222222222222222
 4477774444777721
 4477774444777721
 2222222222222221
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 2222222222222223
 2222222222222222
 4447777444477721
 4447777444477721
 2222222222222221
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 2222222222222223
 2222222222222222
 4444777744447721
 4444777744447721
 2222222222222221
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 2222222222222223
 2222222222222222
 7444477774444721
 7444477774444721
 2222222222222221
 1111111111111111
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 3333333333333333
 
 Edited 2020-07-07 07:55 by matherp
 |