k, ashingda. here ya go.
Comments are semi-tutorial like, because i had to explain to a coding buddy.
REM Rpg Tile map example.....
REM By DD, The one and only DARKDragon.....
REM 2/17/10 5:34.....started.
rem 100x100 Map with up to 5 layers
Dim Map(100,100,5)
Sync on
Sync Rate 60
rem you never know when you are gonna change stuff,
rem so variables are very important.
` ps if i were coding a real game, the variable
` would be replaced by an array - they make our
` programming lives eaisier.......
test_tileimg = 1
load image "level/Testtile.bmp",test_tileimg
load image "level/Testtile.bmp",2
load image "level/Testtile2.bmp",3
load image "level/Testtile3.png",4
load image "level/Testtile4.png",5
REM Declared for Scrolling our map....
` notice how i used a float value!
ScrollX# = 150
ScrollY# = 150
Rem For testing purposes....a load routine for "test_map.mLap"
` ps..........mLap stands for multiple layer.......well, the
` other part of the acronym needs work.......like the file
` does...... i'm not done with it....heheh...LOL.
Open to Read 1,"Data/Test.mLap"
REM Read the map size...
Read Byte 1,mapsizeX
Read Byte 1,mapsizeY
for x = 1 to mapsizeX step 2
Read String 1, TempSTR$
for y = 1 to mapsizeY
Map(y,x,1) = Val( Mid$(TempSTR$,y) )
next y
next x
close file 1
Open to Read 1,"Data/Test Layer 2.mLap"
REM Read the map size...
Read Byte 1,mapsizeX
Read Byte 1,mapsizeY
for x = 1 to mapsizeX step 2
Read String 1, TempSTR$
for y = 1 to mapsizeY
Map(y,x,2) = Val( Mid$(TempSTR$,y) )
next y
next x
close file 1
REM DONT ASK, I NEEDED THIS AT FIRST.......
for x = 5 to mapsizeX / 2.5
for y = 5 to mapsizeY / 2.5
if Rnd(400) < 2 then Map(y,x,3) = Rnd(1)+1
Map(15,15,3) = 1
Map(30,20,3) = 2
Map(23,23,3) = 1
Map(34,25,3) = 2
Map(18,26,3) = 2
next y
next x
REM I wont explain.......not part of the "lesson", but basically
REM Controls the camera(ScrollX and ScrollY) smoothly.......
Camera_Velx# = 1
Camera_Vely# = 1
do
cls
REM Map viewing update stuff.......
If downkey() = 1 then dec Camera_Vely#,1
If upkey() = 1 then inc Camera_Vely#,1
If rightkey() = 1 then dec Camera_Velx#,1
If leftkey() = 1 then inc Camera_Velx#,1
if Camera_Velx# => 0.1 then Camera_Velx# = Camera_Velx# - 0.5
if Camera_Vely# => 0.1 then Camera_Vely# = Camera_Vely# - 0.5
if Camera_Velx# =< -0.1 then Camera_Velx# = Camera_Velx# + 0.5
if Camera_Vely# =< -0.1 then Camera_Vely# = Camera_Vely# + 0.5
` if Camera_Velx# =< 0.06 and Camera_Velx# => -0.06 then Camera_Velx# = 0
` if Camera_Vely# =< 0.06 and Camera_Vely# => -0.06 then Camera_Vely# = 0
ScrollX# = ScrollX# - Camera_Velx#
ScrollY# = ScrollY# - Camera_Vely#
Print Camera_Vely#
rem This is the "for....next" loop that "Prints" the map
REM Even more useful if you were to make a function
REM out of it.....
for layer = 1 to 3
for x = 1 to mapsizeX
for y = 1 to mapsizeY
if Map(x,y,layer) > 0 and layer = 1 then paste image test_tileimg+layer,(x*16) - ScrollX#,(y*16) - ScrollY#
if Map(x,y,layer) > 0 and layer = 2 then paste image test_tileimg+layer,( (x)*16 ) - ScrollX#,( (y)*16 ) - ScrollY#
if Map(x,y,layer) > 0 and layer = 3 then paste image test_tileimg+2+Map(x,y,layer),( (x)*16 ) - ScrollX#,( (y)*16 ) - ScrollY#,1
next y
next x
next layer
sync
loop
Quote: "Can always learn a thing or two. "
Wow,lol, I'd never thought I could come up with somthing that the DBprofessionals would learn from......
(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )