r/CodingForBeginners • u/Krastesoff • Oct 25 '26
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;
}
}
}
145
Upvotes



View all comments
2
u/Gold-Cat-9392 23d ago
Nowadays the trade of for longer names is not as strong as it was in old days. We have autocomplete in most ides including vim and nvim. So instead of // l- current line, I recommend you use for(int line...). It reduces the load when you are going through the code.
Your global variable len doesn't need to be in float, you are using it for integer indexing. Length as a integer value will suit more. Use float only if you are sure that the range for the variable includes decimals. Also use f for floats. `float power = 10.0f;` just a good practice