Skip to content

Commit

Permalink
Fix sistema de luces + sistema de dias + nicks
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinTrionfetti committed Nov 13, 2021
1 parent a8226a5 commit 17313d9
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 131 deletions.
28 changes: 12 additions & 16 deletions CODIGO/ClsRoundLight.cls
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Friend Function Create_Light_To_Map(ByVal map_x As Byte, ByVal map_y As Byte, Co
NumLights = NumLights + 1

ReDim Preserve light_list(1 To NumLights) As tLight

'Le damos color
light_list(NumLights).RGBcolor = Color

Expand All @@ -50,9 +50,8 @@ Friend Function Create_Light_To_Map(ByVal map_x As Byte, ByVal map_y As Byte, Co
'Pos en el mapa
light_list(NumLights).map_x = map_x
light_list(NumLights).map_y = map_y

'LucesRedondas.LightRenderAll


UpdateLights = True

Exit Function

Expand Down Expand Up @@ -112,7 +111,9 @@ Public Function Delete_Light_To_Index(ByVal light_index As Byte, Optional Render
max_x = light_list(light_index).map_x + light_list(light_index).range
min_y = light_list(light_index).map_y - light_list(light_index).range
max_y = light_list(light_index).map_y + light_list(light_index).range


UpdateLights = True

For Ya = min_y To max_y
For Xa = min_x To max_x

Expand All @@ -125,12 +126,6 @@ Public Function Delete_Light_To_Index(ByVal light_index As Byte, Optional Render

Next Xa
Next Ya

If RenderFinal Then
LucesRedondas.LightRenderAll

End If


Exit Function

Expand Down Expand Up @@ -221,6 +216,8 @@ Private Sub LightRender(ByVal light_index As Integer)
min_y = light_list(light_index).map_y - range
max_y = light_list(light_index).map_y + range



For Ya = min_y To max_y
For Xa = min_x To max_x

Expand Down Expand Up @@ -255,16 +252,17 @@ LightRender_Err:

End Sub

Public Sub LightRenderAll()
Public Sub LightRenderAll(ByVal MinX As Long, ByVal MinY As Long, ByVal MaxX As Long, ByVal MaxY As Long)

On Error GoTo LightRenderAll_Err


Dim i As Long

For i = 1 To NumLights
LightRender i

If light_list(i).map_x + light_list(i).range > MinX And light_list(i).map_x - light_list(i).range < MaxX And light_list(i).map_y + light_list(i).range > MinY And light_list(i).map_y - light_list(i).range < MaxY Then
LightRender i
End If
Next i


Expand All @@ -285,9 +283,7 @@ Public Function Delete_All_LigthRound(Optional RenderFinal As Boolean = True)

For i = 1 To NumLights
Delete_Light_To_Index i, RenderFinal

Next i


Exit Function

Expand Down
5 changes: 3 additions & 2 deletions CODIGO/General.bas
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ Sub SetConnected()
frmMain.Timerping.Enabled = False
End If

frmMain.UpdateLight.Enabled = True
frmMain.UpdateDaytime.Enabled = True
' frmMain.UpdateLight.Enabled = True
'frmMain.UpdateDaytime.Enabled = True
light_transition = 1#

COLOR_AZUL = RGB(0, 0, 0)
Expand Down Expand Up @@ -1149,6 +1149,7 @@ Sub Main()
AlphaNiebla = 75
EntradaY = 10
EntradaX = 10
UpdateLights = False

Call SwitchMap(UserMap)

Expand Down
89 changes: 62 additions & 27 deletions CODIGO/ModMetereologia.bas
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,84 @@ Public Const LIGHT_TRANSITION_DURATION = 5000
Public Const STEP_LIGHT_TRANSITION = 1 / LIGHT_TRANSITION_DURATION

'Status
Private Const Normal As Byte = 0
Private Const NUBLADO As Byte = 1
Private Const LLUVIA As Byte = 2
Private Const NIEVE As Byte = 3
Private Const TORMENTA As Byte = 4
Public Const Normal As Byte = 0
Public Const NUBLADO As Byte = 1
Public Const LLUVIA As Byte = 2
Public Const NIEVE As Byte = 3
Public Const TORMENTA As Byte = 4

Private DayColors() As RGBA
Private DeathColor As RGBA
Private BlindColor As RGBA
Private TimeIndex As Integer
Public DayColors() As RGBA
Public DeathColor As RGBA
Public BlindColor As RGBA
Public TimeIndex As Integer

Private NightIndex As Integer
Private MorningIndex As Integer
Public NightIndex As Integer
Public MorningIndex As Integer

Public MeteoParticle As Integer

Public Sub IniciarMeteorologia()

On Error GoTo IniciarMeteorologia_Err

ReDim DayColors(11)
ReDim DayColors(0 To 24) As RGBA

' 00:00 - 02:00
Call SetRGBA(DayColors(0), 130, 130, 130)
Call SetRGBA(DayColors(0), 70, 70, 70)
NightIndex = 0
' 02:00 - 04:00
Call SetRGBA(DayColors(1), 130, 130, 160)
Call SetRGBA(DayColors(1), 60, 60, 60)
' 04:00 - 06:00
Call SetRGBA(DayColors(2), 150, 150, 180)
Call SetRGBA(DayColors(2), 80, 80, 80)
' 06:00 - 08:00
Call SetRGBA(DayColors(3), 200, 200, 200)
'Call SetRGBA(DayColors(3), 20, 20, 20)
Call SetRGBA(DayColors(3), 100, 100, 100)
MorningIndex = 3
' 08:00 - 10:00
Call SetRGBA(DayColors(4), 230, 200, 200)
Call SetRGBA(DayColors(4), 100, 100, 100)
' 10:00 - 12:00
Call SetRGBA(DayColors(5), 255, 230, 220)
Call SetRGBA(DayColors(5), 130, 125, 125)
' 12:00 - 14:00
Call SetRGBA(DayColors(6), 255, 240, 220)
Call SetRGBA(DayColors(6), 150, 150, 150)
' 14:00 - 16:00
Call SetRGBA(DayColors(7), 255, 250, 200)
Call SetRGBA(DayColors(7), 170, 170, 170)
' 16:00 - 18:00
Call SetRGBA(DayColors(8), 255, 200, 200)
Call SetRGBA(DayColors(8), 180, 170, 170)
' 18:00 - 20:00
Call SetRGBA(DayColors(9), 255, 180, 160)
Call SetRGBA(DayColors(9), 190, 180, 190)
' 20:00 - 22:00
Call SetRGBA(DayColors(10), 180, 150, 140)
Call SetRGBA(DayColors(10), 200, 210, 200)
' 22:00 - 00:00
Call SetRGBA(DayColors(11), 150, 140, 130)
Call SetRGBA(DayColors(11), 220, 220, 220)

Call SetRGBA(DayColors(12), 255, 255, 255)
NightIndex = 0
' 02:00 - 04:00
Call SetRGBA(DayColors(13), 255, 255, 255)
' 04:00 - 06:00
Call SetRGBA(DayColors(14), 240, 240, 240)
' 06:00 - 08:00
Call SetRGBA(DayColors(15), 240, 235, 240)
MorningIndex = 3
' 08:00 - 10:00
Call SetRGBA(DayColors(16), 230, 230, 230)
' 10:00 - 12:00
Call SetRGBA(DayColors(17), 210, 200, 210)
' 12:00 - 14:00
Call SetRGBA(DayColors(18), 220, 190, 200)
' 14:00 - 16:00
Call SetRGBA(DayColors(19), 190, 170, 170)
' 16:00 - 18:00
Call SetRGBA(DayColors(20), 130, 130, 170)
' 18:00 - 20:00
Call SetRGBA(DayColors(21), 130, 130, 170)
' 20:00 - 22:00
Call SetRGBA(DayColors(22), 120, 120, 140)
' 22:00 - 00:00
Call SetRGBA(DayColors(23), 110, 110, 110)

Call SetRGBA(DayColors(24), 90, 90, 90)

' Muerto
Call SetRGBA(DeathColor, 120, 120, 120)

Expand Down Expand Up @@ -91,9 +120,9 @@ Public Sub RevisarHoraMundo(Optional ByVal Instantaneo As Boolean = False)

If MapDat.base_light = 0 Then
If Instantaneo Then
global_light = DayColors(TimeIndex)
global_light = DayColors(HoraActual)
Else
Call ActualizarLuz(DayColors(TimeIndex))
Call ActualizarLuz(DayColors(HoraActual))
End If

If TimeIndex = NightIndex Then
Expand Down Expand Up @@ -146,7 +175,13 @@ Public Sub RestaurarLuz()
global_light = BlindColor

ElseIf TimeIndex >= 0 Then
global_light = DayColors(TimeIndex)
Dim Elapsed As Single
Elapsed = (FrameTime - HoraMundo) / DuracionDia
Elapsed = (Elapsed - Fix(Elapsed)) * 24

Dim HoraActual As Integer
HoraActual = Fix(Elapsed)
global_light = DayColors(HoraActual)

Else
global_light = COLOR_WHITE(0)
Expand Down
15 changes: 1 addition & 14 deletions CODIGO/Protocol.bas
Original file line number Diff line number Diff line change
Expand Up @@ -3889,12 +3889,8 @@ Private Sub HandleObjectCreate()
If Rango < 100 Then
id = x & y
LucesCuadradas.Light_Create x, y, Color, Rango, id
LucesCuadradas.Light_Render_All
Else
LucesRedondas.Create_Light_To_Map x, y, Color, Rango - 99
LucesRedondas.LightRenderAll
LucesCuadradas.Light_Render_All

End If

End If
Expand Down Expand Up @@ -3969,7 +3965,7 @@ Private Sub HandleObjectDelete()
LucesCuadradas.Light_Remove id
MapData(x, y).luz.Color = COLOR_EMPTY
MapData(x, y).luz.Rango = 0
LucesCuadradas.Light_Render_All
' LucesCuadradas.Light_Render_All

End If

Expand Down Expand Up @@ -7259,16 +7255,12 @@ Private Sub HandleLightToFloor()

If MapData(x, y).luz.Rango > 100 Then
LucesRedondas.Delete_Light_To_Map x, y

LucesCuadradas.Light_Render_All
LucesRedondas.LightRenderAll
Exit Sub
Else
id = LucesCuadradas.Light_Find(x & y)
LucesCuadradas.Light_Remove id
MapData(x, y).luz.Color = COLOR_EMPTY
MapData(x, y).luz.Rango = 0
LucesCuadradas.Light_Render_All
Exit Sub

End If
Expand All @@ -7281,14 +7273,9 @@ Private Sub HandleLightToFloor()
If Rango < 100 Then
id = x & y
LucesCuadradas.Light_Create x, y, color_value, Rango, id
LucesRedondas.LightRenderAll
LucesCuadradas.Light_Render_All
Else

LucesRedondas.Create_Light_To_Map x, y, color_value, Rango - 99
LucesRedondas.LightRenderAll
LucesCuadradas.Light_Render_All

End If

Exit Sub
Expand Down
4 changes: 1 addition & 3 deletions CODIGO/ProtocolCmdParse.bas
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,6 @@ Public Sub ParseUserCommand(ByVal RawCommand As String)
Else
Call LucesRedondas.Create_Light_To_Map(UserPos.x, UserPos.y, COLOR_WHITE(0), 10)
End If
LucesRedondas.LightRenderAll
LucesCuadradas.Light_Render_All
End If

Case "/LUZMAPA"
Expand All @@ -768,7 +766,7 @@ Public Sub ParseUserCommand(ByVal RawCommand As String)
ValidNumber(ArgumentosAll(2), eNumber_Types.ent_Integer) Then

Call SetGlobalLight(D3DColorXRGB(ArgumentosAll(0), ArgumentosAll(1), ArgumentosAll(2)))
Call MapUpdateGlobalLight
'Call MapUpdateGlobalLight
Exit Sub

End If
Expand Down
27 changes: 16 additions & 11 deletions CODIGO/Recursos.bas
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Private Type tMapDat

End Type

Private MapSize As tMapSize
Public MapSize As tMapSize
Public MapDat As tMapDat
Public iplst As String
' *********************************************************
Expand Down Expand Up @@ -948,6 +948,19 @@ Public Sub CargarMapa(ByVal map As Integer)
#End If

'Limpiamos los efectos remantentes del mapa.
For x = 1 To 100
For y = 1 To 100
With MapData(x, y)

Call SetRGBA(.light_value(0), 0, 0, 0)
Call SetRGBA(.light_value(1), 0, 0, 0)
Call SetRGBA(.light_value(2), 0, 0, 0)
Call SetRGBA(.light_value(3), 0, 0, 0)

End With
Next y
Next x

Call LucesCuadradas.Light_Remove_All
Call LucesRedondas.Delete_All_LigthRound(False)
Call Graficos_Particulas.Particle_Group_Remove_All
Expand All @@ -968,13 +981,8 @@ Public Sub CargarMapa(ByVal map As Integer)

ReDim MapData(1 To 100, 1 To 100)

If MapDat.base_light = 0 Then
Call RestaurarLuz

Else
Call SetGlobalLight(MapDat.base_light)
End If

UpdateLights = True

For x = 1 To 100
For y = 1 To 100
With MapData(x, y)
Expand Down Expand Up @@ -1214,9 +1222,6 @@ Public Sub CargarMapa(ByVal map As Integer)
Delete_File Windows_Temp_Dir & "mapa" & map & ".csm"
#End If

Call LucesRedondas.LightRenderAll
Call LucesCuadradas.Light_Render_All

Exit Sub

CargarMapa_Err:
Expand Down
3 changes: 2 additions & 1 deletion CODIGO/TileEngine.bas
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ Public ScrollPixelsPerFrameY As Single
Public timerElapsedTime As Single
Public timerTicksPerFrame As Single
Public engineBaseSpeed As Single
Public UpdateLights As Boolean

Public NumBodies As Integer
Public Numheads As Integer
Expand Down Expand Up @@ -576,7 +577,7 @@ Sub ConvertCPtoTP(ByVal viewPortX As Integer, ByVal viewPortY As Integer, ByRef

On Error GoTo ConvertCPtoTP_Err

' Debug.Print "viewportX: " & viewPortX & "- ViewportY: " & viewPortY
If viewPortX < 0 Or viewPortX > frmMain.renderer.ScaleWidth Then Exit Sub
If viewPortY < 0 Or viewPortY > frmMain.renderer.ScaleHeight Then Exit Sub

Expand Down
Loading

0 comments on commit 17313d9

Please sign in to comment.