r/C_Programming • u/Embarrassed-Big-9305 • Jul 13 '26
Video How do C Programmers do it? (Epilepsy warning)
I've been reading a C book for about 4 months now. I originally picked it up so I can learn how my favorite video game worked. After nearly finishing the 400 page monstrosity, doing many of the exercises, and hand writing about 400 pages of notes, I went back to my game and see what I could do.
It was written in C++.
I got so mad at myself. I decided I cant let the effort I put go to waste. I spent 10 hours creating this bouncing ball. Not enough whimsical enjoyment has been brought to me for it to be called a "bouncy ball". Its just... a bouncing ball. I fucking suck at everything in life. What am I going to do?
***Edit*** I usually try to reply to everyone, for taking their time to reply, but some of them I cant find the words to reply with, so I apologize! But thank you for your words of encouragement :')
This post was mostly a small amount of venting, but mostly just a post to crack a joke. I apologize it didn't come off that way! I did learn a lot, a lot of which I wasn't expecting, so thank you all!
118
u/slimscsi Jul 13 '26
And you probably learned more by writing the bouncing ball program than you did with all the studying and note taking.
How do C programmers do it? They sit down and do it, make mistakes and repeat.
23
u/SimoneMicu Jul 13 '26
Is flashing because you are clearing the terminal instead of rewriting on top of already used characters. Reposition your cursor on 0,0. I am almost sure you used ANSI escape code `[2J` instead of `[H`
Please, if you have issue link something like the code used from a github repository or post in the request the code. If I didn't solve the issue modify the post at the end with `Edit:` then add useful information to help like you code.
8
u/FrequentHeart3081 Jul 13 '26
You're going to make the C Version of your C++ game. Learn how to simulate physics realistically in code, Learn how to render stuff to consoles (double buffering / triple buffering ??), learn how much expensive each printf command is, how to clean the console and make a C version and then drop the repo here for us to check ;)
2
u/TPIRocks Jul 13 '26
C++ is just an extension of C, it's not like you wasted time learning something useless. If you want to learn more about displaying text, ncurses, termios and ioctl calls. Learn that stuff and you'll know more about how to display data on a tty.
SDL and opengl or lvgl are for graphics/xwindows. Long ago, I made a video "player" for X windows. It would take a folder full of jpeg images, that were created from screen capturing video from a V4L compatible TV tuner card. This would let me play them back at selectable frame rates, or to single step back and forth through the images. I also had "hot keys" that would jump ahead, or back, 30 frames at a time. This all started with me trying to come up with my own motion detection algorithm, for a homebrew DVR, but I digress.
The program would display these images, using an SDL timer callback, to generate a callback, every 33 milliseconds. This was to give 30 frames per second, the exact same rate that they were originally captured.
I double buffered the output, so that one buffer was being filled, while the other was being displayed using SDL. It worked perfectly, no tearing or glitches in the displayed images, 640x480 30fps on a core2 duo. I believe TCL/TK was involved as well, but just for drawing text on top of the images.
Why all the 0s on the screen, instead of spaces?
22
u/kansetsupanikku Jul 13 '26
As a C programmer with epilepsy, I would read termios.h manual/info pages or use ncurses
11
u/Narrow-Progress-5229 Jul 13 '26
Before mastering something you must suck at something and keep at sucking at something.
9
u/MagicWolfEye Jul 13 '26
And your question is?
6
u/readmodifywrite Jul 13 '26
Pro tip for terminal UIs: don't use terminal clear and redraw the whole thing, that's how you get that blink. Just move the cursor and overwrite.
Better yet: Take a look at SDL. If you just want to do something simple like a bouncing ball, it's only a handful of function calls to set that up. The hardest part actually is drawing a circle since SDL doesn't have a circle API. You can find a ton of examples of how to do it on the net.
4
u/hey_buddy123 Jul 13 '26
look into double buffering; that flickering is gonna give me a fuckin aneurysm
3
u/KvThweatt Jul 13 '26
It looks like it’s because you’re clearing the screen instead of placing chars per position, do you have a pastebin to your code?
2
u/princepii Jul 13 '26
maybe you don't know what you wanna do and where to start!
just forget everything and write down 5 things u wanna program. then forget 4 of em and focuse on that whats worth to program for u.
then make your way up one by one. find the problems and solve em. learn how to solve em and why they are even problems.
if you wanna learn you will. if you don't wanna learn you basically will be stuck where you started and programming is just not for u.
try learning how to divide a bigger problem into smaller ones.
constant repitition is the keyword here. just do one thing until you understand and move on.
2
u/rupertavery64 Jul 13 '26
Instead of berating yourself, ask yourself and people questions.
Everyone sucked at one point.
2
u/skeptical-speculator Jul 13 '26
You don't suck at everything. It seems to me you've accomplished quite a lot, even if you didn't accomplish exactly what you wanted to accomplish. You deserve to be proud of what you've done.
2
u/ZeSprawl Jul 13 '26
C is the best foundation you can have for C++. Keep going. Even the best C and C++ programmers keep learning things for decades. Someone who has done either language for 5 years non stop is only at the beginning of developing their skills.
2
u/logic_circuit Jul 13 '26
Try it. If it does not work, try again. Eventally read the manual. However, you are supposed to be on well with theory.
2
u/P-39_Airacobra Jul 13 '26
I’ll let you in on a secret that many people don’t learn till they’re already through a degree and starting a software job. You learn by doing not listening. You sit down, inevitably fail, and then try again. That’s how you really master a language
2
u/Proman4713 Jul 13 '26
Hey, other comments have done their job, I'll just give you advice to use a different terminal emulator (like the new Windows Terminal since you're on Windows) than the basic Windows one to help with that epileptic effect
2
u/Legitimate-Fee7609 Jul 14 '26
C and C++ are very different languages. C is technically a strict subset of C++ but the approach you need to take for working with each is completely different
2
u/NomadicalYT Jul 13 '26
My question is why you’re going for a graphical program after learning C…
I almost exclusively use it for embedded programming and simple control scripts.
When I need visuals it’s always C++, Java, or Python (or JavaScript for web)
2
u/u32Vec Jul 13 '26
Stop treating learning programming like a class. Your notes are useless. You’ve learned 1 programming language. Now learn C++. You’ll be able to learn enough about C++ to read some of the code of the game in a month if you learn by writing C++ code and googling.
2
u/my_password_is______ Jul 13 '26
don't use C++
it is a garbage language
use C
use the raylib library
https://www.raylib.com/
https://www.raylib.com/examples.html
1
u/klacker2202 Jul 13 '26
Check out Raylib
1
u/AttitudeElectronic68 Jul 15 '26
You're doing it backwards. Learn to code first. Then write a program.
-3
u/Royal-Ambassador-960 Jul 14 '26
And that is why C is garbage. You have learned a valuable lesson.