Hi heletrobe,
For future reference use {code} and {/code} but with square brackets [ ] to preserve your code formatting in the forums. That gives the Nice green on black appearance too
Alternatively, you can use {codebox} and {/codebox} if you have a particularly long code sample and need to keep the size of the post down.
Anyhoo, about your question:
If readmap=1 Then Read map(10,10)
DrawImage tileset,x*40,y*40,map(10,10)
Because the value at (10,10) which is cell 11x11 never gets populated (arrays are always start from 0 ... n ) and every tile drawn will be '0' (grass)
Try this instead:
Graphics 800,600,0,2
SetBuffer BackBuffer()
AutoMidHandle True
AppTitle "RPG TEST"
Global mapx=9
Global mapy=9
Dim map(mapx,mapy)
Data 0,0,1,0,0,0,0,0,1,0
Data 0,0,1,0,0,0,0,0,1,0
Data 0,0,1,0,0,0,0,0,1,0
Data 0,0,1,0,0,0,0,0,1,0
Data 0,0,1,1,1,1,1,1,1,1
Data 0,0,1,0,0,0,0,0,0,0
Data 0,0,1,0,0,2,2,0,0,0
Data 0,0,1,0,0,2,2,0,0,0
Data 0,0,1,0,0,0,0,0,0,0
Data 0,0,1,0,0,0,0,0,0,0
playerx=80
playery=80
Global readmap=True
Global tileset=LoadAnimImage("tileset.png",40,40,0,3)
player=CreateImageLoadImage("player.png")
While Not KeyDown(1)
Cls
MaskImage player,255,255,255
DrawImage player,40+(playerx),playery
If KeyDown(205) Then playerx=playerx+1
If KeyDown(203) Then playerx=playerx-1
loadworld()
Flip
Wend
End
Function loadworld()
For y=0 To mapy
For x=0 To mapx
If (readmap) Then
Read map(y,x)
End If
DrawImage tileset,40+(x*40),y*40,map(y,x)
Next
Next
readmap=False
End Function
|