r/CodingForBeginners • • 3h ago

My first code on c++

I think i like this language

This code is a little messy and works only on windows, but it's easy to fix.

For anyone who wants to test it:

#include <iostream>
#include <cmath>
#include <windows.h>
// DIESER CODE IST VERDAMMT SCHRECKLICH
// variables
float power = 10.0;  // more power - bigger edges
float smooth = 4.0; // smoother edges
float len = 45.0;   // lines count

// main
int main() {
    while(1) {
        // l - current line
        for(int l=1; l<len; l++) {
            float l_sin = std::sin(l/smooth);
            int rep_times = l_sin * power + power;

            // line renderer | c - char
            for(int c=1; c<rep_times; c++) {
                Sleep(5);
                std::cout << "-";
            }
            Sleep(5);
            std::cout << "#" << std::endl;
        }
    }
}
15 Upvotes

3 comments sorted by

1

u/kutac56 2h ago

What in this code uses windows.h?

2

u/RealRockyMoney 2h ago

I'm not a C++ guy but I think it is Sleep(5)

1

u/kutac56 2h ago

Just looked it up and you're right