This came up out of VG Teacher's original thread
here which I sort of hijacked and don't want to continue to do so.
There were some really cool ideas coming out of guys like zenassem,nonZero, and Chris Tate that inspired me to try some various collision mapping methods.
I thought to myself (and out loud): "Self, wouldn't it be sweet if I could just simply draw an image and tell DBPro what colors represent boundaries for collisions?"
So here's the first, simplest attempt that I was able to toss together in a spare few minutes today.
You just paint a terrain in GIMP or your favorite BMP creation tool (if it isn't GIMP then you should try it).
In this version the ground has to be green. For some reason I had to open up green to a range or was otherwise getting stuck. Maybe I have some non-green pixels in the middle of my green land... not a worry.
So this makes use of the apparently slow point(x,y) command. I'm not sure if it causes any issue in this simple of a program, but there is something that causes a random extra delay... like the wait cycles get stacked up and then release... could be busy CPU though...
Anyway for those of you who want to try something a little different:
REM Project: collision_map_basic
REM Created: 12/20/2011 3:32:29 PM
REM By: Sean Mann
REM ***** Main Source File *****
REM
disable escapekey
set window on
set display mode 640,480,16
print "Press Q to Quit at any time."
print "Press [ or ] to decrease or increase the wait cycle."
print
print "Press any key to start..."
wait key
gosub point_sub
cls
print "Wow wasn't that a fun trip?... See ya!"
wait 1000
end
point_sub:
wait_cycle = 5
load image "simple_collision_map.bmp",1
load bitmap "simple_collision_map.bmp",1
x = bitmap width(0)/2 - 50
y = bitmap height(0)/2 - 50
set current bitmap 0
repeat
xx = x
yy = y
if leftkey() then dec x
if rightkey() then inc x
if upkey() then dec y
if downkey() then inc y
set current bitmap 1
if inkey$() = "[" then dec wait_cycle
if inkey$() = "]" then inc wait_cycle
if point(x,y) > 65500 or point(x,y) < 65000
x = xx
y = yy
endif
wait wait_cycle
set current bitmap 0
paste image 1,0,0
for r = 5 to 1 step -1
ellipse x,y, r,r
next r
until inkey$() = "q"
return
Next attempt will be something a bit more universal and utilizing memblocks instead of bitmaps and the infamous point(x,y) command. Maybe a scrolling background too... we'll see.