When i run this code i only get a dark screen with a faint blue color where the water would be on the map. I have tried other ways but get a white screen. Can anyone please look at this code and tell me what I am doing wrong.
`set screen resolution
set display mode 1024, 768, 32
`backdrop on
sync on
sync rate 100
Global MapWidth = 40
Global MapHeight = 40
Global MapTileSize = 64
Global MapOffsetX = 0
Global MapOffsetY = 0
Global MapViewportWidth = 0 : MapViewportWidth = 1024/ MapTileSize
Global MapViewportHeight = 0 : MapViewportHeight = 768/ MapTileSize
rem maximum amounts the map can scroll in world coordinates
maxScrollX = MapWidth*MapTileSize - 1024
maxScrollY = MapHeight*MapTileSize - 768
rem player's on-screen boundaries
scrollBoundX1 = 100 : scrollBoundX2 = 920
scrollBoundY1 = 70 : scrollBoundY2 = 690
load image "C:\Program Files\The Game Creators\Dark Basic Professional Online\Projects\2dgame\media\level\sand_001.bmp",1,1
load image "C:\Program Files\The Game Creators\Dark Basic Professional Online\Projects\2dgame\media\level\slate_001.bmp",10,1
load image "C:\Program Files\The Game Creators\Dark Basic Professional Online\Projects\2dgame\media\level\water_001.bmp",11,1
rem build random map
dim map(MapWidth,MapHeight)
for x = 1 to MapWidth
for y = 1 to MapHeight
read map(x,y)
next y
next x
do
`cls
rem player controls
if rightkey() then pa = wrapvalue(pa+2)
if leftkey() then pa = wrapvalue(pa-2)
if downkey()
px# = px# + cos(pa)*2
py# = py# + sin(pa)*2
endif
if upkey()
px# = px# - cos(pa)*2
py# = py# - sin(pa)*2
endif
rem keep player within its boundaries
if px# > scrollBoundX2-22 then px# = scrollBoundX2-22 : inc MapOffsetX, 2
if px# < scrollBoundX1+22 then px# = scrollBoundX1+22 : dec MapOffsetX, 2
if py# > scrollBoundY2-22 then py# = scrollBoundY2-22 : inc MapOffsetY,2
if py# < scrollBoundY1+22 then py# = scrollBoundY1+22 : dec MapOffsetY,2
rem scroll map according to player
if MapOffsetX < 0 then MapOffsetX = 0
if MapOffsetY < 0 then MapOffsetY = 0
if MapOffsetX > maxScrollX then MapOffsetX = maxScrollX
if mapOFfsetY > maxScrollY then MapOffsetY = maxScrollY
rem draw map
drawMap(MapOffsetX, MapOffsetY)
rem draw player
ink rgb(255,255,0)
circle px#, py#, 22
line px#, py#, px#-cos(pa)*24, py#-sin(pa)*24
rem show player's boundaries.
ink rgb(255,0,0),0
line scrollBoundX1,scrollBoundY1,scrollBoundX2,scrollBoundY1
line scrollBoundX1,scrollBoundY2,scrollBoundX2,scrollBoundY2
line scrollBoundX1,scrollBoundY1,scrollBoundX1,scrollBoundY2
line scrollBoundX2,scrollBoundY1,scrollBoundX2,scrollBoundY2
rem
ink rgb(255,255,255),0
set cursor 0,490
print "Player World X: ",MapOffsetX+px#
print "Player World Y: ",MapOffsetY+py#
sync
loop
function drawMap(offsetX as float, offsetY as float)
sx = int(offsetX / MapTileSize)
sy = int(offsetY / MapTileSize)
ox = offsetX mod MapTileSize
oy = offsetY mod MapTileSize
ex = sx + MapViewportWidth+1
ey = sy + MapViewportHeight+1
if ex >= mapWidth then ex = mapWidth-1
if ey >= mapHeight then ey = mapHeight-1
for y = sy to ey
for x = sx to ex
ink map(x+1,y+1)
ix = (x - sx)*MapTileSize - ox
iy = (y - sy)*MapTileSize - oy
box ix, iy, ix+MapTileSize, iy+MapTileSize
next x
next y
endfunction
`store tile data at the end of the program so its out of the way
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,10
data 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,10
data 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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