i can create a DDA algoritm.. but pixel a pixel.
so what is the best speed for it?

IncrementPixel = 2
    For RayAngle = StartAngle To EndAngle Step IncrementAngle
        Distance = 0
        Wall = 0
        RayActualX = RayX
        RayActualY = RayY
        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 + IncrementPixel
        Loop

        ' Cast a ray from the player's position at this angle
        ' Check for collision with any walls
        ' Calculate the distance to the collision point
        ' Draw the wall section on the screen using the distance for perspective
        DrawLine CLng(RayX), CLng(RayY), CLng(RayActualX), CLng(RayActualY), vbCyan
        'Me.Line (CLng(RayX), CLng(RayY))-(CLng(RayActualX), CLng(RayActualY)), vbCyan
    Next RayAngle

these code ins't 100% completed, but what i need is just understand how can i speed up my calculations and win more speed.

It's been decades since I had to optimize such but hey, let's go!

  1. I see Sin() and Cos() in lines 7 and 8. Since we are dealing with graphics on a small screen (up to say 8K?) we could use a look up table. We don't have to be in floating point here since the screen is well inside 16 bit math.
  2. From what I recall, DrawLine() in line 21 uses VB6's Single data type so you may be incurring more overhead with CLng. Try CSng() instead.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.