Since I couldn't isolate any area of the code here's the whole thing.
Strict;
Const TILE_WIDTH=96;
Const TILE_LENGTH=60;
Const TILE_HEIGHT=12;
Const TILE_TOP=48;
Const SCREEN_WIDTH=800;
Const SCREEN_HEIGHT=600;
Graphics SCREEN_WIDTH,SCREEN_HEIGHT,32,60
SetMaskColor 255,0,255
SetBlend MASKBLEND
HideMouse()
Type Tile
Field graphic
Field passable:Int
Field reachable:Int
Field targetable:Int
Field animated:Int
Field event:Int
Field height:Int
Method AnimateTile()
End Method
End Type;
Type BattleMap
Field name:String
Field width:Int
Field length:Int
Field height:Int
Field slideX:Int
Field slideY:Int
Field Map:Tile[,]
Function Create:BattleMap(area:String)
Local b:BattleMap=New BattleMap
b.name:String = area
Local inFile=ReadStream("Maps/"+b.name+".dat")
b.width=Readint(inFile)
b.length=Readint(inFile)
b.height=Readint(inFile)
Local numTiles=Readint(inFile)
Local allTiles=LoadAnimImage("Maps/"+b.name+"Tiles.png",TILE_WIDTH,TILE_LENGTH,0,numTiles,MASKEDIMAGE|DYNAMICIMAGE)
b.Map=New Tile[b.width, b.length]
For Local xx:Int = 0 To b.width-1
For Local yy:Int = 0 To b.length-1
b.Map[xx,yy]=New Tile
b.Map[xx,yy].height=Readint(inFile)
If b.Map[xx,yy].height>0 Then
b.Map[xx,yy].graphic=CreateImage(TILE_WIDTH,(TILE_TOP+(TILE_HEIGHT*b.Map[xx,yy].height)),1,MASKEDIMAGE);
SetColor(255,0,255)
For Local j = 0 To ImageHeight(b.Map[xx,yy].graphic)
DrawLine 0,j,TILE_WIDTH,j
Next
For Local i:Int = b.Map[xx,yy].height-1 To 0 Step -1
DrawImage allTiles,0,(i*TILE_HEIGHT),Readint(inFile)
Next
GrabImage b.Map[xx,yy].graphic,0,0
End If
SetColor 255,255,255
Next
Next
Return b
End Function
Method Draw()
SetClsColor 50,50,200
Cls
For Local xx:Int = 0 To width-1
For Local yy:Int = 0 To length-1
If Map[xx,yy].height>0 Then
Local screenx=(SCREEN_WIDTH/2)-(TILE_WIDTH/2)+((TILE_WIDTH/2)*xx)-((TILE_WIDTH/2)*yy)+slideX
Local screeny=(yy*(TILE_TOP/2))+(xx*(TILE_TOP/2))+((height-Map[xx,yy].height)*TILE_HEIGHT)+slideY
DrawImage Map[xx,yy].graphic,screenx,screeny
EndIf
Next
Next
End Method
End Type
Global timer:Int =MilliSecs()+1000
Global ticks:Int=0
Global secs:Int=0
Global a:BattleMap = BattleMap.Create("Testie")
Repeat
a.Draw()
DrawText "FPS: "+secs,0,SCREEN_HEIGHT-20
If timer<=MilliSecs() Then
timer=MilliSecs()+1000
secs=ticks
ticks=0
Else
ticks=ticks+1
End If
FlushMem()
Flip
Until KeyHit(KEY_ESCAPE)
and this is the pic

and the data file http://projects.rpgi.net/tact/files/Testie.dat
|