diff --git a/data/gfx/tileset01.bmp b/data/gfx/tileset01.bmp
index 2fcafd2..15bbaff 100644
Binary files a/data/gfx/tileset01.bmp and b/data/gfx/tileset01.bmp differ
diff --git a/data/gfx/tileset01.psd b/data/gfx/tileset01.psd
index 2ab8167..1f509c5 100644
Binary files a/data/gfx/tileset01.psd and b/data/gfx/tileset01.psd differ
diff --git a/data/maps/Tileset.tsx b/data/maps/Tileset.tsx
new file mode 100644
index 0000000..7d02d18
--- /dev/null
+++ b/data/maps/Tileset.tsx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/data/maps/awesometestmap.tmx b/data/maps/awesometestmap.tmx
new file mode 100644
index 0000000..c4d3e7d
--- /dev/null
+++ b/data/maps/awesometestmap.tmx
@@ -0,0 +1,130 @@
+
+
diff --git a/data/maps/joni.tmx b/data/maps/joni.tmx
new file mode 100644
index 0000000..5ef6833
--- /dev/null
+++ b/data/maps/joni.tmx
@@ -0,0 +1,135 @@
+
+
diff --git a/data/maps/joni2.tmx b/data/maps/joni2.tmx
new file mode 100644
index 0000000..c8b227b
--- /dev/null
+++ b/data/maps/joni2.tmx
@@ -0,0 +1,58 @@
+
+
diff --git a/src/Events.pbi b/src/Events.pbi
index 8bcf16e..5ff24a3 100644
--- a/src/Events.pbi
+++ b/src/Events.pbi
@@ -47,7 +47,7 @@ Procedure HandleEventRunningGame()
EndIf
; Player movement
- If KeyboardReleased(#PB_Key_Left) And Player\X > 0
+ If KeyboardPushed(#PB_Key_Left) And Player\X > 0
Player\X-1
; Camera positioning
@@ -56,16 +56,16 @@ Procedure HandleEventRunningGame()
EndIf
EndIf
- If KeyboardReleased(#PB_Key_Right) And Player\X < #MAP_WIDTH
+ If KeyboardPushed(#PB_Key_Right) And Player\X < #MAP_WIDTH-1
Player\X+1
; Camera positioning
- If Player\X > (Cam\X + Cam\Width - Cam\Padding) And (Cam\X + Cam\Width) < #MAP_WIDTH
+ If Player\X > (Cam\X + Cam\Width - Cam\Padding) And (Cam\X + Cam\Width) < #MAP_WIDTH-1
Cam\X + 1
EndIf
EndIf
- If KeyboardReleased(#PB_Key_Up) And Player\Y > 0
+ If KeyboardPushed(#PB_Key_Up) And Player\Y > 0
Player\Y-1
; Camera positioning
@@ -74,11 +74,11 @@ Procedure HandleEventRunningGame()
EndIf
EndIf
- If KeyboardReleased(#PB_Key_Down) And Player\Y < #MAP_HEIGHT
+ If KeyboardPushed(#PB_Key_Down) And Player\Y < #MAP_HEIGHT-1
Player\Y+1
; Camera positioning
- If Player\Y > (Cam\Y + Cam\Height - Cam\Padding) And (Cam\Y + Cam\Height) < #MAP_HEIGHT
+ If Player\Y > (Cam\Y + Cam\Height - Cam\Padding) And (Cam\Y + Cam\Height) < #MAP_HEIGHT-1
Cam\Y + 1
EndIf
EndIf
diff --git a/src/Functions.pbi b/src/Functions.pbi
index 84848d9..a251835 100644
--- a/src/Functions.pbi
+++ b/src/Functions.pbi
@@ -10,17 +10,48 @@ EndProcedure
; TODO: Make this dynamic
Procedure InitTileset()
- Tileset(0) = CopySprite(GFXTileset, #PB_Any)
- ClipSprite(Tileset(0), #TILE_SIZE*0, 0, #TILE_SIZE, #TILE_SIZE)
-
- Tileset(1) = CopySprite(GFXTileset, #PB_Any)
- ClipSprite(Tileset(1), #TILE_SIZE*1, 0, #TILE_SIZE, #TILE_SIZE)
-
- Tileset(2) = CopySprite(GFXTileset, #PB_Any)
- ClipSprite(Tileset(2), #TILE_SIZE*2, 0, #TILE_SIZE, #TILE_SIZE)
-
- Tileset(3) = CopySprite(GFXTileset, #PB_Any)
- ClipSprite(Tileset(3), #TILE_SIZE*3, 0, #TILE_SIZE, #TILE_SIZE)
+ Define i.i, j.i, count.i
+ count = 0
+ For i=0 To 5
+ For j=0 To 5
+
+ Tileset(count) = CopySprite(GFXTileset, #PB_Any)
+ ClipSprite(Tileset(count), #TILE_SIZE*j, #TILE_SIZE*i, #TILE_SIZE, #TILE_SIZE)
+ count+1
+ Next
+ Next
+ 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,?")
+ Dim Tiles.s(0)
+ Define NumFound.i = ExtractRegularExpression(0, MapData, Tiles())
+ Define i.i, X.i, Y.i
+ X = 0
+ Y = 0
+
+ Debug ArraySize(Tiles())
+
+ 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
+
+ If X = #MAP_WIDTH-1
+ X = 0
+ Y+1
+ Else
+ X+1
+ EndIf
+ Next
+ EndIf
+ EndIf
EndProcedure
Procedure DrawTile(number.i, x.i, y.i)
diff --git a/src/Globals.pbi b/src/Globals.pbi
index a2e07f1..63f9e7d 100644
--- a/src/Globals.pbi
+++ b/src/Globals.pbi
@@ -1,8 +1,9 @@
#DATA_PATH = "../data/"
#TILE_SIZE = 20
-#MAP_WIDTH = 120
-#MAP_HEIGHT = 120
+#MAP_WIDTH = 50
+#MAP_HEIGHT = 50
+; TODO: Aus der XML lesen
; Global variables
Global Fullscreen = 0
@@ -30,11 +31,12 @@ Global *ActiveMenu.GameMenu
; Fonts
Global Font_H1 = LoadFont(1, "Arial", 40, #PB_Font_Bold)
Global Font_H2 = LoadFont(2, "Verdana", 18)
+Global Font_H3 = LoadFont(3, "Verdana", 10)
; Graphics
Global GFXLogo.i
Global GFXTileset.i
-Global Dim Tileset.i(3)
+Global Dim Tileset.i(36)
; Sounds
Global MenuSoundStarted = 0
@@ -44,12 +46,13 @@ LoadSound(2, #DATA_PATH + "sound/title_song.wav")
; FIXME: JUST FOR DEBUGGING
+
Global Dim TileMap.Tile(#MAP_WIDTH, #MAP_HEIGHT)
-Define x, y
-For x.i=0 To #MAP_WIDTH
- For y.i=0 To #MAP_HEIGHT
- TileMap(x, y)\TileNumber = Random(2)+1
- TileMap(x, y)\X = x
- TileMap(x, y)\Y = y
- Next
-Next
+;Define x, y
+;For x.i=0 To #MAP_WIDTH
+; For y.i=0 To #MAP_HEIGHT
+; TileMap(x, y)\TileNumber = Random(2)+1
+; TileMap(x, y)\X = x
+; TileMap(x, y)\Y = y
+; Next
+;Next
diff --git a/src/Main.pb b/src/Main.pb
index f92da05..2353dc3 100644
--- a/src/Main.pb
+++ b/src/Main.pb
@@ -18,6 +18,9 @@ XIncludeFile "Draw.pbi"
XIncludeFile "Events.pbi"
+LoadMap(#DATA_PATH + "maps/joni2.tmx")
+
+
; Initialize all the variables and stuff. I think we refactor this
; into a separate file if it gets messy.
GameStates("MAIN_MENU")\DrawFun = @DrawMenu()