people tend to use the term 'camera' in 2d but there's no real camera at all (atleast in dbpro terms).
basically, you, the programmer, manage what your player sees in 2d or 3d, right? we call this 'camera work', in general.
here's ONE example of some 2d 'camera' work. it's very basic, but you'll get the idea. use the arrow keys to move the player (a red square) around a randomly generated map. note the
illusion of player movement, and the camera following it
hide mouse `we don't need it for this
rem let's make some images for our 'map' and player
cls rgb(0,255,0) `green land block
get image 1,0,0,64,64,1
cls rgb(0,0,255) `blue water block
get image 2,0,0,64,64,1
cls rgb(255,0,0) `red player block
get image 3,0,0,16,16,1
rem make a "map" for us to explore. here's a 20x20 grid
dim map(20,20)
for x = 1 to 20
for y = 1 to 20
map(x,y) = (rnd(1)+1) `50/50 chance each block will be land or water
next y
next x
rem let's offset the start point to somewhere near the center of the "map"
xoffset = 320 : yoffset = 320
rem for this example, i'm locking the player near the center of the screen.
sprite 1, screen width()/2, screen height()/2,3
color backdrop 0
do
rem some basic movement using arrow keys. the x and y offsets are adjusted if player 'moves'.
if leftkey() and lastmove + 10 < timer()
xoffset = xoffset - 1
lastmove = timer()
endif
if rightkey() and lastmove + 10 < timer()
xoffset = xoffset + 1
lastmove = timer()
endif
if upkey() = 1 and lastmove + 10 < timer()
yoffset = yoffset - 1
lastmove = timer()
endif
if downkey() and lastmove + 10 < timer()
yoffset = yoffset + 1
lastmove = timer()
endif
rem draw the map images (land and water blocks made earlier)
gosub _drawmap:
set cursor 0,0
print "Use Arrow Keys to Move"
print "X and Y Offsets: ", xoffset, ", ", yoffset
loop
_drawmap:
rem note the image blocks are pasted using the x and y offsets generated from the arrow key 'movement' code above
for x = 1 to 20
for y = 1 to 20
paste image map(x,y), (x-1)*64-xoffset, (y-1)*64-yoffset,0 `remember our "map blocks" are 64x64 pixels
next y
next x
return
you can do some fancy 2d 'camera work'... world rotation, simulated "3d movement" into and out of of the screen, etc. but for now, just trying to show you the concept of a 2d 'camera'.
good luck!
edit: and, yes. the coding is not efficient (i paste all images whether they're 'visible' or not, etc) and is very basic (ie, you wouldn't want to paste this into your project!) but you'll get the idea.
check the
code snippets and
code base for better examples!
Virtual Nomad . California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium