News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Very basic lunar lander

Started by monkeybot, October 27, 2009, 11:07:09 AM

Previous topic - Next topic

monkeybot

PlayBASIC Code: [Select]
; PROJECT : luna landa
; AUTHOR : Monkybot
; CREATED : 08/10/2009
; EDITED : 27/10/2009
; ---------------------------------------------------------------------
restart:
explicit on
screenvsync off
global gamespeed=40 ;higher =slower
global g#=0.25 ;gravity

dim pad(100)
global gamestatus=0

global screenwidth=getscreenwidth()
global screenHeight=getscreenHeight()

constant offset=200
global mapwidth=2000

global numOfElements,padcount

global gametimer=timer()

constant shipscale=3

global foreground1


type landvar
x
y
endtype

type landingPad
x
y
width
height
status
shapeNo
endtype

type playerType
x#
y#
xmom#
ymom#
thrust#
endtype

dim land(10000) as landvar
dim lPad as landingpad list
dim player as playerType
player.x#=400
player.y#=100
cls 0
print "mapwidth="+str$(mapwidth)
Print "Very Simple unfinished Lunar Lander by Monkeybot using randomly generated landscapes."
print ""
print "use cursors for sideways movement and Space bar to thrust"
print "hit all the pads to complete the game(not that much happens)"
numOfElements,padcount=generateLand(10,50,10,300) ;;minx span ,max x span,miny span ,max y span,
print "Number of pads is......"+str$(padcount)
print "Press any key to play"
drawland3(0,300,1)
makepads()
drawpads2(300)
sync
waitnokey
waitkey


global landShape= GetFreeShape()
createshape landShape,numOfElements+10,numOfElements+5
makeshape()
foreground1=getfreeshape()
copyshape landShape,foreground1
ScaleShapeXY foreground1,1,0.7
global ship=GetFreeShape()
CreateShape ship,9,9
global NumOfPadsLeft
makeship()


repeat
cls 0

drawLandShapes()
ink $ff0000
NumOfPadsLeft=drawpads()
if numOfpadsLeft=0 then gamestatus=3
ink $ffffff
drawshape ship,screenwidth/2,player.y#,1
linec screenwidth/2,player.y#+6,screenwidth/2,(player.y#+6)+player.thrust#,$ff0000 ;engine flame

print "Num Of Pads Left="+str$(NumOfPadsLeft)
print "Game running at :"+str$(fps())+" fps"
sync
if timer()>gametimer
checkkeys2()
physics2()
gametimer=timer()+gamespeed
checkColl()
endif
until gamestatus<>0
cls 0
select gamestatus
case 1
print "hit land"
case 2
print "hit pad too hard"
case 3
print "!!!!!YOU DID IT !!!!!"
print "!!!WOOOOOOOOOOOOO!!!!"
endselect
print "press any key to restart"
sync
waitnokey
waitkey
goto restart
end

Function checkColl()
local hit
hit=ShapeHitShape (ship,(screenwidth/2)-2,player.y#,landshape,-player.x,offset )
if hit=1 then gamestatus=1
local x,y,count
for each lpad()
x=lpad.x-player.x#
y=lpad.y
if shapehitshape (ship,(screenwidth/2)-5,player.y#,lpad.shapeNo,x,y+offset )and lpad.status=0
lpad.status=1
if player.ymom# <- 4 then gamestatus=2
endif
next
EndFunction


Function drawPads()
local x,y,count,padcount,scale#=1
for each lpad()
x=lpad.x-player.x#
y=lpad.y
if lpad.status=0
drawshape lpad.shapeNo,x,(y+offset),2
inc padcount
endif
next
Login required to view complete source code



ATLUS