fixed tha regex bug! map-loading is awesome now :)

This commit is contained in:
Ruben Müller 2011-08-21 11:48:49 +02:00
parent b125c73a19
commit c6b205f0a3
4 changed files with 15 additions and 11 deletions

View file

@ -10,7 +10,7 @@
<section name="data">
<explorer view="../../../" pattern="0"/>
<log show="1"/>
<lastopen date="2011-08-20 22:58" user="rubenmueller" host="localhost"/>
<lastopen date="2011-08-21 02:18" user="rubenmueller" host="localhost"/>
</section>
<section name="files">
<file name="src/Draw.pbi">
@ -19,19 +19,19 @@
</file>
<file name="src/Events.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="a0c820e419e497f30bad0b61543b7f25"/>
<fingerprint md5="a92102efdf5b3df0a7c4cc41dc1180b1"/>
</file>
<file name="src/Functions.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="ed491d1019ce28aa13abe10d2d379bd9"/>
<fingerprint md5="b7a749bf67b3203603e337ea5710a2fd"/>
</file>
<file name="src/Globals.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="0ac1462aee241a3988087e55d18c4cb6"/>
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
<fingerprint md5="1a281d6c07f7d8f5a89a7df675ac424e"/>
</file>
<file name="src/Main.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="3dbf5809e1f3064215228cb40414399d"/>
<fingerprint md5="b9b239f5a2931d7943036e024d3daecb"/>
</file>
<file name="src/Structs.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="0"/>

View file

@ -23,13 +23,12 @@ Procedure InitTileset()
Debug count
EndProcedure
; TODO: Hier gehts weiter
Procedure LoadMap(Filename.s)
; Extract the map data from the XML file
If LoadXML(0, Filename) And XMLStatus(0) = #PB_XML_Success
Define *Node.i = XMLNodeFromPath(MainXMLNode(0), "/map/layer/data")
Define MapData.s = GetXMLNodeText(*Node)
If CreateRegularExpression(0, "\d,?")
If CreateRegularExpression(0, "\d{1,2},?")
Dim Tiles.s(0)
Define NumFound.i = ExtractRegularExpression(0, MapData, Tiles())
Define i.i, X.i, Y.i
@ -38,18 +37,23 @@ Procedure LoadMap(Filename.s)
Debug ArraySize(Tiles())
;CreateFile(0, "mapcheck.txt") ; File stuff for checking the map loader
For i=0 To NumFound-1
TileMap(X, Y)\TileNumber = Val(RTrim(Tiles(i), ","))-1
TileMap(X, Y)\X = X
TileMap(X, Y)\Y = Y
;WriteString(0, StrU(TileMap(X, Y)\TileNumber+1)+",")
If X = #MAP_WIDTH-1
X = 0
Y+1
;WriteStringN(0, "") ; do new line
Else
X+1
EndIf
Next
;CloseFile(0)
EndIf
EndIf
EndProcedure

View file

@ -1,8 +1,8 @@

#DATA_PATH = "../data/"
#TILE_SIZE = 20
#MAP_WIDTH = 50
#MAP_HEIGHT = 50
#MAP_WIDTH = 120
#MAP_HEIGHT = 120
; TODO: Aus der XML lesen
; Global variables

View file

@ -18,7 +18,7 @@ XIncludeFile "Draw.pbi"
XIncludeFile "Events.pbi"
LoadMap(#DATA_PATH + "maps/joni2.tmx")
LoadMap(#DATA_PATH + "maps/joni.tmx")
; Initialize all the variables and stuff. I think we refactor this