Hello.
I'm stilling learning DarkBASIC Pro, but I'm using the DarkBASIC Pro book by Johnathan s. Harbour (and someone else's name who i can't remember).
anyways, In the book, it tells us to make our game maps using the DATA function, we do something like this:
data 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
data 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
data 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
data 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 5, 1, 1, 1, 1, 1, 4, 0, 0, 0, 12, 13, 1, 1, 1
data 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 1, 10, 11, 0, 0, 0, 0, 0, 0, 5, 1, 1
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 1, 1
data 0, 0, 0, 0, 6, 7, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 9, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1
data 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
data 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
Well, the output should look like this:
(minus the black area in the middle.
But the output looks like this when I ran the program:
I was using this tileset:
(from the metroid fusion debug room)
And this was the code I was using:
set image colorkey 255, 0, 255
`Tile constants
global img_tiles as word = 1
global spr_tiles as word = 1
`tile grid
dim tiledata(20,20) as byte
init_game()
run_game()
end
function init_game()
sync on
sync rate 15
hide mouse
randomize timer()
`load the tiles
create animated sprite spr_tiles, "debug.bmp", 7, 3, img_tiles
set sprite frame img_tiles, 1
`load the level data
for y = 1 to 15
for x = 1 to 25
read tiledata(x,y)
next x
next y
endfunction
function draw_tiles()
for x = 1 to 25
for y = 1 to 15
if tiledata(x,y) > 0
dx = 10 + sprite width(spr_tiles) * x
dy = 10 + sprite height(spr_tiles) * y
set sprite frame spr_tiles, tiledata(x,y)
paste sprite spr_tiles, dx, dy
endif
next x
next y
endfunction
function run_game()
do
draw_tiles()
sync
if escapekey() = 1 then exit
loop
endfunction
(a modified version of the Darkanoid game from the book to display the blocks)
Thanks for any help.
http://twewy-fan.com/ <-- The first ever fansite for "The World Ends With You"