Hey all!
I ive been programming with darkbasic for a little while but just found the website today!
anyways im making a little rpg game however I am stuck on how to generate the map. I consider myself just past the newb mark, so sorry if this is a dumb question!
heres my code:
You have to run this program first so it creates the file that is loaded!
start:
input "player name: ",playername$
playerlvl# = 1
playerhp# = 10
playerexp# = 0
playermap# = 1
savestart:
if file exist("save.xdr") = 1
ink rgb(255,0,0),1
print "FILE ALREADY EXISTS!"
print "OVERWRITE FILE? (THIS WILL ERASE ALL SAVED DATA!"
input "[y]es / [n]o : ",cmd$
if cmd$ = "y"
goto write
else
if cmd$ = "n"
goto start
endif
endif
else
if file exist("save.xdr") = 0
write:
print "SAVING FILE"
open to write 1,"save.xdr"
write string 1,playername$
write float 1,playerlvl#
write float 1,playerhp#
write float 1,playerexp#
write float 1,playermap#
close file 1
print " "
print "SAVE COMPLETE"
endif
endif
wait key
Heres the actual game:
(if you can call it such)
sync on
print "LOADING FILE"
open to read 1,"save.xdr"
read string 1,playername$
read float 1,playerlvl#
read float 1,playerhp#
read float 1,playerexp#
read float 1,playermap#
close file 1
print " "
print "LOAD COMPLETE"
print "name: ",playername$
print "lvl: ",playerlvl#
print "hp: ",playerhp#
print "exp: ",playerexp#
print "map: ",playermap#
wait key
if playermap# = 1
map$ = "LEVEL 1"
mapw = 10
maph = 10
remstart
else
if playermap# = 2
map$ = "LEVEL 2"
else
if playermap# = 3
map$ = "LEVEL 3"
endif
endif
remend
endif
cls
dim map$(mapw,maph)
xlocal = 0
ylocal = 0
if playermap# = 1
gosub level1
endif
for h = 1 to maph
for w = 1 to mapw
if map$(x,y) = "0"
ink rgb(0,255,0),1
box xlocal,ylocal,xlocal+10,ylocal+10
inc xlocal,11
inc ylocal,11
endif
if map$(x,y) = "D"
ink rgb(128,64,0),1
box xlocal,ylocal,xlocal+10,ylocal+10
endif
if map$(x,y) = "S"
ink rgb(0,190,0),1
box xlocal,ylocal,xlocal+10,ylocal+10
endif
next w
next h
`LEVELS
level1:
data "0,0,0,0,0,0,0,0,0,D"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "0,0,0,0,0,0,0,0,0,0"
data "S,0,0,0,0,0,0,0,0,0"
return
remstart
level2:
print "NOT MADE YET"
level3:
print "NOT MADE YET"
remend