Should work with any resolution. Make sure all your tiles are the same size.
Rem Project: 2d tile editor
Rem Created: 9/11/2004 5:52:26 AM
Rem ***** Main Source File *****
`set display mode 1600, 1200, 32
sync on
backdrop on
color backdrop 0
randomize timer()
rem map dimensions
mx = 16
my = 16
dim map(mx, my)
rem size of image tiles used
tile_size_x = 128
tile_size_y = 128
rem calculate number sprites that can fit in the screen
screen_size_x = (screen width() / tile_size_x) + 2
screen_size_y = (screen height() / tile_size_y) + 2
REM IMAGES =============================================================
load image "tiles\t.bmp", 1
load image "tiles\t2.bmp", 2
rem Create a random map
for x = 1 to mx
for y = 1 to my
if x = 1 or x = mx or y = 1 or y = my
map(x,y) = 2
else
map(x,y) = 1
endif
next y
next x
rem create map sprites
s = 0
for x = -1 to screen_size_x
for y = -1 to screen_size_y
inc s
sprite s,0,0,1
next y
next x
REM MAIN LOOP ==========================================================
DO
gosub _scroll_map
sync
LOOP
REM Controlls scrolling and redrawing of map
_scroll_map:
sprt = 0
for x = -1 to screen_size_x
for y = -1 to screen_size_y
imx = (x+1) + tile_offset_x
imy = (y+1) + tile_offset_y
inc sprt
if imx <= mx and imy <= my and imx>0 and imy>0
img = map(imx, imy)
sprite sprt, (x*tile_size_x)-ox, (y*tile_size_y)-oy, img
show sprite sprt
else
hide sprite sprt
endif
next y
next x
if rightkey() = 1 and tile_offset_x < (mx-screen_size_x)+2
inc ox, 1
endif
if leftkey() = 1 and (tile_offset_x > 0 or ox > 0)
dec ox, 1
endif
if upkey() = 1 and (tile_offset_y > 0 or oy > 0)
dec oy, 1
endif
if downkey() = 1 and tile_offset_y < (my-screen_size_y)+2
inc oy, 1
endif
if ox >= tile_size_x
ox = 0
inc tile_offset_x, 1
endif
if ox = 0-tile_size_x
ox = 0
dec tile_offset_x, 1
if tile_offset_x < 0 then tile_offset_x = 0
endif
if oy >= tile_size_y
oy = 0
inc tile_offset_y, 1
endif
if oy <= 0-tile_size_x
oy = 0
dec tile_offset_y, 1
if tile_offset_y < 0 then tile_offset_y = 0
endif
RETURN
"eureka" - Archimedes