bewaaaaare, the shaodow of darkness is there! :o
This commit is contained in:
parent
c6b205f0a3
commit
cb9262752c
6 changed files with 76 additions and 18 deletions
BIN
shots/ESCape-03.jpg
Normal file
BIN
shots/ESCape-03.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 131 KiB |
|
@ -36,6 +36,11 @@ EndProcedure
|
||||||
|
|
||||||
Procedure DrawRunningGame()
|
Procedure DrawRunningGame()
|
||||||
DrawMap()
|
DrawMap()
|
||||||
|
|
||||||
|
CalculateShadow()
|
||||||
|
DrawShadow()
|
||||||
|
|
||||||
DrawPlayer()
|
DrawPlayer()
|
||||||
|
|
||||||
DrawHUD()
|
DrawHUD()
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
|
@ -47,7 +47,7 @@ Procedure HandleEventRunningGame()
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
; Player movement
|
; Player movement
|
||||||
If KeyboardPushed(#PB_Key_Left) And Player\X > 0
|
If KeyboardReleased(#PB_Key_Left) And Player\X > 0
|
||||||
Player\X-1
|
Player\X-1
|
||||||
|
|
||||||
; Camera positioning
|
; Camera positioning
|
||||||
|
@ -56,7 +56,7 @@ Procedure HandleEventRunningGame()
|
||||||
EndIf
|
EndIf
|
||||||
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
|
Player\X+1
|
||||||
|
|
||||||
; Camera positioning
|
; Camera positioning
|
||||||
|
@ -65,7 +65,7 @@ Procedure HandleEventRunningGame()
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
If KeyboardPushed(#PB_Key_Up) And Player\Y > 0
|
If KeyboardReleased(#PB_Key_Up) And Player\Y > 0
|
||||||
Player\Y-1
|
Player\Y-1
|
||||||
|
|
||||||
; Camera positioning
|
; Camera positioning
|
||||||
|
@ -74,7 +74,7 @@ Procedure HandleEventRunningGame()
|
||||||
EndIf
|
EndIf
|
||||||
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
|
Player\Y+1
|
||||||
|
|
||||||
; Camera positioning
|
; Camera positioning
|
||||||
|
|
|
@ -20,7 +20,6 @@ Procedure InitTileset()
|
||||||
count+1
|
count+1
|
||||||
Next
|
Next
|
||||||
Next
|
Next
|
||||||
Debug count
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure LoadMap(Filename.s)
|
Procedure LoadMap(Filename.s)
|
||||||
|
@ -35,8 +34,6 @@ Procedure LoadMap(Filename.s)
|
||||||
X = 0
|
X = 0
|
||||||
Y = 0
|
Y = 0
|
||||||
|
|
||||||
Debug ArraySize(Tiles())
|
|
||||||
|
|
||||||
;CreateFile(0, "mapcheck.txt") ; File stuff for checking the map loader
|
;CreateFile(0, "mapcheck.txt") ; File stuff for checking the map loader
|
||||||
For i=0 To NumFound-1
|
For i=0 To NumFound-1
|
||||||
TileMap(X, Y)\TileNumber = Val(RTrim(Tiles(i), ","))-1
|
TileMap(X, Y)\TileNumber = Val(RTrim(Tiles(i), ","))-1
|
||||||
|
@ -58,6 +55,61 @@ Procedure LoadMap(Filename.s)
|
||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
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)
|
Procedure DrawTile(number.i, x.i, y.i)
|
||||||
DisplaySprite(Tileset(number), #TILE_SIZE*x, #TILE_SIZE*y)
|
DisplaySprite(Tileset(number), #TILE_SIZE*x, #TILE_SIZE*y)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
@ -72,10 +124,12 @@ Procedure DrawMap()
|
||||||
Next
|
Next
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; The player
|
||||||
Procedure DrawPlayer()
|
Procedure DrawPlayer()
|
||||||
DrawTile(Player\TileNumber, Player\X-Cam\X, Player\Y-Cam\Y)
|
DrawTile(Player\TileNumber, Player\X-Cam\X, Player\Y-Cam\Y)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; We need a HUD, hell yeah!
|
||||||
Procedure DrawHUD()
|
Procedure DrawHUD()
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#DATA_PATH = "../data/"
|
#DATA_PATH = "../data/"
|
||||||
#TILE_SIZE = 20
|
#TILE_SIZE = 20
|
||||||
|
#SHADOW_RADIUS = 6
|
||||||
#MAP_WIDTH = 120
|
#MAP_WIDTH = 120
|
||||||
#MAP_HEIGHT = 120
|
#MAP_HEIGHT = 120
|
||||||
; TODO: Aus der XML lesen
|
; 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(1, #DATA_PATH + "sound/menu_select.wav")
|
||||||
LoadSound(2, #DATA_PATH + "sound/title_song.wav")
|
LoadSound(2, #DATA_PATH + "sound/title_song.wav")
|
||||||
|
|
||||||
|
; Map
|
||||||
; FIXME: JUST FOR DEBUGGING
|
|
||||||
|
|
||||||
Global Dim TileMap.Tile(#MAP_WIDTH, #MAP_HEIGHT)
|
Global Dim TileMap.Tile(#MAP_WIDTH, #MAP_HEIGHT)
|
||||||
;Define x, y
|
Global Dim ShadowMap.Shadow(#MAP_WIDTH, #MAP_HEIGHT)
|
||||||
;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
|
|
|
@ -35,6 +35,13 @@ Structure Tile
|
||||||
X.i
|
X.i
|
||||||
Y.i
|
Y.i
|
||||||
TileNumber.i
|
TileNumber.i
|
||||||
|
Health.i
|
||||||
|
EndStructure
|
||||||
|
|
||||||
|
Structure Shadow
|
||||||
|
X.i
|
||||||
|
Y.i
|
||||||
|
Strength.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
Structure Camera
|
Structure Camera
|
||||||
|
|
Loading…
Reference in a new issue