diff --git a/shots/ESCape-03.jpg b/shots/ESCape-03.jpg new file mode 100644 index 0000000..992d04b Binary files /dev/null and b/shots/ESCape-03.jpg differ diff --git a/src/Draw.pbi b/src/Draw.pbi index dd4dfae..bae96b5 100644 --- a/src/Draw.pbi +++ b/src/Draw.pbi @@ -36,6 +36,11 @@ EndProcedure Procedure DrawRunningGame() DrawMap() + + CalculateShadow() + DrawShadow() + DrawPlayer() + DrawHUD() EndProcedure diff --git a/src/Events.pbi b/src/Events.pbi index 5ff24a3..c7620c0 100644 --- a/src/Events.pbi +++ b/src/Events.pbi @@ -47,7 +47,7 @@ Procedure HandleEventRunningGame() EndIf ; Player movement - If KeyboardPushed(#PB_Key_Left) And Player\X > 0 + If KeyboardReleased(#PB_Key_Left) And Player\X > 0 Player\X-1 ; Camera positioning @@ -56,7 +56,7 @@ Procedure HandleEventRunningGame() EndIf EndIf - If KeyboardPushed(#PB_Key_Right) And Player\X < #MAP_WIDTH-1 + If KeyboardReleased(#PB_Key_Right) And Player\X < #MAP_WIDTH-1 Player\X+1 ; Camera positioning @@ -65,7 +65,7 @@ Procedure HandleEventRunningGame() EndIf EndIf - If KeyboardPushed(#PB_Key_Up) And Player\Y > 0 + If KeyboardReleased(#PB_Key_Up) And Player\Y > 0 Player\Y-1 ; Camera positioning @@ -74,7 +74,7 @@ Procedure HandleEventRunningGame() EndIf EndIf - If KeyboardPushed(#PB_Key_Down) And Player\Y < #MAP_HEIGHT-1 + If KeyboardReleased(#PB_Key_Down) And Player\Y < #MAP_HEIGHT-1 Player\Y+1 ; Camera positioning diff --git a/src/Functions.pbi b/src/Functions.pbi index 20f785f..9523850 100644 --- a/src/Functions.pbi +++ b/src/Functions.pbi @@ -20,7 +20,6 @@ Procedure InitTileset() count+1 Next Next - Debug count EndProcedure Procedure LoadMap(Filename.s) @@ -35,8 +34,6 @@ Procedure LoadMap(Filename.s) X = 0 Y = 0 - 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 @@ -58,6 +55,61 @@ Procedure LoadMap(Filename.s) EndIf EndProcedure +; Shadowmap +Procedure CalculateShadow() + Define X.i, Y.i + Define MapX.i, MapY.i, Strength.i, CentercheckX.i, CentercheckY.i + + For X.i=0 To #SHADOW_RADIUS*2 + For Y.i=0 To #SHADOW_RADIUS*2 + MapX = (Player\X-#SHADOW_RADIUS) + X + MapY = (Player\Y-#SHADOW_RADIUS) + Y + + CentercheckX = X - #SHADOW_RADIUS + If CentercheckX < 0 + CentercheckX * -1 + EndIf + CentercheckX = 5-CentercheckX + + CentercheckY = Y - #SHADOW_RADIUS + If CentercheckY < 0 + CentercheckY * -1 + EndIf + CentercheckY = 5-CentercheckY + + If CentercheckX > CentercheckY + CentercheckX = CentercheckY + EndIf + + Strength = (255 / #SHADOW_RADIUS) * (CentercheckX+1) + + If MapX >= 0 And MapY >= 0 + If ShadowMap(MapX, MapY)\Strength < Strength + ShadowMap(MapX, MapY)\Strength = Strength + EndIf + EndIf + Next + Next +EndProcedure + +Procedure DrawShadowtile(strength.i, x.i, y.i) + Box(#TILE_SIZE*x, #TILE_SIZE*y, #TILE_SIZE, #TILE_SIZE, RGBA(Random(0), Random(0), Random(0), 255-strength)) +EndProcedure + +Procedure DrawShadow() + Define X.i ,Y.i + + StartDrawing(ScreenOutput()) ;ImageOutput(0) + DrawingMode(#PB_2DDrawing_AlphaBlend) + For X.i=0 To Cam\Width + For Y.i=0 To Cam\Height + DrawShadowtile(ShadowMap(X+Cam\X, Y+Cam\Y)\Strength, X, Y) + Next + Next + StopDrawing() +EndProcedure + +; Map itself Procedure DrawTile(number.i, x.i, y.i) DisplaySprite(Tileset(number), #TILE_SIZE*x, #TILE_SIZE*y) EndProcedure @@ -72,10 +124,12 @@ Procedure DrawMap() Next EndProcedure +; The player Procedure DrawPlayer() DrawTile(Player\TileNumber, Player\X-Cam\X, Player\Y-Cam\Y) EndProcedure +; We need a HUD, hell yeah! Procedure DrawHUD() EndProcedure diff --git a/src/Globals.pbi b/src/Globals.pbi index a1d663a..cb2b7f5 100644 --- a/src/Globals.pbi +++ b/src/Globals.pbi @@ -1,6 +1,7 @@  #DATA_PATH = "../data/" #TILE_SIZE = 20 +#SHADOW_RADIUS = 6 #MAP_WIDTH = 120 #MAP_HEIGHT = 120 ; TODO: Aus der XML lesen @@ -44,15 +45,6 @@ LoadSound(0, #DATA_PATH + "sound/menu_change.wav") LoadSound(1, #DATA_PATH + "sound/menu_select.wav") LoadSound(2, #DATA_PATH + "sound/title_song.wav") - -; FIXME: JUST FOR DEBUGGING - +; Map 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 +Global Dim ShadowMap.Shadow(#MAP_WIDTH, #MAP_HEIGHT) \ No newline at end of file diff --git a/src/Structs.pbi b/src/Structs.pbi index 307bb02..f4e3f70 100644 --- a/src/Structs.pbi +++ b/src/Structs.pbi @@ -35,6 +35,13 @@ Structure Tile X.i Y.i TileNumber.i + Health.i +EndStructure + +Structure Shadow + X.i + Y.i + Strength.i EndStructure Structure Camera