how working with RayCasting?
i have these code for RayCasting:
Code:
Private Sub rayCasting()    ' O RayAngle é o angulo atual do "raio".
    ' se ele começa olhando para angulo 90º e tem fov 60, então o rayAngle vai de 60 até 120, sendo incrementado por fov/width
    Dim rayAngle As Long
    rayAngle = PlayerAngle - PlayerFOV / 2
    ' Para Cada coluna da tela
    Dim raycount As Long
    For raycount = 0 To CamWidth
        ' Player dados
        Dim RayX As Double
        Dim RayY As Double
        RayX = PlayerX
        RayY = PlayerY
        


        ' Com cosseno e seno do angulo conseguimos a direção do raio sobre o grid a partir do ponto de visão.
        ' Aqui teremos a direção do raio sobre a matriz e também o modulo (passo)
        Dim rayCos As Double
        Dim raySin As Double
        rayCos = Cos(DegreeToRadians(rayAngle)) / RayCastingPrecision
        raySin = Sin(DegreeToRadians(rayAngle)) / RayCastingPrecision


        ' Colisão do raio com as paredes
        Dim Wall As Long
        Wall = 0
        While (Wall = 0) ' Aqui o "raio" seria tipo uma progetil que sai do personagem até colidir com uma parede
        
            RayX = RayX + rayCos ' novo x do raio
            RayY = RayY + raySin ' novo y do raio
            Wall = LevelMap(Fix(RayY))(Fix(RayX)) ' verifica colisão com a parede (não nulo na matriz)
        Wend


        ' Distancia até a parede (teorema de pitagoras), uma vez que temos o (X,Y) do personagem e da parede
        Dim distance As Double
        distance = Sqr((PlayerX - RayX) ^ 2 + (PlayerY - RayY) ^ 2)


        ' Correção olho de peixe (sem colisão com a parede), melhora a vista em corredores ou proximo de paredes
        distance = distance * Cos(DegreeToRadians(rayAngle - PlayerAngle))


        'Altura da parede em consequência a distancia
        'quando mais longe a parede está menor ela é e vice versa, são inversamente proporcionais
        Dim WallHeight As Long
        WallHeight = Fix(CamHalfHeight / distance)
        If (WallHeight > CamHalfHeight) Then WallHeight = CamHalfHeight
            


         'Desenhando as paredes usando os tamanhos calculados acima
        DrawLine raycount, 0, raycount, CamHalfHeight - WallHeight, ColorConstants.vbCyan 'céu
        If (Wall > 0) Then DrawLine raycount, CamHalfHeight - WallHeight, raycount, CamHalfHeight + WallHeight, colors(Wall) ' Wall
        DrawLine raycount, CamHalfHeight + WallHeight, raycount, CamHeight, vbMagenta ' chão
        Wall = 0
        ' Incremento da ray
        rayAngle = rayAngle + PlayerFOV / CamWidth
    Next raycount
End Sub
i have notice that the entire 'Wall' is drawed with same color... even if the 'Wall' been a different color... even 1 vertical line is red, the line will be green...