Skip to content

Development environment.

#4
Auto-translated
Hello. I've been playing "Heroes III" for over 20 years. And now I decided to create my own map. "Heroes III" is a 2D game, but since I am a person with limitations, I decided to make it 1D, so that the hero can only move along a line, not a plane.
I found the ideal line to be a spiral. To draw a spiral, you need to put many, many 1/8 circles together.
The circle is calculated using the formula y = sqrt(r * r - x * x). But we are dealing with a map with discrete values. To calculate these values for different radii, I wrote a program.
This program is a translation from "Turbo C", so I didn't focus on the content, but only on translating from one language to another.
Since the program turned out well and doesn't take too long to run, I'm posting a link to download the archive. The archive contains the program, screenshots, the executable file, and the project itself, which is compiled.

https://disk.yandex.ru/d/ygvAwU-jMQwGHQ

    Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
        Dim radius As Integer, max As Integer, counter As Integer, h As Integer

        REM radius - the radius for which the calculation is performed
        REM max - the maximum value for which the square root is calculated
        REM counter - the counter
        REM h - the calculated value of the circle boundary

        T1.Text = ""
        For radius = 1 To 60 REM Outer radius of 1/8 circle
            max = Int(radius / Math.Sqrt(2) + 1) REM Upper limit of calculations
            T1.Text = T1.Text & "r = " & radius & Chr(13) & Chr(10)

            For counter = 0 To max
                If counter = radius Then Exit For
                h = Int(Math.Sqrt(radius * radius - counter * counter - 0.0001) + 1) REM Calculation using the formula y = sqrt(r * r - x * x)
                If h < counter Then Exit For
                If h < radius Then T1.Text = T1.Text & counter & " - " & h & Chr(13) & Chr(10)
            Next

            T1.Text = T1.Text & Chr(13) & Chr(10)
        Next
    End Sub
Attachments 2
2 files attached • Total size: 49.0 KB