SdlBasic, display a simple map.


const BOARD_HEIGHT = 15
const BOARD_WIDTH  = 15
const TILE_W = 32
const TILE_H = 32

WIDTH  = (TILE_W * BOARD_WIDTH)
HEIGHT = (TILE_H * BOARD_HEIGHT)

setdisplay(WIDTH, HEIGHT, 32, 1)

dim img[BOARD_WIDTH, BOARD_HEIGHT]
dim m[]

sub loadmap(filename)
if(fileexists(filename)) then
open filename for input as 1
i = 0
while eof(1)=0
input 1, $a
m[i] = $a
i = i + 1
wend
close(1)
end if
end sub
loadmap("map.dat")

for y = 0 to BOARD_HEIGHT
for x = 0 to BOARD_WIDTH
if(m[x+y*BOARD_WIDTH] = 0) then
img[x, y] = loadimage("floor.bmp")
else
img[x, y] = loadimage("wall.bmp")
end if
next
next

for y = 0 to BOARD_HEIGHT
for x = 0 to BOARD_WIDTH
bob(img[x, y], TILE_W * x, TILE_H * y, img[x, y])
next
next

waitkey(27)

 

map

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s