News:

Function Finder  Find all the functions within source code files

Main Menu

Question about Lunar Lander Game?

Started by ScottieB, October 27, 2009, 10:37:22 AM

Previous topic - Next topic

ScottieB

I'm just started working on a lunar lander game.
I'm haveing trouble with the vector landscape.
I can't seem to make a good mountain ridge that the shuttle must not crach into.
Any ideas how this would be done?
Some source code would be nice.


Thanks,
Peace
and
out!

kevin


howdy Scottie,

What have you got so far ?

ScottieB

I just started fiddling around with playbasic it's vrey new to me.
I know I can get the spacehip with thrust/gravity/fuel and I know how to scroll the screen. Landing pads would just be a vector line but...

I just don't know how to program a nice landscape out of vectors that the ship must avoid beside that I think I could manage to program the rest.

So I looking for ideas/sourcecode/alogrthyms on how I could approach this problem.

kevin

#3
 Mid Point / Fractal


Bezier Curves


The world can build out of shapes/worlds (captured line segments) etc..

monkeybot

#4
Funnily enough i just wrote one.......


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
EndFunction padcount
Login required to view complete source code



ScottieB

Kewl! Thanks!
Oddly enough the bezier curves does'nt draw the curve. Is it me? or Is there something missing in the code? I only get four points and a line. No curve.

monkeybot

#6
its just using straight lines....
oh you mean the bezier....

i only get straight lines too. ???