ok. I added some more, but encountered another bug I con't figure out.
Levels = 2
Level = 1
largestmap = 69
tilesize = 64
playerx = 0
playery = 0
direction = 2
windowsizex = 4
windowsizey = 3
Dim mapsize(2,2)
mapsize(1,1) = 68: mapsize(1,2) = 65
mapsize(2,1) = 69: mapsize(2,2) = 69
Dim Map$(largestmap,largestmap,levels,2)
Load image "title.jpg",1
Load image "door.jpg",2
Load image "floor.jpg",3
Load image "key.jpg",4
Load image "locked door.jpg",5
Load image "open door.jpg",6
Load image "stairs up.jpg",7
Load image "stairs down.jpg",8
Load image "wall.jpg",9
Load image "playerup.bmp",10
Load image "playerdown.bmp",11
Load image "playerleft.bmp",12
Load image "playerright.bmp",13
Sync on
sync rate 0
gosub Loadmap
gosub refreshscreen
suspend for key
Do
gosub keystuff
sync
Loop
`***SUBPROGRAM: LOADMAP***
LOADMAP:
For I = 1 to levels
Filename$ = "level"+str$(I)+".map"
open to read 1,filename$
For y = 1 to mapsize(I,2)
For x = 1 to mapsize(I,1)
read string 1,map$(x,y,I,1)
next x
next y
close file 1
next I
For y = 1 to mapsize(level,2)
For x = 1 to mapsize(level,1)
If map$(x,y,level,1) = "down"
playerx = x
playery = y
endif
next x
next y
return
`***SUBPROGRAM: REFRESHSCREEN***
REFRESHSCREEN:
xpos = 0
ypos = 0
For y = playery - windowsizey to playery + windowsizey
For x = playerx - windowsizex to playerx + windowsizex
xpos = x - (playerx - windowsizex)
ypos = y - (playery - windowsizey)
If map$(x,y,level,1) = "wall" then paste image 9,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "door" then paste image 2,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "floor" then paste image 3,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "key" then paste image 4,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "lock" then paste image 5,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "open" then paste image 6,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "up" then paste image 7,xpos*tilesize,ypos*tilesize
If map$(x,y,level,1) = "down" then paste image 8,xpos*tilesize,ypos*tilesize
next x
next y
If direction = 1 then sprite 1,windowsizex*tilesize,windowsizey*tilesize,10
If direction = 2 then sprite 1,windowsizex*tilesize,windowsizey*tilesize,11
If direction = 3 then sprite 1,windowsizex*tilesize,windowsizey*tilesize,12
If direction = 4 then sprite 1,windowsizex*tilesize,windowsizey*tilesize,13
Return
`***SUBPROGRAM: KEYSTUFF***
Keystuff:
If upkey() = 1
direction = 1
playery = playery - 1
gosub refreshscreen
endif
If downkey() = 1
direction = 2
playery = playery = 1
gosub refreshscreen
endif
If leftkey() = 1
direction = 3
playerx = playerx - 1
gosub refreshscreen
endif
If rightkey() = 1
direction = 4
playerx = playerx + 1
gosub refreshscreen
endif
return
The player won't move.