VB6 : is possible convert radians to pixels?
the WindowViewe is 200 pixels.
so i need draw 200 lines between PlayerAngle(100 pixels) to 200. but how can i convert pixels to Radians... the PlayerAngle is the 100 pixel(the half of WindowViewe)

Private Sub rayCasting()
    Dim rayAngle As Double
    Dim IncreRayAngle As Double
    Dim RayX As Double
    Dim RayY As Double
    Dim rayCos As Double
    Dim raySin As Double

    'CamWidth is the viewe width... 
    IncreRayAngle = DegreeToRadians(PlayerFOV) / CamWidth 'getting the angle step

    'getting the player position to ray origin:
    RayX = PlayerX * MapResolution 
    RayY = PlayerY * MapResolution

    For rayAngle = PlayerAngle To 2 Step IncreRayAngle
        'draw the line with 50 of lenght thinking on it's angle:
        DrawLine Floor(RayX), Floor(RayY), Floor(RayX + Cos(rayAngle) * 50), Floor(RayY + Sin(rayAngle) * 50), vbRed
    Next rayAngle
End Sub

Recommended Answers

All 4 Replies

I thought you were about to move away from vb6? :)

As I mentioned in your previous post, it is difficult to answer your vb6 questions as the IDE is dead and we cannot test the code. I found the following link for you if you persist to use VB6 which might help you.

raycasting engine VB6 GDI32
Problem in making raycasting work
Tutorial in raycasting

You need to keep in mind that although it seems that your app is working on your machine (I assume it has been setup to run vb6 properly), it will most probably crash on any other user's system.

commented: for now, i must be with VB6 lol +1

AndreRet: that youtube video isn't share the code... the link zip is broken :(

commented: It opened fine for me - https://www.youtube.com/watch?v=q81XVHPhKaw +15

It opened fine for me - www dot youtube dot com/watch?v equals q81XVHPhKaw

AndreRet: i enter on link... but i was mean the zip file on description

commented: Ok understand. I am not about to download a zip file from in inknown developer sorry, keep on using Google for more answers. +0
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.