How to Program Matrix Style Dripping Text (terminal, C, curses example)

  Рет қаралды 24,133

Jacob Sorber

Jacob Sorber

3 жыл бұрын

Patreon ➤ / jacobsorber
Courses ➤ jacobsorber.thinkific.com
Website ➤ www.jacobsorber.com
---
How to Program Matrix Style Dripping Text (terminal, C, curses example) // Have you ever wanted to make your computer look like the matrix with that drippy green text. This video shows you how to do it, using curses, in the terminal, using C. No fancy graphics libraries needed. No fancy math. Just Erie green characters dripping from the sky. Enjoy.
Related Videos:
• ASCII Art, Curses, and...
• The Debugger - a Short...
• Learn make in 60 seconds.
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
www.jacobsorber.com
people.cs.clemson.edu/~jsorber/
persist.cs.clemson.edu/
To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [ / jacobsorber ]
Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]

Пікірлер: 62
@JacobSorber
@JacobSorber 3 жыл бұрын
Apparently, this code works on iTerm2, but not on the standard terminal that ships with macOS. Thanks, Matt for helping point this out. I'll need to dig into this, but let me know if any of you beat me to it. 😀
@taylanunver
@taylanunver Жыл бұрын
Little clarification for 14:22 . The reason it goes y first and x second is not a quirk of curses. You are the one doing the switching here. Outer loop actually moves in y axis while inner loop moves in x axis. I've encountered this mismatch a lot when doing 2d grid like movements. Great video!
@gcm4312
@gcm4312 3 жыл бұрын
Could you make a video about CMake? :)
@Danhec95
@Danhec95 3 жыл бұрын
This helped me learn about the curses library, thanks!
@t0m0b0nes
@t0m0b0nes 3 жыл бұрын
Absolutely fun and a lot to learn! Impressive how you shake this one out of your wrist.
@jsnmad
@jsnmad 2 жыл бұрын
This was awesome! End product made me smile.
@klokibril
@klokibril 3 жыл бұрын
Followed along and learned a lot. Thank you!
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome. Glad it was helpful!
@erbenton07
@erbenton07 Жыл бұрын
Great job Jacob!
@nunyobiznez875
@nunyobiznez875 3 жыл бұрын
Curses is fantastic! It gives absolute mastery over a terminal window, while still being portable to nearly any system of the last 30 years, not just thanks to being a POSIX requirement, but also by it being flexible enough to do cool stuff like this. Even the sadly deficient Windows and MS-DOS have it with Cygwin, msys2 and pdcurses.
@ji1046
@ji1046 3 жыл бұрын
i think projects are very helpful along with theory
@AinurEru
@AinurEru 2 жыл бұрын
Hey Jacob, you've making extremely good videos on C, I'm basically binge-watching all your stuff now. For this one it was hard to follow, I think it's because you wrote the final thing before ever trying to execute it. There's a thing that happens when iterating, where the connection between the code as it's being written and the observed change in behaviour in response to that, that connection gets generated by that iterative process of - write->run->write->run .. Without that, unless you've already gone through with it before, you loose that connection pretty early on. It would have been easier I think if you just focused on a single drip at first, even without a tail - then run it. Then add a tail but without colorization and without fading - then run it. Then work on the fading - then run it. All the while with no randomness at all, and still with a single drip. Only once that's done, start duplicating it, and introduce randomization incrementally. I think it would have been much easier to follow that way.
@JacobSorber
@JacobSorber 2 жыл бұрын
Thanks for letting me know. I've tried to be more incremental in my more recent videos. I agree that it makes things a bit easier - seems to bring you more into the thought process.
@modolief
@modolief Жыл бұрын
Superb!!
@plumaligera8885
@plumaligera8885 3 жыл бұрын
Great video! What about some video tutorial on how to configure VS for C programming?
@diceandbricks
@diceandbricks 3 жыл бұрын
Very cool! Can we make that run in the background while using the terminal shell?
@maxim25o2
@maxim25o2 3 жыл бұрын
Wow, super, I wish to make this in C++. I even don't know when I will have time to try this code and learn it.
@abcddd580
@abcddd580 3 жыл бұрын
this is crazy cool
@simondurand-st-amour3284
@simondurand-st-amour3284 3 жыл бұрын
Amazing how i would've coded that with easily 10 times that number of line...nice work
@cyrusgomes4934
@cyrusgomes4934 10 ай бұрын
Hi Jacob awesome video! I wanted to ask you about a problem that I am facing when I run ./main in the bash terminal in vsCode. So when I run it do you happen to now why the terminal crashed? And is there a way to get the program working? By the way I am using a Linux system.
@MineKaikks
@MineKaikks 3 жыл бұрын
Wow, that is literally my next project after Snake in C! Awesome, but I think I'm gonna try to do it before watching before hand, what you think? btw, could you please recommend some good material to learn the curses library?
@JacobSorber
@JacobSorber 3 жыл бұрын
Sounds like a good plan. Best of luck with snake. As for resources, maybe check out Pradeep Padala's tutorial (tldp.org/HOWTO/NCURSES-Programming-HOWTO/)
@neillunavat
@neillunavat 3 жыл бұрын
Finally. My friends now call me a hacker. 😁
@JacobSorber
@JacobSorber 3 жыл бұрын
Nice. That's what I like to hear. Glad I could help. 😀
@michalski9141
@michalski9141 2 жыл бұрын
how did you write a bool in ui.h without getting red squiggly underscores??
@MrBeanbones
@MrBeanbones 3 жыл бұрын
I would love a video about threads in C!
@JacobSorber
@JacobSorber 3 жыл бұрын
I have a few of them on my channel. Check them out, and let me know what you think I'm missing.
@edakimling133
@edakimling133 3 жыл бұрын
Used to be a developer, so truly enjoyed this video. You have a nice clear voice, and you go at good pace. Sure, you could go even slower, but then the video would be too long. Folks can always pause if they want to review what you just did and it does not sink in. Nice presentation too; great you use an IDE with black background (what on earth were we thinking back in the 90's/2000's with the glaring white IDEs?) Wondering: would it be possible you think to somehow run this code in the background of your terminal (perhaps dimmed, or perhaps leave a space of few lines on the bottom clear)? Now that would be really awesome, because you could see this code run every time you used the terminal. Not sure if ncurses supports this sort of layering though (meaning I don't want to write an entire terminal just to add this to the background) Great video!
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks, Eda. A few people have asked about the background, and I'm really not sure if curses can pull that off (I'm doubtful). You could do a screen capture to create a video, and then if you're using something like "terminology" I think you can create a video background for your terminal. Seems like a bad idea, but I think it would work.
@rafaelvillalobos9145
@rafaelvillalobos9145 3 жыл бұрын
So the code was not working for me, there was only a black screen when I would run the program. Took me two days of studying the code to realize that I didn't write the statement that would set the live field of a drip to true in the routine try_add_drips.
@finmat95
@finmat95 Жыл бұрын
It seems that these functions (delwin(), endwin(), refresh(), color_set(). etc) return ERR code, meaning something went wrong. It happens everytime i run the program. I don't understand why.
@benvining9968
@benvining9968 3 жыл бұрын
hey Jacob -- great videos, I've learned a lot from you! Thank you for this wonderful public service! If you're looking for suggestions, I would love to see a video on basic software licensing. I want to make my projects open source, but the GPL seems to come with lots of provisos attached, and I'm not sure how I feel about all of them. It would be great if you could break down some of the prominent open source licenses, and maybe cover the basics of writing your own? Anyway, thanks again! Love your channel!
@JacobSorber
@JacobSorber 3 жыл бұрын
Hi Ben. Great suggestion. I'm definitely not a legal expert, but I've run into licensing issues in the past. So, I might have some helpful perspective here. I'll add it the list and see what I make happen. Thanks.
@benvining9968
@benvining9968 3 жыл бұрын
@@JacobSorber Thanks! Looking forward to it, I'm sure it will be very helpful :)
@pedro_alonso
@pedro_alonso 3 жыл бұрын
🤩
@ladyViviaen
@ladyViviaen 3 жыл бұрын
dripcurses
@yousseftobgy9319
@yousseftobgy9319 3 жыл бұрын
Hello Jacob, love your videos mate. Would be really appreciated if you could explain the implementation of Bellman Ford algorithm in C! Cheers!
@JacobSorber
@JacobSorber 3 жыл бұрын
Probably. Seems like I need to cover a few topics first, though: graphs...dijkstra's algorithm...but yeah,...I'll add it to the list and see what happens. Thanks. 😀
@yousseftobgy9319
@yousseftobgy9319 3 жыл бұрын
@@JacobSorber Thanks man!
@sinnytax
@sinnytax 3 жыл бұрын
Thanks, but I think I'll use cmatrix :D
@JacobSorber
@JacobSorber 3 жыл бұрын
Ah, yes indeed. I didn't realize that was there. Well, now you have an alternate implementation. 😀 Thanks!
@flippert0
@flippert0 7 ай бұрын
"Hallelujah, you are my saviour, man! My own personal Jesus Christ"
@stevegremory3849
@stevegremory3849 3 жыл бұрын
uh-Apparently I'm only getting one green line at a time, everything else is black- Why could that possibly be happening? I'm using iTerm 2.
@JacobSorber
@JacobSorber 3 жыл бұрын
Hmmm... not sure. Is the drip always in the same place, or does it show up in different X positions? I would look at the code that creates the drips. Make sure the drip spawn probability is high enough.
@stevegremory3849
@stevegremory3849 3 жыл бұрын
@@JacobSorber but everything is the same as shown in the video, and the drip shows up in different X locations, Yes, But only one at a time. I'll make a GitHub repo ASAP and comment! Thanks for the reply!
@arti5musicc
@arti5musicc 3 жыл бұрын
Dripp text Dripp text
@kenvat6344
@kenvat6344 3 жыл бұрын
nice name
@integral1191
@integral1191 3 жыл бұрын
C this is why I learned C
@cmdlp4178
@cmdlp4178 3 жыл бұрын
It might look even better if you had used a bold font
@JacobSorber
@JacobSorber 3 жыл бұрын
It might. If you try it out, I would love to hear how it goes.
@cmdlp4178
@cmdlp4178 3 жыл бұрын
@@JacobSorber I coded a Matrix style clock years ago in C++ (2018): github.com/cmdLP/Countdown (Unfortunately: I did write it specifically for windows back then). I did use a single color pair. but I used special characters like the block characters. I might one day rewrite it for curses
@Matt-kl1mx
@Matt-kl1mx 3 жыл бұрын
For some reason, instead of having different shades of green, I have multiple colours. Why is this happening to me when it didn't happen to you?
@JacobSorber
@JacobSorber 3 жыл бұрын
It's hard to say from here. Some terminals have different color capabilities. That could be it. Or, you might have forgotten to set the colors?
@Matt-kl1mx
@Matt-kl1mx 3 жыл бұрын
@@JacobSorber I wrote what you wrote for the set_colors() function. I'm using a bash terminal on MacOS Mojave if that helps
@JacobSorber
@JacobSorber 3 жыл бұрын
@@Matt-kl1mx I was using iTerm2 (not the standard terminal). Didn't expect that to matter, but it's worth a try.
@Matt-kl1mx
@Matt-kl1mx 3 жыл бұрын
@@JacobSorber I downloaded iTerm2 and ran the program, and it worked. Thanks! :)
@JacobSorber
@JacobSorber 3 жыл бұрын
@@Matt-kl1mx Ah, interesting. Good to know. I'll have to look into the difference. Thanks.
@bokunochannel84207
@bokunochannel84207 3 жыл бұрын
imagine the matrix segfault
@RickertBrandsen
@RickertBrandsen 3 жыл бұрын
Is it just me or you are writing the c code in more pythonic way? :D
@jakobfredriksson2272
@jakobfredriksson2272 3 жыл бұрын
Wanna create a second YT account and like again!
@JacobSorber
@JacobSorber 3 жыл бұрын
Well, I guess you could....🤔
@jakobfredriksson2272
@jakobfredriksson2272 3 жыл бұрын
​@@JacobSorber Haha! If it wasn't for the actions made by the industry to hedge against automatic email creation - pick pictures with an apple in it etc (way ahead of my current skills to solve) I'd love to write code to create a ton of YT identities and like your channel and bless the algo gods. As an amateur/hobby programmer I'm unfortunately not there...yet.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 46 М.
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 3,4 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 13 МЛН
МАМА И STANDOFF 2 😳 !FAKE GUN! #shorts
00:34
INNA SERG
Рет қаралды 4,4 МЛН
Василиса наняла личного массажиста 😂 #shorts
00:22
Денис Кукояка
Рет қаралды 10 МЛН
How does fork work with open files?
13:12
Jacob Sorber
Рет қаралды 9 М.
Transform Your Scripts With Bash Simple Curses
16:15
DistroTube
Рет қаралды 106 М.
Coding a Bouncing Ball in Terminal
1:26:29
Tsoding Daily
Рет қаралды 81 М.
When do I use a union in C or C++, instead of a struct?
11:18
Jacob Sorber
Рет қаралды 67 М.
Is the C programming language still worth learning?
9:27
Jacob Sorber
Рет қаралды 89 М.
Making variables atomic in C
11:12
Jacob Sorber
Рет қаралды 35 М.
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 95 М.
Use curses, don't swear
30:15
Next Day Video
Рет қаралды 85 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 137 М.
fgets is unsafe! So what’s the alternative?
11:32
Code With Huw
Рет қаралды 2,7 М.
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 3,4 МЛН