OK. I got it to work. Now, it won't let me draw a box. I tell it to and it won't. Why?
Numoftiles = 5
Dim character$(numoftiles)
Tilesize = 10
Selectedtile = 2
dim box(5)
box(1) = 0
Set display mode 1280,1024,16
Sync on
sync rate 0
gosub maketiles
ink rgb(255,255,255), rgb(0,0,0)
Input "Do you want to (L)oad a map or make a (N)ew map:", loadornew$
loadornew$ = upper$(loadornew$)
If loadornew$ = "L" then gosub loadmap
Input "x size:", xsize
Input "y size:", ysize
For I = 1 to numoftiles
Input "enter character for tile "+str$(I)+":",character$
character$(I) = character$
next I
Dim Map(xsize,ysize)
For y = 1 to ysize
For x = 1 to xsize
Map(x,y) = 1
next x
next y
gosub Drawmap
gosub datastuff
Do :`**************MAIN LOOP!!!*****************
If int(mousex()/tilesize) < xsize then mousex = int(mousex()/tilesize)
If int(mousey()/tilesize) < ysize then mousey = int(mousey()/tilesize)
If scancode() = 2 then selectedtile = 1
If scancode() = 3 then selectedtile = 2
If scancode() = 4 then selectedtile = 3
If scancode() = 5 then selectedtile = 4
If scancode() = 6 then selectedtile = 5
If scancode() = 31 then gosub savemap
If scancode() = 35 then gosub help
If scancode() = 46 then gosub chngchar
If scancode() = 38 then gosub loadmap
If scancode() = 48 then box(1) = 1
If mouseclick() = 1 and box(1) = 0
map(mousex+1,mousey+1) = selectedtile
paste image selectedtile,mousex*tilesize,mousey*tilesize
endif
If mouseclick() = 1 and box(1) = 1
box(2) = mousex+1
box(3) = mousey+1
box(1) = 2
endif
If mouseclick() = 2 and box(1) = 2
box(4) = mousex+1
box(5) = mousey+1
box(1) = 3
endif
If box(1) = 3 then gosub makebox
gosub datastuff
sync
Loop :`**********MAIN LOOP!!!***********
`Make Tiles:
MAketiles:
ink rgb(255,255,255), rgb(0,0,0)
box 1,1,tilesize,tilesize
Ink rgb(0,0,0), rgb(0,0,0)
line 1,1,tilesize,tilesize
line 1,tilesize,tilesize,1
get image 1,1,1,tilesize,tilesize
cls
ink rgb(255,255,0), rgb(0,0,0)
box 1,1,tilesize,tilesize
Ink rgb(0,0,0), rgb(0,0,0)
line 1,1,tilesize,tilesize
line 1,tilesize,tilesize,1
get image 2,1,1,tilesize,tilesize
cls
ink rgb(255,0,0), rgb(0,0,0)
box 1,1,tilesize,tilesize
Ink rgb(0,0,0), rgb(0,0,0)
line 1,1,tilesize,tilesize
line 1,tilesize,tilesize,1
get image 3,1,1,tilesize,tilesize
cls
ink rgb(0,0,255), rgb(0,0,0)
box 1,1,tilesize,tilesize
Ink rgb(0,0,0), rgb(0,0,0)
line 1,1,tilesize,tilesize
line 1,tilesize,tilesize,1
get image 4,1,1,tilesize,tilesize
cls
ink rgb(0,255,0), rgb(0,0,0)
box 1,1,tilesize,tilesize
Ink rgb(0,0,0), rgb(0,0,0)
line 1,1,tilesize,tilesize
line 1,tilesize,tilesize,1
get image 5,1,1,tilesize,tilesize
cls
Return
`Draw Map:
Drawmap:
cls
For y = 1 to ysize
For x = 1 to xsize
Paste image Map(x,y), x*tilesize - tilesize, y*tilesize - tilesize
next x
next y
sync
Return
`Save map
savemap:
sleep 1000
cls
ink rgb(255,255,255), rgb(0,0,0)
Input "Filename:",filename$
if File exist(filename$) = 1 then delete file filename$
open to write 1,filename$
write string 1,str$(xsize)
write string 1,str$(ysize)
For I = 1 to numoftiles
Write string 1,character$(I)
Next I
For y = 1 to ysize
For x = 1 to xsize
thing = map(x,y)
write string 1,character$(thing)
next x
next y
close file 1
cls
gosub drawmap
return
`Load map
Loadmap:
cls
ink rgb(255,255,255), rgb(0,0,0)
sleep 1000
Input "Show files in directory? Y or N:", yesorno$
yesorno$ = upper$(yesorno$)
If yesorno$ = "Y" then dir
Input "Filename:", filename$
If file exist(filename$) = 1
Open to read 1,filename$
read string 1,xsize$
read string 1,ysize$
xsize = val(xsize$)
ysize = val(ysize$)
dim map(xsize,ysize)
For I = 1 to numoftiles
read string 1,Character$(I)
next I
For y = 1 to ysize
For x = 1 to xsize
Map(x,y) = 1
next x
next y
For y = 1 to ysize
For x = 1 to xsize
read string 1,map$
For I = 1 to numoftiles
If character$(I) = map$ then map(x,y) = I
next I
next x
next y
close file 1
endif
If file exist(filename$) = 0
Print "File does not exist"
sleep 1000
Input "(T)ry again, or (L)oad a new map:", fail$
fail$ = upper$(fail$)
If fail$ = "T" then goto loadmap
endif
cls
gosub drawmap
return
`HELP:
Help:
cls
Ink rgb(255,255,255), rgb(0,0,0)
Print "Press 1,2,3,4, or 5 to select a tile."
Print "The current selected tile is "+str$(selectedtile)+"."
Print
Print "Press ESC to end the program"
Print "Press H for help during the program"
Print "Press S to save the current map"
Print "Press C to change the characters for each tile #"
Print "The current characters are: ";
For I = 1 to numoftiles
Print character$(I);
Print " ";
Next I
Print
Print "Press L to load a map"
Print "Press b and then left click on a box and right click on another box to make a box with the selected color (currently has bugs)"
sleep 1000
Print "Press any key to continue..."
suspend for key
cls
gosub drawmap
return
`Change characters
Chngchar:
cls
sleep 1000
Ink rgb(255,255,255), rgb(0,0,0)
For I = 1 to numoftiles
Input "enter character for tile "+str$(I)+":",character$
character$(I) = character$
next I
cls
gosub drawmap
return
`Make Box
Makebox:
For x = box(2) to box(4)
For y = box(3) to box(5)
map(x,y) = selectedtile
next y
next x
gosub drawmap
box(1) = 0
return
`Datastuff
Datastuff:
ink rgb(0,0,0), rgb(0,0,0)
box 0,800,1280,1024
set cursor 0,1000
Ink rgb(255,255,255), rgb(0,0,0)
Print "Selected Tile:"+str$(selectedtile)+" ";
If box(1)>0 then Print "Box Mode:" + str$(box(1))+" ";
sync
return
Here is the part that doesn't work:
`Datastuff
Datastuff:
ink rgb(0,0,0), rgb(0,0,0)
box 0,800,1280,1024
set cursor 0,1000
Ink rgb(255,255,255), rgb(0,0,0)
Print "Selected Tile:"+str$(selectedtile)+" ";
If box(1)>0 then Print "Box Mode:" + str$(box(1))+" ";
sync
return
It's not saying there is a bug or anything, it just won't appear...