hey guys, im brand new to dark basic, but this is what ive come up with so far, but im struggling to get my little character to walk ontop of the key.
what i want it to do is, for the character to get the key, and then for the door to appear once done for the level to be completed..
Any advice would be deeply appreciated.
and if u cud msn me at triggersgone@hotmail.com that would be superb
thanks alot, petey
` Project: platforms
` Created: 03/03/2009 16:29:07
` Aaron Haggerty
`***** Main Source File *****
`runin 2d
set display mode 800,600,32
hide mouse
cls
sync on
sync rate 15
`load media
backdrop off
load music "cry4u.mp3",55
play music 55
load bitmap "Dark_city.jpg",9
load image "pigstill.jpg",1
load image "pigmove.jpg",2
load image "pigjump.jpg",3
load image "brickz.jpg",4
load image "brickz.jpg",5
load image "brickz.jpg",7
load image "Apple.jpg",8
load image "door.jpg",10
x = 0
y = 500
running = 0
facingright = 1
frame = 0
rem width of level, change to extend the level width
levelwidth = 1600
screenstartx = 0
dim objectx(200)
dim objecty(200)
dim objectimage(200)
totalobjects = setupobjects(levelwidth)
` CONTROLS
do
running = 0
if rightkey()= 1
if shiftkey()= 1
x = x + 5
else
x = x + 20
endif
if controlkey() = 1
x = x + 30
else
x = x + 20
endif
if facingright = 0
mirror sprite 1
facingright = 1
endif
running = 1
endif
if leftkey() = 1
if shiftkey() = 1
x = x - 5
else
x = x - 20
endif
if controlkey() = 1
x = x - 30
else
x = x - 20
endif
if facingright = 1
mirror sprite 1
facingright = 0
endif
running = 1
endif
` Jumping
if spacekey() = 1 and spacepressed=0 and jumping <10
jumping= jumping + 1
jumpy= -10
spacepressed = 1
endif
if spacekey() = 0 then spacepressed = 0
if running = 1
imagenum = 2 + (frame/2)
frame=frame + 1
if frame >3 then frame=0
else imagenum = 1
endif
if jumping > 0 then imagenum = 3
if jumping > 0
y = y + jumpy
jumpy = jumpy + 1
endif
` Collision
if jumpy >0
newy = blockcollision(totalobjects,x,y,imagenum)
if newy <> y
y=newy
jumping = 0
jumpy = 0
endif
else
if jumping = 0
newy = blockcollision(totalobjects,x,y+2,imagenum)
if newy <> y
jumping = 2
jumpy = 1
endif
endif
endif
cls
` Bounderies
if x < 0 then x = 0
if x > levelwidth -32 then x=levelwidth -32
if x < screen width()/2
screenstartx = 0
else
if x > levelwidth -(screen width()/2)
screenstartx= levelwidth - screen width()
else
screenstartx = x -(screen width()/2)
endif
endif
cls
drawobjects(totalobjects,screenstartx)
sprite 1, x - screenstartx,y,imagenum
sync
loop
function setupobjects(levelwidth)
count = 1
for x = 0 to levelwidth step 190
objectx(count) = x
objecty(count) = 536
objectimage(count) = 5
count=count + 1
next x
objectx(count) = 500
objecty(count) = 100
objectimage(count) =5
count=count + 1
objectx(count) = 100
objecty(count) = 43
objectimage(count) =5
count=count + 1
objectx(count) = 100
objecty(count) = 5
objectimage(count) = 8
count=count + 1
objectx(count) = 650
objecty(count) = 350
objectimage(count) = 5
count=count + 1
objectx(count) = 1100
objecty(count) = 290
objectimage(count) = 5
count=count + 1
objectx(count) = 1395
objecty(count) = 40
objectimage(count) = 10
count=count + 1
objectx(count) = 1250
objecty(count) = 150
objectimage(count) = 5
endfunction count
` Function to paste images and where to paste them
function drawobjects(total,screenstartx)
load bitmap "Dark_city.jpg"
for i = 1 to total
paste image objectimage(i),objectx(i)-screenstartx,objecty(i),1
next i
endfunction
` Collision function
function blockcollision(total,x,y,imagenum)
newy = y
sprite 2,x,y,imagenum
for i=1 to total
sprite 3, objectx(i),objecty(i),objectimage(i)
if sprite collision(2,3)
newy=objecty(i) - sprite height(2)
endif
next i
delete sprite 2
delete sprite 3
endfunction newy