bewaaaaare, the shaodow of darkness is there! :o

This commit is contained in:
Ruben Müller 2011-08-21 12:42:55 +02:00
parent c6b205f0a3
commit cb9262752c
6 changed files with 76 additions and 18 deletions

BIN
shots/ESCape-03.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View file

@ -36,6 +36,11 @@ EndProcedure
Procedure DrawRunningGame()
DrawMap()
CalculateShadow()
DrawShadow()
DrawPlayer()
DrawHUD()
EndProcedure

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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