It reads the map files correctly. The map file DATA is in the right place.
But the bottom line of the map is displayed above map 0,0!
And it does not go down to the bottom of the map.
Worse than that it seems to shift the bottom of the map over 1 tile so what is being placed at 0,0 would actually be on the OPPOSITE BOTTOM CORNER of the map.
Code: Select all
; from an example provided by Kaeru Gaman in the PB Forums
; file load is all Rook ZImbabwe
InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(1024,768,16,"Tiledemo 1")
; ************************************ Change the following to change maps!
filename$ = "MAP-9.rwd" ; "MAP-001.rwd"
GFile$ = "MAP-9.bmp" ; "MAP-001.bmp"
OpenPreferences(filename$) ; if the file could be read, we continue...
PreferenceGroup("DATA")
MaxWide = ReadPreferenceLong("X2",0)
MaxHigh = ReadPreferenceLong("X3",0)
SPX = ReadPreferenceLong("X4",32)
SPY = ReadPreferenceLong("X5",32)
PreferenceGroup("LAYER")
LVL$ = ReadPreferenceString("X2","")
PreferenceGroup("MAPDATA")
GFile$ = ReadPreferenceString("X1", "MAP-0.bmp")
IntBase = ReadPreferenceLong("X2",4)
SpriteCount = ReadPreferenceLong("X3",4)
ClosePreferences() ; close the previously opened file
result = LoadSprite(999, GFile$)
Debug "Sprite to clip load is = "+Str(result) ; indicate success of failure
UseBuffer(999) ; change grab buffer to sprite just created
Imagesize = IntBase * SPX - 1
For y = 0 To Imagesize ; <== for images arranged in column order the loops should be reversed (making x the outside loop)
For x = 0 To Imagesize
GrabSprite(Spritenumber,x,y,SPX,SPY)
Spritenumber = Spritenumber + 1
If Spritenumber >= SpriteCount
Break 2
EndIf
x + SPX - 1 ; <=='variable' step
Next
y + SPY - 1 ; <=='variable' step
Next
UseBuffer(#PB_Default)
Dim LAYER(MaxWide,MaxHigh)
op = 0
For x = 0 To MaxWide
For y = 0 To MaxHigh
LAYER(x,y) = Asc(Mid(LVL$,op,1)) - 35
op = op + 1
Next
Next
MouseLocate(512,381)
FineStep = 4 ; 4
Repeat
ExamineKeyboard()
ExamineMouse()
MauX = MouseX() : MauY = MouseY()
ClearScreen(0)
If KeyboardPushed(#PB_Key_Left) Or MauX < 8
FineX - FineStep
If FineX < 0
FineX = SPX - FineStep
MapX-1
If MapX < 0
MapX = 0
FineX = 0
EndIf
EndIf
EndIf
If KeyboardPushed(#PB_Key_Right) Or MauX > 1016
FineX + FineStep
If FineX > SPX - FineStep
FineX = 0
MapX+1
If MapX > MaxWide - 16
MapX = MaxWide - 16
FineX = SPX - FineStep
EndIf
EndIf
EndIf
If KeyboardPushed(#PB_Key_Up) Or MauY < 8
FineY - FineStep
If FineY < 0
FineY = SPY - FineStep
MapY-1
If MapY < 0
MapY = 0
FineY = 0
EndIf
EndIf
EndIf
If KeyboardPushed(#PB_Key_Down) Or MauY > 760
FineY + FineStep
If FineY > SPY - FineStep
FineY = 0
MapY+1
If MapY > MaxHigh - 12
MapY = MaxHigh - 12
FineY = SPY - FineStep
EndIf
EndIf
EndIf
; ***** PLACE TO CUT AND INSERT NEW CODE
; THIS IS THE MOUSE DISPLAY ***********************************
ActTileX = (MauX+FineX) / SPX + MapX
ActTileY = (MauY+FineY) / SPY + MapY
; Buff = LAYER(ActTileX,ActTileY)
; LAYER(ActTileX,ActTileY) = 28
;***********************************
;*** Tile Engine
For SY=0 To 12
For SX = 0 To 16
DisplaySprite(LAYER(MapX+SX,MapY+SY), SPX * SX - FineX , SPY * SY - FineY )
Next
Next
;***********************************
; LAYER(ActTileX,ActTileY) = Buff ; den alten Wert wiederherstellen.
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
http://www.bluemesapc.com/Downloads/MAP-001.zip