TGC Codebase Backup



moonlander by Rasdini

29th Mar 2004 18:33
Summary

Moon lander game(newer version)-no media required



Description

moonlanding game



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: moonlander
Rem Created: 3/25/04 8:54:00 AM

Rem ***** Main Source File *****
rem This program written by Richard Sardini, E-mail:noramdia@adelphia.net
rem My telephone #:814-504-6033


cls:set display mode 800,600,16
set cursor screen width()/2-30,0
print "Welcom to Lunar Lander written by Richard Sardini"
print " ":print "Use shift key or joystick fire(A) for main thrusters."
print "Use the arrow keys or joystick directions to fire your directional thrusters."
print "Get bonus fuel above landing pads.  I wouldn't worry too hard"
print "about the bonus fuel if I were you."
print "I programmed no boundaries, so don't fly off the map if you can help it."
print "You must land on all 10 pads to move on to the next level."
print "The mountains get higher and the fuel more valuable."
print "You will receive 200 gallons on each landing pad."
print "Don't miss one as you will probably never make it back."
print "Also, you carry leftover fuel as well as you 200 on each pad."
print "Just keep in mind, the more fuel you carry, the heavier you are."
print "Press 'P' key or joystick fire(B) anytime to pause and any other key to continue."
print "Press any key to start, and escape key anytime to quit."

redoinput:
if joystick fire a()=1 then goto startnow
if inkey$()="" then goto redoinput
startnow:
sleep 100

create bitmap 1,50,50
ink RGB(0,128,64),0
for x=0 to 50:line x,0,x,50:next x
for x=128 to 255:ink rgb(128,64,x-128),0:for y=0 to 8:dot rnd(50),rnd(50):next y:next x
ink rgb(0,0,0),0:for x=0 to 100:dot rnd(50),rnd(50):next x
ink RGB(0,255,0),0:for x=0 to 50:dot rnd(50),rnd(50):next x
ink RGB(255,0,255),0:for x=0 to 20:dot rnd(50),rnd(50):next x
get image 1,0,0,50,50
delete bitmap 1

create bitmap 1,50,50
ink RGB(0,255,0),0:for x=0 to 50:line x,0,x,50:next x
ink RGB(255,128,0),0:for x=12 to 15:circle 25,25,x:next x
ink RGB(128,128,128),0:for x=0 to 150:dot rnd(50),rnd(50):next x
get image 3,0,0,50,50
delete bitmap 1

create bitmap 1,50,50
ink RGB(123,65,233),0:for x=0 to 50:line x,0,x,50:next x
ink RGB(40,189,85),0:line 20,20,20,40:line 20,20,40,20:line 20,30,35,30
get image 4,0,0,50,50
delete bitmap 1

create bitmap 1,50,50
ink rgb(255,255,255),0:for x=0 to 50:line x,0,x,50:next x
get image 2,0,0,50,50
delete bitmap 1
cls

make matrix 1,11000.0,11000.0,100.0,100.0
color backdrop rgb(0,0,0)
position matrix 1,0.0,0.0,0.0
hide mouse
sync on
autocam off
randomize matrix 1,300
height=50
update matrix 1
prepare matrix texture 1,1,2,2
make object sphere 1,10:make object cube 2,10:make object cylinder 3,10:make object cone 4,10
for x=1 to 4:make mesh from object x,x:delete object x:next x

make object cube 10,50
y#=get ground height(1,200,200)
color object 10,RGB(49,145,131)
position object 10,200,y#+20,200
y=1
for x=1000 to 10000 step 1000
make object cube 10+y,50
position object 10+y,x+rnd(600)-300,0,x+rnd(600)-300
y1#=get ground height(1,object position x(10+y),object position z(10+y))
position object 10+y,object position x(10+y),y1#+20,object position z(10+y)
texture object 10+y,3
make object sphere 30+y,30
position object 30+y,object position x(10+y)+rnd(100)-50,300+object position y(10+y),object position z(10+y)+rnd(100)-50
texture object 30+y,4
inc y
next x

make object sphere 1,20
add limb 1,1,4:offset limb 1,1,0,-10,0
add limb 1,2,3:offset limb 1,2,0,10,0
add limb 1,3,1:offset limb 1,3,0,15,0
add limb 1,4,3:scale limb 1,4,20,250,20:offset limb 1,4,6,-11,6
add limb 1,5,3:scale limb 1,5,20,250,20:offset limb 1,5,6,-11,-6
add limb 1,6,3:scale limb 1,6,20,250,20:offset limb 1,6,-6,-11,6
add limb 1,7,3:scale limb 1,7,20,250,20:offset limb 1,7,-6,-11,-6
for x=8 to 11
add limb 1,x,4:scale limb 1,8,80,80,80
next x
offset limb 1,8,0,0,-12:rotate limb 1,8,-90,0,0
offset limb 1,9,12,0,0:rotate limb 1,9,0,0,-90
offset limb 1,10,0,0,12:rotate limb 1,10,90,0,0
offset limb 1,11,-12,0,0:rotate limb 1,11,0,0,90

color object 1,RGB(255,0,0):color limb 1,1,RGB(208,217,216)
color limb 1,2,RGB(109,147,243):color limb 1,3,RGB(253,202,108)
for x=8 to 11:color limb 1,x,rgb(208,217,216):next x
position object 1,object position x(10),object position y(10)+50,object position z(10)

make particles 1,2,20,30
rotate particles 1,0,45,0:set particle emissions 1,0:set particle gravity 1,0
set particle velocity 1,40
set particle life 1,10:color particles 1,255,0,0

make particles 2,2,20,20
set particle emissions 2,0:set particle velocity 2,50:set particle gravity 2,0
set particle life 2,10:color particles 2,255,0,0

make particles 3,2,20,20
set particle emissions 3,0:set particle velocity 3,50:set particle gravity 3,0
set particle life 3,10:color particles 3,255,0,0

make particles 4,2,20,20
set particle emissions 4,0:set particle velocity 4,50:set particle gravity 4,0
set particle life 4,10:color particles 4,255,0,0

make particles 5,2,20,20
set particle emissions 5,0:set particle velocity 5,50:set particle gravity 5,0
set particle life 5,10:color particles 5,255,0,0






landed=1:spdz#=0:spdx#=0:fuel#=200:dim marker(20):for x=11 to 20:marker(x)=0:next x
vt#=0:xpos#=object position x(1):ypos#=object position y(1):zpos#=object position z(1)

make camera 1
set camera range 1,1,100000
set camera view 1,600,20,750,170
color backdrop 1,RGB(81,66,79)
make camera 2
set camera range 2,1,100000
set camera view 2,600,200,750,350
color backdrop 2,rgb(81,66,79)
make camera 3
set camera range 3,1,100000
set camera view 3,600,400,750,550
color backdrop 3,rgb(81,66,79)

yoff#=0:yinc#=-.5
do

check=0
for x=11 to 20:if marker(x)=1 then inc check
next x
if check=10
   set cursor screen width()/2-20,screen height()/3
   print "TRY MAKING IT NOW, WISE GUY"
   sync
   sleep 4000
   for y=1 to 10
   if object exist(30+y)=1 then delete object 30+y
   next y
   randomize matrix 1,300+height
   update matrix 1
   y=1
   for x=1000 to 10000 step 1000
   position object 10+y,x+rnd(600+height)-(300+height/2),0,x+rnd(600+height)-(300+height/2)
   y1#=get ground height(1,object position x(10+y),object position z(10+y))
   position object 10+y,object position x(10+y),y1#+20,object position z(10+y)
   make object sphere 30+y,30
   position object 30+y,object position x(10+y)+rnd(100)-50,300+object position y(10+y),object position z(10+y)+rnd(100)-50
   texture object 30+y,4
   inc y
   next x
   y#=get ground height(1,200,200)
   position object 10,200,y#+20,200
   position object 1,object position x(10),object position y(10)+50,object position z(10)
   xpos#=object position x(1):ypos#=object position y(1):zpos#=object position z(1)
   for x=11 to 20:marker(x)=0:next x:inc height,50
endif

position particles 2,limb position x(1,8)+spdx#,limb position y(1,8),limb position z(1,8)
position particles 3,limb position x(1,9),limb position y(1,9),limb position z(1,9)+spdz#
position particles 4,limb position x(1,10)+spdx#,limb position y(1,10),limb position z(1,10)
position particles 5,limb position x(1,11),limb position y(1,11),limb position z(1,11)+spdz#

if thdlay>0 then dec thdlay:goto skipthrust
if fuel#<=0 then fuel=0:for x=1 to 5:set particle emissions x,0:next x:goto skipthrust
if shiftkey()=1 or joystick fire a()=1
   dec fuel#,.25
   if vt#<8 then vt#=vt#+.0125
   color particles 1,0,0,255
   set particle emissions 1,5
   if landed=1 then landed=0
endif

if shiftkey()=0 and joystick fire a()=0
   set particle emissions 1,0
endif

if landed=1 then spdx#=0:spdz#=0:goto skipthrust
if landed=2 then spdx#=0:spdz#=0:goto skipthrust

if upkey()=1 or joystick up()=1
   dec fuel#,.125
   if spdz#<5 then inc spdz#,.0125
   rotate particles 2,-90,object angle y(1),object angle z(1)
   set particle emissions 2,3
endif

if upkey()=0 and joystick up()=0
   set particle emissions 2,0
endif


if downkey()=1 or joystick down()=1
   dec fuel#,.125
   if spdz#>-5 then dec spdz#,.0125
   rotate particles 4,90,object angle y(1),object angle z(1)
   set particle emissions 4,3
endif

if downkey()=0 and joystick down()=0
   set particle emissions 4,0
endif

if leftkey()=1 or joystick left()=1
   dec fuel#,.125
   if spdx#>-5 then dec spdx#,.0125
   rotate particles 3,object angle x(1),object angle y(1),-90
   set particle emissions 3,3
endif

if leftkey()=0 and joystick left()=0
   set particle emissions 3,0
endif

if rightkey()=1 or joystick right()=1
   dec fuel#,.125
   if spdx#<5 then inc spdx#,.0125
   rotate particles 5,object angle x(1),object angle y(1),90
   set particle emissions 5,3
endif

if rightkey()=0 and joystick right()=0
   set particle emissions 5,0
endif

skipthrust:

if landed=1 or landed=2 then goto crashing
t1=object collision(1,0)

inc yoff#,yinc#
if yoff#<0 or yoff#>150 then yinc#=yinc#*-1

for x=31 to 40
if object exist(x)=1
   turn object right x,2
   yo#=object position y(x)+yinc#
   position object x,object position x(x),yo#,object position z(x)
endif

if t1=x
   inc fuel#,30
   if particles exist(30)=0
      make particles 30,1,50,30
      position particles 30,object position x(x),object position y(x),object position z(x)
      color particles 30,38,111,230
      set particle emissions 30,60:set particle gravity 30,2
      set particle velocity 30,60
      fueldur=5
   endif
   delete object x
endif
next x

for x=11 to 20
if t1=x
   if vt#>=-.5
      if object position x(1)>object position x(x)-15 and object position x(1)<object position x(x)+15 and object position z(1)>object position z(x)-15 and object position z(1)<object position z(x)+15
         landed=1
         if marker(x)=0 then inc fuel#,200:vt#=0:marker(x)=1
         position object 1,object position x(1),object position y(x)+50,object position z(1)
         xpos#=object position x(1):ypos#=object position y(1):zpos#=object position z(1)
         thdlay=200
         for y=1 to 5:set particle emissions y,0:next y
      endif

      if object position x(1)<object position x(x)-15 or object position x(1)>object position x(x)+15 or object position z(1)<object position z(x)-15 or object position z(1)>object position z(x)+15
         landed=2
         if particles exist(10)=0
            make particles 10,1,50,50:color particles 10,226,185,15
            position particles 10,object position x(1),object position y(1),object position z(1)
            hide object 1
            set particle emissions 10,80:set particle gravity 10,5
            set particle velocity 10,60
            crshdur=5
            for y=1 to 5:set particle emissions y,0:next y
            for y=11 to 20:marker(y)=0:next y
         endif
      endif
   endif
   if landed=1 then goto skipvelcrash
   if vt#<-.5
      landed=2
      if particles exist(10)=0
         make particles 10,1,50,50:color particles 10,226,171,15
         position particles 10,object position x(1),object position y(1),object position z(1)
         hide object 1
         set particle emissions 10,80:set particle gravity 10,5
         set particle velocity 10,60
         crshdur=5
         for y=1 to 5:set particle emissions y,0:next y
         for y=11 to 20:marker(y)=0:next y
         for v=31 to 40
            if object exist(v)=0
               make object sphere v,30
               position object v,object position x(v-20)+rnd(100)-50,300+object position y(v-20),object position z(v-20)+rnd(100)-50
               texture object v,4
            endif
         next v
      endif
   endif
   skipvelcrash:
endif
next x

ey#=get ground height(1,object position x(1),object position z(1))
if object position y(1)<ey#+20
   landed=2
   if particles exist(10)=0
      make particles 10,1,50,50:color particles 10,226,171,15
      position particles 10,object position x(1),object position y(1),object position z(1)
      hide object 1
      set particle emissions 10,80:set particle gravity 10,5
      set particle velocity 10,60
      crshdur=5
      for y=1 to 5:set particle emissions y,0:next y
      for y=11 to 20:marker(y)=0:next y
      for v=31 to 40
         if object exist(v)=0
            make object sphere v,30
            position object v,object position x(v-20)+rnd(100)-50,300+object position y(v-20),object position z(v-20)+rnd(100)-50
            texture object v,4
         endif
      next v
   endif
endif

inc zpos#,spdz#
inc xpos#,spdx#

if landed=0
   if vt#>-5 then dec vt#,.0045+((fuel#/100000)-.002)
   inc ypos#,vt#
endif

crashing:

if landed=2
   inc crshdur
   color particles 10,226,141-crshdur,15
   set cursor object screen x(1),object screen y(1)+50
   print "HA HA HA HA HA HA!!"
   if crshdur>130
      delete particles 10
      landed=1:show object 1
      position object 1,object position x(10),object position y(10)+50,object position z(10)
      xpos#=object position x(1):ypos#=object position y(1):zpos#=object position z(1)
      fuel#=200:vt#=.4:set particle emissions 1,0:set particle emissions 2,0
   endif
endif

if particles exist(30)=1
   inc fueldur
   if fueldur>60 then delete particles 30
endif

position object 1,xpos#,ypos#,zpos#

position camera 0,object position x(1)-120,object position y(1)+180,object position z(1)-220
point camera 0,object position x(1),object position y(1),object position z(1)

position camera 1,object position x(1),object position y(1)+100,object position z(1)
point camera 1, object position x(1),object position y(1),object position z(1)

position camera 2,object position x(1)-75,object position y(1),object position z(1)-75
point camera 2, object position x(1),object position y(1),object position z(1)

position camera 3,object position x(1),object position y(1)+1000,object position z(1)
point camera 3, object position x(1),object position y(1),object position z(1)

position particles 1,object position x(1),object position y(1)-25,object position z(1)
rotate particles 1,0,0,180

alt#=(object position y(1)-get ground height(1,object position x(1),object position z(1)))-70

set cursor 0,0
ink rgb(255,255,255),0
print "FUEL LEVEL-->";fuel#
set cursor screen width()/2-30,0
print "LUNAR LANDER: BY: RICHARD SARDINI"
print "VERTICLE SPEED-->";vt#
print "ALTITUDE-->";int(alt#)
set cursor object screen x(1)+20,object screen y(1)-30
print "Alt->";int(alt#)
set cursor object screen x(1)+20,object screen y(1)
print "Fuel->";fuel#
ink RGB(255,255,0),0
line 599,19,751,19:line 598,18,752,18
line 599,19,599,551:line 598,18,598,552
line 599,551,751,551:line 598,552,752,552
line 751,19,751,551:line 752,18,752,552
line 600,171,751,171:line 600,199,751,199:line 600,351,751,351:line 600,399,751,399
if inkey$()="p" or joystick fire b()=1
   set cursor screen width()/2-10,screen height()/2+50
   print "!! GAME PAUSED !!":sync
   sleep 200
   pausewait:
   if joystick fire b()=1 then goto backtogame
   if inkey$()="" then goto pausewait
   backtogame:
   sleep 200
endif
sync
loop