Ir ao conteúdo
  • Cadastre-se

Visual Basic VB6 como aumentar velocidade e tela no Raycasting?


Posts recomendados

eis a função do RayCasting:
 

Private Sub RayCasting()
    Dim StartAngle As Double
    Dim EndAngle As Double
    Dim IncrementAngle As Double
    Dim Distance As Double
    Dim RayX As Double
    Dim RayY As Double
    Dim RayAngle As Double
    Dim RayActualX As Double
    Dim RayActualY As Double
    Dim Wall As Integer
    Dim IncrementPixel As Double
    Dim IncrementStepSin As Double
    Dim IncrementStepCos As Double
    Dim AlturaLinha As Double
    Dim CorrecaoVisao As Double
    
    
    'Obter a posição inicial dos Raios com a posição do jogador:
    RayX = PlayerX
    RayY = PlayerY
    
    'o ângulo do meio tem de ser o ângulo do jogador
    StartAngle = PlayerAngle - DegreeToRadians(60 / 2)
    IncrementAngle = PlayerRotation / 10
    Distance = 0
    IncrementPixel = 2
    
    Dim RayCount As Long
    
    Picture1.Cls
    RayAngle = StartAngle
    For RayCount = 0 To CamWidth / 10 Step 1
        Distance = 0
        AlturaLinha = 0
        Wall = 0
        RayActualX = PlayerX
        RayActualY = PlayerY
        IncrementStepSin = Sin(RayAngle) * IncrementPixel
        IncrementStepCos = Cos(RayAngle) * IncrementPixel
        Do While (Wall = 0)
            Wall = LevelMap(Floor(RayActualY / MapResolution))(Floor(RayActualX / MapResolution))
            If (Wall <> 0) Then Exit Do
            RayActualX = RayActualX + IncrementStepCos
            RayActualY = RayActualY + IncrementStepSin
            Distance = Distance + 1
        Loop
        
        AlturaLinha = Floor(CamHalfHeight / Distance * MapResolution)
        
        DrawLine Picture1, RayCount, 0, RayCount, CamHalfHeight - AlturaLinha / 2, vbCyan
        DrawLine Picture1, RayCount, CamHalfHeight - AlturaLinha / 2, RayCount, CamHalfHeight + AlturaLinha / 2, colors(Wall)
        DrawLine Picture1, RayCount, CamHalfHeight + AlturaLinha / 2, RayCount, CamHeight, vbMagenta
        Me.Line (RayX, RayY)-(RayActualX, RayActualY), vbCyan
        
        RayAngle = RayAngle + IncrementAngle
        If (RayCount = CamWidth) Then Exit For
    Next RayCount
End Sub

não tenho controlo entre velocidade e tamanho da tela... a fica fica super pequena... mas não entendi como posso alterar o tamanho da tela.... só se repetir a 2ª 'Drawline" para dupla linha vertical

Link para o comentário
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!