REM Start of BASIC! Program ! lunar.bas ! Lunar lander game ! by mookiebearapps ! GR.OPEN 255,0,0,0 GR.SCREEN w,h FN.DEF game(demo,fuel) GR.SCREEN aw,ah w=1280:h=720 Sx=aw/w:Sy=ah/h GR.SCALE sx,sy GR.COLOR 255,255,255,255 mh1=20:mh2=0:mw=100 GR.COLOR 255,255,0,0 GR.TEXT.SIZE h/20 GR.TEXT.DRAW nofuel,w/10,h/10,"out of fuel" GR.HIDE nofuel GR.COLOR 255,255,255,255 fuel=500 x=0 GR.LINE l,x-mw,h-mh1,x,h-mh2 GR.SHOW l GR.GROUP m,l GR.GET.VALUE m,"list",mlist GR.POINT st,-mw,0 GR.SHOW st GR.GROUP s,st GR.GET.VALUE s,"list",slist GR.COLOR 255,0,0,255 GR.SET.STROKE 3 px=3*w/4 py=h/4 pw=50 vx=0 vy=0 acc=0.03 thrust=0.08 IF !demo GR.BITMAP.LOAD lander_obj, "lander.png" pw=h/15 GR.BITMAP.SCALE lander,lander_obj,pw,pw GR.BITMAP.DRAW player,lander,px,py GR.SHOW player ENDIF DO GR.MOVE m,5,0 GR.MOVE s,2,0 vy+=acc GR.TOUCH t,xx,yy IF demo & t THEN d_u.break IF t & fuel vy-=thrust:fuel-- IF !fuel THEN GR.SHOW nofuel endif IF !demo GR.MOVE player,vx,vy LIST.SIZE mlist,z GR.GET.VALUE player,"x",left,"y",bottom bottom+=pw:left+=pw/2 FOR I=1 TO z LIST.GET mlist,i,mm GR.GET.VALUE mm,"x1",x1,"y1",y1,"x2",x2,"y2",y2 IF left>=x1 & left<=x2 & bottom>(y2-y1)*(left-x1)/(x2-x1)+y1 land=1 IF y1=y2 THEN win=1 ENDIF IF land THEN F_N.BREAK NEXT ENDIF LIST.SIZE mlist,z LIST.GET mlist,z,l GR.GET.VALUE l,"x1",x,"y1",y1 IF x>0 LET mw=RND()*100+50 LET mh3=RND()*300 GR.COLOR 255,255,255,255 LET flat=(FLOOR(RND()*5)=1) IF flat GR.COLOR 255,0,255,0 GR.SET.STROKE 6 GR.LINE l2,-mw,y1,2,y1 ELSE GR.LINE l2,-mw,h-mh3,2,y1 ENDIF GR.SHOW l2 LIST.ADD mlist,l2 LET starx=-RND()*mw LET stary=RND()*MIN(h-mh3,y1) GR.SET.STROKE 2 GR.COLOR rnd()*255,255,255,255 GR.POINT st,starx,stary GR.SHOW st LIST.ADD slist,st ENDIF LIST.GET mlist,1,ll GR.GET.VALUE ll,"x1",x1 IF x1>w+300 GR.HIDE ll LIST.REMOVE mlist,1 ENDIF LIST.GET slist,1,ll GR.GET.VALUE ll,"x",x1 IF x1>w+300 GR.HIDE ll LIST.REMOVE slist,1 ENDIF GR.RENDER UNTIL land LIST.CLEAR slist LIST.CLEAR mlist FN.RTN win FN.END ! main GR.SCREEN w,h GR.TEXT.SIZE h/5 GR.COLOR 255,0,255,0 GR.TEXT.ALIGN 2 GR.TEXT.DRAW ttl,w/2,h/2,"touch to begin" GR.SHOW ttl game(1,&fuel) GR.HIDE ttl again: GR.CLS win=game(0,&fuel) GR.TEXT.SIZE h/12 GR.COLOR 255,0,255,0 IF win GR.TEXT.DRAW txt,w/2,h/2,"safe landing... fuel="+INT$(fuel) ELSE GR.COLOR 255,255,0,0 GR.TEXT.DRAW txt, w/2,h/2,"you crashed!" ENDIF FOR I=1 TO 100 GR.MOVE txt,-2,-1 GR.MODIFY txt,"alpha",I*2.5 GR.RENDER NEXT PAUSE 2000 DIALOG.MESSAGE "play again?","",c,"yes","no" IF c=1 THEN GOTO again gr.close EXIT