Wotcha, folks.
I'm sure this must have been asked a 100 times, but I simply can't find any mention of what I'm specifically after.
I'm a BlitzBasic person trying to cut my teeth on DBPro. With BB, you had a very effective and simply collision commnd called...
rectsoverlap (x,y,20,20,x1,y1,20,20)
...which basically checks the position of two rectangles to see if they overlap.
Is there such a command in DBpro, or are all collision commands restricted to sprites?
Reason I ask, is that I'm trying to put together some background code of a 2D maze/platformer game, and I'm working with 'box'es at the moment, rather than sprites.
My code may better explain it.
set display mode 800,600,32
`set window on
dim map(19,19)
global px=20
global py=20
global gpx,gpy
readmap()
do
cls
drawmap()
moveplayer()
drawplayer()
drawstats()
drawsurround()
loop
end
` FUNCTIONS
`DrawSurround
function drawsurround()
ink rgb(0,255,0),0
for x=-1 to 1
for y=-1 to 1
if map(gpx+x,gpy+y)=1
line (gpx*20)+x*20,(gpy*20)+y*20,((gpx*20)+x*20)+20,(gpy*20)+y*20
line ((gpx*20)+x*20)+20,(gpy*20)+y*20,((gpx*20)+x*20)+20,((gpy*20)+y*20)+20
line ((gpx*20)+x*20)+20,((gpy*20)+y*20)+20,(gpx*20)+x*20,((gpy*20)+y*20)+20
line (gpx*20)+x*20,((gpy*20)+y*20)+20,(gpx*20)+x*20,(gpy*20)+y*20
endif
next
next
ink rgb(255,255,255),0
endfunction
`DrawStats
function drawstats()
set cursor 450,10
print "PX: ",px," PY: ",py
set cursor 450,30
print "GPX: ",gpx," GPY: ",gpy
endfunction
`MovePlayer
function moveplayer()
local ox=px:oy=py
if rightkey()
px=px+1
endif
if leftkey()
px=px-1
endif
if downkey()
py=py+1
endif
if upkey()
py=py-1
endif
if px>360 or px<20 then px=ox
if py>360 or py<20 then py=oy
gpx=px/20:gpy=py/20
endfunction
`DrawPlayer
function drawplayer()
ink rgb(255,255,0),0
box px,py,px+20,py+20
ink rgb(255,255,255),0
endfunction
`DrawMap
function drawmap()
for ac=0 to 19
for dn=0 to 19
if map(ac,dn)=1 then box ac*20,dn*20,(ac*20)+20,(dn*20)+20
next
next
endfunction
`ReadMap
function readmap()
restore level1
for dn=0 to 19
for ac=0 to 19
read a
map(ac,dn)=a
next
next
endfunction
level1:
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Many thanks,
Tobo