From c6b205f0a31784cab521088be03049af4f371e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20Mu=CC=88ller?= Date: Sun, 21 Aug 2011 11:48:49 +0200 Subject: [PATCH] fixed tha regex bug! map-loading is awesome now :) --- escape.pbp | 12 ++++++------ src/Functions.pbi | 8 ++++++-- src/Globals.pbi | 4 ++-- src/Main.pb | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/escape.pbp b/escape.pbp index 8236ef9..9e81ac5 100644 --- a/escape.pbp +++ b/escape.pbp @@ -10,7 +10,7 @@
- +
@@ -19,19 +19,19 @@ - + - + - - + + - + diff --git a/src/Functions.pbi b/src/Functions.pbi index a251835..20f785f 100644 --- a/src/Functions.pbi +++ b/src/Functions.pbi @@ -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 diff --git a/src/Globals.pbi b/src/Globals.pbi index 63f9e7d..a1d663a 100644 --- a/src/Globals.pbi +++ b/src/Globals.pbi @@ -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 diff --git a/src/Main.pb b/src/Main.pb index 2353dc3..049dd15 100644 --- a/src/Main.pb +++ b/src/Main.pb @@ -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