No video

Code-It-Yourself! Tetris - Programming from Scratch (Quick and Simple C++)

  Рет қаралды 1,495,379

javidx9

javidx9

Күн бұрын

I mentioned in an earlier video that programming a Tetris clone is a good way to get going with programming as it makes you think about algorithms. Putting my money where my mouth is, I went ahead and did just that.
GitHub: github.com/One...
/ discord
Blog: www.onelonecode...

Пікірлер: 1 600
@javidx9
@javidx9 5 жыл бұрын
lol, because I've answered this 200 times now, please ensure you have unicode enabled for your compiler. In VS, that's Project Properties -> General -> Character Set.
@tommy2nes
@tommy2nes 5 жыл бұрын
I am compiling this from the command prompt using cl, I am having the same problems related to the unicode thing, do you know if there is a way to set this from the command line or will i have to use the IDE? thanks
@javidx9
@javidx9 5 жыл бұрын
Just define UNICODE and _UNICODE with your compile command
@VictorPeraltaGomez
@VictorPeraltaGomez 5 жыл бұрын
@@tommy2nes #ifndef UNICODE #define UNICODE #endif #ifndef _UNICODE #define _UNICODE #endif Before #include
@Torchl146
@Torchl146 5 жыл бұрын
sorry if I ask another easy to answer often asked question, but how is this important?
@javidx9
@javidx9 5 жыл бұрын
Its a good question. Simple answer is, not everyone uses a Latin alphabet. Regular character types and strings dont have enough precision to represent all languages. For hobby needs, this is less important, but professionally your customers might need additional language support. Its also easier to include from the beginning rather than engineer in later.
@OxygenMagnet
@OxygenMagnet 6 жыл бұрын
"Totally unnecessary, but it looks cool" - everything i've ever programmed
@bigrafati1221
@bigrafati1221 5 жыл бұрын
This comment made my day.
@SealedKiller
@SealedKiller 5 жыл бұрын
So true
@tylermassey5431
@tylermassey5431 4 жыл бұрын
Is it bad that I would have just said to hell with this "? 1 : 0" business and added the result of the bool directly?
@Anon_581
@Anon_581 4 жыл бұрын
​@@tylermassey5431 Nope! I was thinking exactly the same thing. In fact, bool to int conversion is implicit and is guaranteed to be 1 for true and 0 for false by the C++ standard (see the answers on stackoverflow.com/questions/5369770/bool-to-int-conversion). I guess the usage of the ternary operator was to be explicit about the assignment for readability purposes.
@toxicitzi357
@toxicitzi357 4 жыл бұрын
If it looks cool on the screen, then it's most likely very necessary.
@bredmond812
@bredmond812 4 жыл бұрын
Me: "I'm sick of long introductions on videos. Wastes my time." javidx9: "Hello! Let's make Tetris." *proceeds to begin tutorial*
@madhoshyagnik3679
@madhoshyagnik3679 4 жыл бұрын
That was kinda cool, I appreciate such introductions.
@cboyslim5490
@cboyslim5490 3 жыл бұрын
i agree. love this dude's videos even though i'm late to the party
@tractorman7733
@tractorman7733 3 жыл бұрын
yeah, I just gotta love it when the intro is longer than the one little piece of info that I forgot when working on a project.
@BenoitAdam
@BenoitAdam 5 жыл бұрын
00:00 Introduction 01:34 Create Tetromino (Old Way) 03:13 Create Tetromino (Algorythmic trick, may not work on slow systems due to usage of multiplication) 03:30 Explanation by Drawing (rotation trick) 07:24 Programming the function 08:13 Playing Field 09:18 Function (initialization) 10:30 Game Loops 12:45 Timing (Not all computer are the same) 13:40 Collision Detection ===== 20:10 TEST N°1 ===== == 20:10 GAME TIMING == 21:00 INPUT LOGIC == 22:00 GAME LOGIC ===== 23:07 TEST N°2 ===== ===== 23:32 TEST N°3 ===== 23:52 C++ Optimisation 24:30 Rotation ===== 24:49 TEST N°3 ===== 25:00 Rotation Hold 26:10 Fall & Speed 27:25 Force Piece down 28:25 Block & Next Piece ===== 29:30 TEST N°4 ===== ===== 31:55 TEST N°5 ===== 33:50 Increase Speed & Difficulty
@pby1000
@pby1000 5 жыл бұрын
Benoit Adam We all appreciate it!
@chrissmith1152
@chrissmith1152 5 жыл бұрын
thanks capt
@robz537
@robz537 5 жыл бұрын
thx a lot
@sevenedus
@sevenedus 4 жыл бұрын
God bless you
@SirGeldi
@SirGeldi 4 жыл бұрын
Old Way is definitely faster on a C64 in BASIC. And pre-calculating is even faster but it consumes much more memory .
@sieyk
@sieyk 4 жыл бұрын
12:27 "because I don't want this video to be half an hour long..." *looks at length of video*
@kuchigyz6231
@kuchigyz6231 4 жыл бұрын
i'd like your comment but i don't want to ruin your likes number
@filmcase1683
@filmcase1683 4 жыл бұрын
@@kuchigyz6231 Your too late... I'm sorry but your noble deed has gone unrecognised.
@inigo8740
@inigo8740 4 жыл бұрын
It, *technically*, isn't half an hour long. It's longer.
@vaibhavagale7969
@vaibhavagale7969 4 жыл бұрын
Its deserving.
@sieyk
@sieyk 4 жыл бұрын
@@mykyta1235 it was a joke dude, chill
@KnutKelkeschoss
@KnutKelkeschoss 5 жыл бұрын
It's like watching Bob Ross using a keyboard instead of a brush - awesome!
@superslayerguy
@superslayerguy 4 жыл бұрын
You hit the nail on the head
@dhananjaydeshmukh3469
@dhananjaydeshmukh3469 4 жыл бұрын
Fucking a right
@DrummerJacob
@DrummerJacob 4 жыл бұрын
This is one of those comments you wrote specifically so that the creator might read and like it.
@KnutKelkeschoss
@KnutKelkeschoss 4 жыл бұрын
@@DrummerJacob I write all of my comments so that the content creators can read those... also, I write most my comments so that the content creators like those. Most of the times there are already sufficiently many they probably don't like, it's a Internet thing...
@javidx9
@javidx9 4 жыл бұрын
And it was read, and liked! Thanks!
@JarmamStuff
@JarmamStuff 5 жыл бұрын
I've challenged myself to finally make "my own" app by, well, making Pong in C#, and I find myself revisiting this video constantly to get a sense of how to treat game logic, timing etc. Highly, highly inspirational stuff - you, sir, are a scholar and a gentleman.
@javidx9
@javidx9 5 жыл бұрын
Thank you Jarmam, you made a great decision to get stuck in and start coding, good luck!
@waterjackattack2829
@waterjackattack2829 4 жыл бұрын
If your output looks all wonky but you've followed his code 100% , it's probably that your default console window size is different. Open Command Prompt, right click the window, select properties, go to layout and you can see your window size. Then just change nScreenWidth/Height to the same values as your console window size.
@mr_noodler
@mr_noodler Жыл бұрын
This is golden advice!! Thank you my screen was wonky!
@jasonli2400
@jasonli2400 Жыл бұрын
For Windows11, you need to right-click and go to settings, then in the startup tab change the launch size
@federicosalvetti4286
@federicosalvetti4286 6 ай бұрын
I love you
@rianlima7785
@rianlima7785 6 ай бұрын
Thanks you
@hijarian
@hijarian 2 ай бұрын
thank you very much, this advice was very helpful
@robertnurss6511
@robertnurss6511 6 жыл бұрын
Fantastic! Thanks Man! I'm going to sit down with my son and daughter to watch this and start game programming! I program a little (more coding than anything else) but my kids have been bugging me for years to show them game programming (which I know practically nothing about). Your explanations, descriptions of concepts, video and graphics are fascinating and all set to a perfectly watchable cadence. Watched several other videos you've posted ~ well done!
@javidx9
@javidx9 6 жыл бұрын
Hey thanks Robert, that's a really nice thing to say, and it's great to involve your family in the fun! Cheers!
@microtree5392
@microtree5392 5 жыл бұрын
7:03 0°) i=wy + x 90°) i=w(w-1) + y - wx 180°) i= w^2 - 1 - wy - x 270°) i= w - 1 - y +wx Don't mind me, just saving for future reference
@esra_erimez
@esra_erimez 5 жыл бұрын
Brilliant
@peterhooper2643
@peterhooper2643 5 жыл бұрын
I'm going to steal this trick
@Li0nheart1810
@Li0nheart1810 5 жыл бұрын
en.wikipedia.org/wiki/Rotation_matrix
@djambradollo4033
@djambradollo4033 5 жыл бұрын
😂😂
@SirGeldi
@SirGeldi 4 жыл бұрын
Thank you
@daemyno
@daemyno 5 жыл бұрын
Your video was recommended by youtube, by curiosity i wanted to check it, i have nothing to do with C++ my stack is completely different, however, your simple way to explain and your behavior which is basically professional and friendly at the same time made you earn a new subscriber ! I'm a big fan of you man :) keep it up
@javidx9
@javidx9 5 жыл бұрын
lol Daemyno, thanks man, that is much appreciated!
@jphvnet
@jphvnet 4 жыл бұрын
Exactly, it is a C program. Nice to see how difficult I find my old (and natural) way of thinking in this code. Sometimes OOP sucks (imposible vectorization operations), but sometimes saves developer's mental health.
@Judderplush
@Judderplush 5 жыл бұрын
This video has made me realise how straight forward coding can be when it's explained in the correct way, thank you for this!
@javidx9
@javidx9 5 жыл бұрын
That's great to hear Corey, I appreciate the feedback!
@user-ov5nd1fb7s
@user-ov5nd1fb7s 6 жыл бұрын
There is something very cool about old-school developers. They tend do write simple code to solve complicated problems. These days, newer developers write complicated code to solve simple problems.
@purpleice2343
@purpleice2343 5 жыл бұрын
These videos are showing hobbyist projects which are then simplified further just so he can explain in as short amount of time as possible (he already needs over 30mins at the time to do so even when simplifying it), he writes simple code because writing simple code is how you show off an idea... It's not built nor is supposed to be robust, it's an example. We don't complicate it for fun, we think about what we will need to do with it 5 maybe 10 years later... You don't need to be old-school developer to write an example simple enough to get the point across, the problem is that bad developers think they can teach others and then shove their 3k LOC example that barely works when that could be 300 loc and have the same idea
@samriviera6299
@samriviera6299 5 жыл бұрын
There are so many developers out there, what do you even base your opinion on?
@jordixboy
@jordixboy 5 жыл бұрын
"Good Practices" "solid" "oop" "ddd" "hexagonal architecture", "Value Objects" "DTO's" "Patterns" "Anti-Patterns" ... these days over-engineering is completely fine...
@peterbonnema8913
@peterbonnema8913 5 жыл бұрын
@@jordixboy You are naming techniques, ideas and practices that are suitable, if not, absolutely mandatory for any bigger scale project. Specifically things like DDD, hexagonal architecture and value objects (and its companions entities and aggregates) were meant to make webscale architectures tracktable. So no, if you use those ideas in the way they were intended then that is not over-engineering. The definition of DDD even states when to use it's technical aspects and when not to.
@talkohavy
@talkohavy 5 жыл бұрын
So... machine-learning of today is trying to solve a simple problem? Please help me understand your wits and logic.
@Lep_19
@Lep_19 5 жыл бұрын
I'm still blown away by that method of rotation. All other videos on this topic that I've seen have done some method of altering the order of the string (or array in some cases) itself, but reading the same string in different ways is such a clever workaround. I know I'm a little late to this one, but that doesn't mean it isn't still educational and impressive. Good stuff as always!
@javidx9
@javidx9 5 жыл бұрын
lol thanks Lep, I've solved many programming problems by turning the problem upside down, I hope seeing this helps the viewers understand there are many routes to the end result.
@YourAliasIsNotAvailable
@YourAliasIsNotAvailable 3 жыл бұрын
The rotation with multidimensional array could also be done without changing the array itself. You just have to change the order in which you read the array.
@weltvonalex
@weltvonalex 4 жыл бұрын
the best intro in a long time, wow straight to the point an no long story how you spend your childhood with your dad on a lake playing tetris, thank you! thank you!
@javidx9
@javidx9 4 жыл бұрын
Thanks weltvonalex, yeah, nobody wants that....
@ScaerieTale
@ScaerieTale 2 жыл бұрын
I started watching the RPG video in this playlist, and it referenced the platformer, so I started watching that. It referenced the Worms project, so I went back to that. And then I said "YOLO" and started from the beginning. I am *so* glad I did. This is amazing (and I learned how powerful arrays can be - bonus!). Thank you for these incredible videos :)
@nomoturtle1788
@nomoturtle1788 4 жыл бұрын
I had a problem at 12:25, the hash symbols were dispersed all over the console. Unless I've made a mistake, it seems that the nScreenWidth and Height don't affect the console window (though they probably should), but do affect the indexing we use. Setting nScreenWidth to 120 fixed the indexing for me and drew the right thing. You didn't mention including the libraries, so that caused me a lot of headache trying to find out why a function wouldn't work, looked at your github eventually though. Also the Scoring, it should probably be nScore += (1
@finesseandstyle
@finesseandstyle 4 жыл бұрын
Thanks a lot you're a savior!
@CB66941
@CB66941 4 жыл бұрын
Thanks man. I too had that same problem with the hash symbols everywhere.
@PeterParker-vn2hv
@PeterParker-vn2hv 4 жыл бұрын
Thanks dude.
@Nick-lx4fo
@Nick-lx4fo 3 жыл бұрын
Thanks, I was wondering why it did that.
@teroton2012
@teroton2012 2 жыл бұрын
For the window error, if you rescale the window with your mouse, it will also adjust that area and realign the grid
@TheBigupz
@TheBigupz 6 жыл бұрын
This is exactly what i was looking for, well explained simple to learn, and loads of great videos, keep it up, instantly subscribed
@javidx9
@javidx9 6 жыл бұрын
Thanks NutritiveApple, I hope you find some useful stuff!
@Torchl146
@Torchl146 5 жыл бұрын
exactly what I'm thinking, thanks
@BDCOMBO
@BDCOMBO 4 жыл бұрын
absolutely love how friendly you are man, exceptional explanation skills too. Keep it up
@HalValla01
@HalValla01 5 жыл бұрын
javid: Because I don't want this video to be half an hour long..." Me: *but it is*
@qwerasdfhjkio
@qwerasdfhjkio 3 жыл бұрын
No! It's longer ;D
@fettigeredgar
@fettigeredgar 4 жыл бұрын
"Hello! Let's make tetris" is possibly the most efficient video introduction i've ever witnessed :D
@vaendryl
@vaendryl 4 жыл бұрын
"Because I don't want this video to be half an hour long..." good thing it's only 36 minutes then.
@tw7522
@tw7522 5 жыл бұрын
The rotate function is absolutely great! I always had all possible rotations stored in my shapes array, but various addressing functions are absolutely ingenious way to solve this problem in a simple and elegant way!
@elijahasefa389
@elijahasefa389 3 жыл бұрын
Javid is the type of guy to have invented the personal computer if he was born in the right place and time. Amazing work.
@LightLord1870
@LightLord1870 7 жыл бұрын
Just ran into this video, and your way of teaching and explanation is fantastic. Seen plenty of videos of programming and you really have something nice here.
@javidx9
@javidx9 7 жыл бұрын
Thanks LightLord, I appreciate that!
@0x9f000
@0x9f000 Жыл бұрын
6 Years Later and You Still Reply to Comments, how admirable. thank you for your hard work. I plan to follow most of the "Do-It-Yourself" Series because I want to try and make a 3D Voxel Game with c++ and think they would help.
@javidx9
@javidx9 Жыл бұрын
Hey Cheers Mason! My videos will cover the basics of the techniques involved but to get the performance you might need will require some GPU help.
@iamrysheem
@iamrysheem Жыл бұрын
@@javidx9 this is actually very impressive that you still reply to old videos. It's new to somebody everyday.
@setharnold9764
@setharnold9764 3 жыл бұрын
Thanks for this, I spend all my time on mature systems, it's fun to see the starting point and how to step it along one feature at a time.
@andrii1701
@andrii1701 5 жыл бұрын
Original Tetris was written in the command promprt as well but it was using double ▓ bars instead of alphanumeric chars.
@gamesgarden8709
@gamesgarden8709 Жыл бұрын
Nice one! I used for rotation another approach. To rotate any position (x, y) around center (0, 0) you can use formula x = y; y = -1 for CW rotation, and x = - y; y = x for CCW.
@SaifUlIslam-db1nu
@SaifUlIslam-db1nu 5 жыл бұрын
Will start binge watching this from today, after all, I've got a semester break from University. Your videos are helping me start and understand game programming in C++. Thank you for your efforts. :)
@javidx9
@javidx9 5 жыл бұрын
Good to hear Saif!
@jakewhiney2278
@jakewhiney2278 Жыл бұрын
I've been looking for a fellow like you for months. Thank you for your content it'll help me rise from a basic understanding of programming to a practical tangible experience I've been looking for.
@derpythecate6842
@derpythecate6842 3 жыл бұрын
Funny thing you should mention about too many people doing things about graphics but not about engines. I was finding a tutorial on how to make a simple tetris that I could run in my linux terminal for decoration, and wanted to implement something lightweight using ascii like what you did in the video. What a serendipitous find!
@biqbicle4982
@biqbicle4982 Жыл бұрын
what a what?
@khrissxander
@khrissxander 5 жыл бұрын
Top notch channel, excellent content. Keep up the great code teaching friend.
@jensborgmann2588
@jensborgmann2588 5 жыл бұрын
I stumbled across your Code-It-Yourself videos and as a IT teacher i must say that i really enjoy watching them. Great work !
@mr_noodler
@mr_noodler Жыл бұрын
I did a code along to this, and got it working! What a thrill! I had a lot of fun. I like coding along while you are explaining things so I get a feel of how it works. Some of it made my brain numb but I suppose it's just part of learning. Great video! Thanks for making it, I learned a lot, especially about handles to the console window, cool stuff!
@Nate-mi2se
@Nate-mi2se 2 жыл бұрын
Rotating 2,147,483,648 times will overflow and Rotate() doesn't handle negatives properly, COMPLETELY UNUSABLE CODE!!! XD
@mr-n0-aim42
@mr-n0-aim42 4 жыл бұрын
Me: "I study Software Engineering, this schouldn't be to hard.... creats first Variable.. wtf is a wString ?" XD
@nonsudunk
@nonsudunk 4 жыл бұрын
It's a W shaped String, duh
@thegardenofeatin5965
@thegardenofeatin5965 4 жыл бұрын
Apparently it's a "wide" string, because though he failed to mention it, this tutorial is Unicode compliant. Just in case.
@inigo8740
@inigo8740 4 жыл бұрын
@@thegardenofeatin5965 apparently it's because Windows.h requires wstring and wchar_t
@facelessn0mad
@facelessn0mad 4 жыл бұрын
@@inigo8740 Thank heavens Linux does Unicode as UTF-8 :P
@ferry6700
@ferry6700 4 жыл бұрын
Every body know w is stand for womboo , sly
@neizih2809
@neizih2809 2 ай бұрын
I always thought I had to be genius enough to come up with this only using my head, now I realize I will never learn if I continue thinking like that. Thanks man
@TheRealFaceyNeck
@TheRealFaceyNeck 5 жыл бұрын
I'm in a C++ class right now. I'm not doing well on the course material, but I'm getting a lot out of your videos! Thanks, mate. 7 mins into this video and I've already learned more than I believe I will learn in a half hour during my class this morning. Shit, I should probably hop in the shower... ah, a few more mins on this Tetris project......
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 Жыл бұрын
uuahh. gross.
@zekezandbergen4435
@zekezandbergen4435 7 жыл бұрын
"I don't want this video to be half an hour long" Video is 36 minutes. Teasing aside, nice video and clean code.
@javidx9
@javidx9 7 жыл бұрын
Hey thanks Zeke, yeah I learned a lesson there! There's very little planning on this channel. Pleased you enjoyed it though!
@lukenukem8028
@lukenukem8028 3 жыл бұрын
[12:25] - When mine prints, I get three single-spaced gapped buckets side-by-side with 28 spaces between the buckets. The 1st and 3rd on the same level and the 3rd with the bucket bottom. ~The funny thing is, even when I copy and paste your raw code from GitHub, I still get the same three gapped buckets split apart.
@lukenukem8028
@lukenukem8028 3 жыл бұрын
What I also notice is, the console window doesn't change size like yours does. Mine stays at 120x30 despite your 80x30 code. How can there be entirely different outcomes from identical raw code???!
@lukenukem8028
@lukenukem8028 3 жыл бұрын
I have to manually change the console window to 80x30 in the console window properties for it to work. Why don't we invoke a function that changes the actual size to our screen size variables? Like in C#. Also, changing the window size destroys it, and it doesn't go back to normal.
@Meatbrick
@Meatbrick 3 жыл бұрын
I wish this would get more attention, or at least an answer.
@javidx9
@javidx9 3 жыл бұрын
See "Introducing ConsoleGameE gine" and/or any of the next 50 videos or so.
@eueueqi
@eueueqi 4 жыл бұрын
i have a dream of making my own indie game, but i don't even have the knowledge nor connections or even resources. for now, I'm gonna start small and learn about this classic yet beloved game. Thank u !
@javidx9
@javidx9 4 жыл бұрын
Hi ella, like all things, programming requires practice and patience. It sounds like youve recognised your limitations, which is a fantastic (and often overlooked) start because now you know what to do next! Good luck with your project!
@eueueqi
@eueueqi 4 жыл бұрын
@@javidx9 thank you so much ! These are very encouraging words and I will try to educate myself as extensively as possible. This is a really great video, I'll be sure to check out your others !
@xtetn4888
@xtetn4888 3 жыл бұрын
If you ask google to define a programmer, his face will show up. Love the tutorial man!
@Rraccd
@Rraccd 7 жыл бұрын
By far the best tutorial and not just for code but your very user friendly comments and explanations in the video and below. I am going to definitely recommend any new programmer to subscribe.
@javidx9
@javidx9 7 жыл бұрын
Hey Thanks D Rrac! That means a lot.
@megabrogames239
@megabrogames239 6 жыл бұрын
great video. I'm not using C++ but have learnt a good technique from you for how to make the blocks
@javidx9
@javidx9 6 жыл бұрын
Thanks MegaBro, glad the video was useful!
@GodofWar1515
@GodofWar1515 6 жыл бұрын
Hey javidx9! Thanks for this great video. It’s good that you show that graphics is not the only important thing to focus on but also the mechanics and engine that run hidden within the code.
@javidx9
@javidx9 6 жыл бұрын
Hi Lucas, thanks man!
@michaeltennant8312
@michaeltennant8312 3 жыл бұрын
If you are having issues with the window size you can correct it to the right size with this in the main block before the game loop: // Resize window HWND hwnd = GetConsoleWindow(); if (hwnd != NULL) { MoveWindow(hwnd, 200, 200, 680, 400, TRUE); }
@dollopbingo5643
@dollopbingo5643 3 жыл бұрын
Tysm, I was so confused
@michaeltennant8312
@michaeltennant8312 3 жыл бұрын
@@dollopbingo5643 np
@digochuanxi9846
@digochuanxi9846 2 жыл бұрын
Thanks my friend!!
@TheCede555
@TheCede555 6 ай бұрын
Thanks for the content! I'm very new to C++ and programming as a whole, and this was the perfect size to be finished in one sitting as well as being old enough to encourage some simple debugging! Had a blast working through it!
@Kimchi_Studios
@Kimchi_Studios 5 жыл бұрын
You are a fantastic teacher. What a great way to learn! I do micros in C but your videos are very helpful for anyone. Going to definitely try this out soon.
@ComposingGloves
@ComposingGloves 6 жыл бұрын
Thank you so much for videos like these. They are immensely helpful and bridge the gap between beginner to advanced! If you ever need a sound guy for music for SFX give me a ring! I spent forever trying to understand how the print function worked but I couldn't seem to get it to work in another program I had written. I searched all over for an answer, and had given up but upon coming back I finally realized I had a < when I needed > Gotta love programming.
@javidx9
@javidx9 6 жыл бұрын
No problem Composing Gloves, programming certainly has its moments and frustrations! I might be looking at SFX in an upcoming video, so it would be interesting to hear your thoughts!
@BubLblckZ
@BubLblckZ 6 жыл бұрын
Composing Gloves "Because i dont want this video to be half an hour long" and its 36 min
@foulzy423
@foulzy423 5 жыл бұрын
Ha, this is exactly what I need, I have a school assignment coming up and this is what I wanted to create, my teacher said it wasn’t going to work in c++, so I’m gonna prove him wrong
@alias4470
@alias4470 5 жыл бұрын
Amazing use of simplicity here. Also loved learning about the screen buffer and how that can be used to manipulate the window instead of CLS. Thanks a lot! You earned a sub
@javidx9
@javidx9 5 жыл бұрын
Hey thanks alias, much appreciated! Its a windows specific way of doing these things, but enables loads of fun for those starting out with programming.
@alias4470
@alias4470 5 жыл бұрын
javidx9 yep! Glad I use windows so I can have fun with your engine
@neuemage
@neuemage 6 жыл бұрын
Wish I had youtube growing up, if you wanted to see programmers code you had to go to a lab and hope they allow you to hang out
@jakubstastny1327
@jakubstastny1327 4 жыл бұрын
When you are so good in programming, that you can make cool games that run on command line.
@shinichikudo8632
@shinichikudo8632 4 жыл бұрын
You are that kind of guy I am confident with that you'll solve my broken internet connection once I call the hotline.
@ralphm786
@ralphm786 5 жыл бұрын
Great tutorial. As simple as possible, but no simpler. Who knew programming Tetris could be so easy?
@Komplexitet
@Komplexitet 4 жыл бұрын
0:37 I like to make ASCII-games and this is really accurate to how everyone is reacting in the beginning.
@Democracyphobia
@Democracyphobia 4 жыл бұрын
There is a huge difference between old-school programmers and the new generation .the new generation programmers are high attention show off kids with one single mission to prove to themselves and others that they are smarter then anyone else .I just code as a hobby and man some people in forums made me think that programming actually cause mental issues due to how toxic they are . We need more chill mature people like this man in this world .
@maxgomes92
@maxgomes92 3 жыл бұрын
This rotation technique is beautiful.
@bbqgiraffe3766
@bbqgiraffe3766 Жыл бұрын
implementing this in C on my 6502 homebrew, I got a NES controller and LCD working but I'm too dumb to know how tetris works so this is helpful :3
@BrekMartin
@BrekMartin 7 жыл бұрын
What beginner programmers should be watching, but apparently aren't. Interesting... I think I rotated the pieces within their arrays, so the array content changed.
@BrekMartin
@BrekMartin 7 жыл бұрын
I'll have to look again now :D not sure you can do that without destroying it.
@javidx9
@javidx9 7 жыл бұрын
+Brek Martin thanks for the compliment! Rotating in the array is just as valid. I think the centre of rotation changes per piece in proper Tetris. That's a bit more fiddly though.
@BrekMartin
@BrekMartin 7 жыл бұрын
javidx9 I've looked again. This was in 2010, so it's vague! I copped out and defined all rotated shape combinations in a table, but I let myself off the hook because I rotated digits to display the score, the same way you rotate tetris bricks (for portrait display) :D
@javidx9
@javidx9 7 жыл бұрын
NIce! I hate looking at code from years ago. Firstly I can barely remember it and obviously I wrote loads of documentation, and secondly, it always looks so inexperienced compared to now. lol. I guess I'll feel the same in 10 years time looking back at these videos.
@BrekMartin
@BrekMartin 7 жыл бұрын
I did it again over two nights :) Bored of the actual game already :D It looks like you expanded the well array to include borders made of set bricks, which I should have done. Checking the borders takes extra code, but the borders included in the well array would be checked naturally with the normal shape collision function. What it appears we both forgot, or maybe you just didn’t want to... I think the well needs a couple of off screen rows to spawn the new shapes to, so they don’t suddenly, and unfairly appear at the top of the well. I did borrow your idea of using values for the brick elements that relate to the shape that each brick came from. It makes the game ready for a colour platform, even if it isn’t running on one.
@AndreasWilfer
@AndreasWilfer 6 жыл бұрын
I giggled at the "Because I don't want the video to be half an hour long" at around 12:30, since the video is.. well.. about half an hour long! :-D Anyway, loved the video!
@javidx9
@javidx9 6 жыл бұрын
Heh thanks Andreas, i dont script these things so i have to guess at the length :D
@romeo2473
@romeo2473 5 жыл бұрын
pfew.. wish I had access to these videos back in my days when I started coding... Great job you do for teaching others!
@hitenterbecomeaprogrammer890
@hitenterbecomeaprogrammer890 2 жыл бұрын
So cool, you explained it so easily, collisions are always a simple but important point when we develop these games, thank you for sharing.
@uuu12343
@uuu12343 5 жыл бұрын
This is exceptional as usual Also - i finally completed my dream of making tetris for fun Oh, you should do more videos on c++ without the use of the olc engine
@javidx9
@javidx9 5 жыл бұрын
Thanks Eternia, I occasionally dont use the olc engines. Ive a series planned later this year which might not use them, we'll see...
@uuu12343
@uuu12343 5 жыл бұрын
@@javidx9 Many thanks, looking forward to learn more pure c++ tutorials!
@rockinpenguin
@rockinpenguin 5 жыл бұрын
0:38 no... my reaction was actually COOOOL ! Thats perfect for the video : who cares about graphics, as you better get the logic down first...
@twitchEmailOkay
@twitchEmailOkay Жыл бұрын
hey this guys pretty good! a lot of entertainment youtubers get comments like "thanks this helps me" but you are actually helping me to sustain my livelihood. Thank you
@DimitriSabadie
@DimitriSabadie 3 жыл бұрын
The ternary expressions inlined to prevent having to write an if made my day. What a brilliant amount of obfuscation. Thanks :D
@silverstringsgia
@silverstringsgia 5 жыл бұрын
next video: How to program Witcher 3
@nukemonk
@nukemonk 4 жыл бұрын
While you're at it, do number 4.
@mephystto2181
@mephystto2181 4 жыл бұрын
it's actually easier to program Witcher 3.
@mrdesperate1
@mrdesperate1 4 жыл бұрын
In ASCII !!!
@leaflords7216
@leaflords7216 3 жыл бұрын
In the command line
@rash_dawg
@rash_dawg 5 жыл бұрын
Im having an issue that when the console opens it is too wide. I can resize it to be the right size. If I dont resize it then the columns of text dont line up. Update: I figured out how to change console settings to set width to 80. Really enjoyed doing this walkthrough. Learned a lot and had fun building Tetris.
@javidx9
@javidx9 5 жыл бұрын
Good stuff Jason, glad you got it resolved!
@rema0126
@rema0126 5 жыл бұрын
Can you help me out, Im having the same problem but I cant seem to fix it
@webnplay
@webnplay 4 жыл бұрын
This question was asked one year ago and since the solution was not given here let me do this. When you run the application, click on the properties bar of the console and resize it accordingly. You can set the width and height by resizing the window. If you do that make sure you click on properties and press Ok so the settings are stored.
@ianr5018
@ianr5018 3 жыл бұрын
@@webnplay If I send this project for someone else to play on a different computer, will the application launch with the terminal the correct size, or will the new computer also need to be resized.
@webnplay
@webnplay 3 жыл бұрын
ian reim probably needs to be resized if it is not correctly set.
@mattiviljanen8109
@mattiviljanen8109 6 жыл бұрын
Assuming we don't want to change the size of the matrix between rotations, only the long bar piece requires 4x4 grid - but only in two orientations. The L pieces and the, uh, three-long with the middle bump piece require 3x3 in four rotations, Z pieces 3x3 in two orientations and the rectangle piece is just a 2x2 in one orientation. The rotation could utilise just next() and prev() commands in a circular linked list, so that the amount of orientations wouldn't matter. The insertion point of the piece could dynamically be the middle-most piece of the top row. You really nerd-sniped me here! I think I have to code a Tetris clone, too! Thanks for the great video!
@javidx9
@javidx9 6 жыл бұрын
Hey no problem Matti, I'm pleased its sniped you! There are many ways to implement tetris, and yes you may save some space by pre-caching all the pieces in a list. Part of me wants to go on to represent the pieces as bit streams, and use bitwise logic to mess about with them...
@mattiviljanen8109
@mattiviljanen8109 6 жыл бұрын
Yeah, there are many ways to implement the pieces. Actually, I think that saving all the pieces and their orientations using bit streams could actually take up less space in the executable instead of using matrix rotation logic. Accessing the pieces in the bit stream using modular arithmetic would actually be faster, too. I haven't coded anything so intensive that squeezing the last CPU cycles out would have been necessary (I do have an idea slowly cooking in my head actually), but as my first computer was an old and slow 386, my mantra is still "don't waste the cycles". It makes my coding a lot slower, but the results become quite snappy, if I say so myself. I remember banging my head against my code, when it was poorly constructed SQL all along... Thanks for yet another inspiring video!
@stupossibleify
@stupossibleify 5 жыл бұрын
Late to the party, but your videos are excellent! Thank you for all the effort you put in and love to see a bit of Vimto on the TV
@Huguillon
@Huguillon 5 жыл бұрын
This is the best channel I suscribed in 2018
@javidx9
@javidx9 5 жыл бұрын
Aww, thanks Guillermo!
@stec9524
@stec9524 4 жыл бұрын
Well done, Gilfoyle!
@octaviews2860
@octaviews2860 3 жыл бұрын
exactly my thoughts man XD
@FullassDear
@FullassDear 3 жыл бұрын
Hello, javidx9! Thank you for your videos, it's a pleasure to see and grasp these magic ( at least magic for me) tricks. I am in tears of joy with your r % 4 solution in rotation, I wouldn't ever thought of it. Feel like a mage aspirant really.
@javidx9
@javidx9 3 жыл бұрын
Thanks, lol, Im pleased youve found it useful :D
@recondito
@recondito 6 жыл бұрын
Dude you impress me. I consider myself a new programmer because I really haven't written some serious code. Currently watching this because I have to make a tetris for a college presentation, but I have to do it in SDL. However you caught my attention when I saw your thumbnail. Really nice video. Liked and subscribed.
@javidx9
@javidx9 6 жыл бұрын
Hey thanks Chico, that's very kind of you! Good luck with your project!
@recondito
@recondito 6 жыл бұрын
Thanks mate.
@randairp
@randairp 5 жыл бұрын
24:18 You don't need the conditional 1 or 0 since bools already evaluate to that. This IS C++ after all ;-)
@RichSchupbach
@RichSchupbach 3 жыл бұрын
Great video. Thank you for sharing. I changed a couple of lines of your code to make the pieces out of full block characters instead of letters. Looks pretty good. Draw Field: screen[(y + 2) * nScreenWidth + (x + 2)] = L" \u2588\u2588\u2588\u2588\u2588\u2588\u2588=#"[pField[y * nFieldWidth + x]]; Draw Current Piece: screen[(nCurrentY + py + 2) * nScreenWidth + (nCurrentX + px + 2)] = 9608; // Unicode 2588 full block
@jdpillar1
@jdpillar1 2 жыл бұрын
Thanks, was just about to look this up myself, saved me the trouble!
@meatlover6916
@meatlover6916 2 жыл бұрын
Thanks!
@goldensnitch1614
@goldensnitch1614 2 жыл бұрын
right away to the tutorial without any unnecessary intro, love it, subbed
@ryanamberger
@ryanamberger 3 жыл бұрын
Graphics are wonderful. However, there's something elegant and beautiful about a video game running on a command line. So freaking cool.
@MrAlus3
@MrAlus3 5 жыл бұрын
Ahh! Finally some normal developer that does normal coding. To many of "5 way to become software developer" or "why you should learn X" videos around. Glad that I found you
@megabrogames239
@megabrogames239 6 жыл бұрын
6:13 my head exploded :0
@huyvole9724
@huyvole9724 6 жыл бұрын
Yeah, they appear a lot of image handling.
@pow9606
@pow9606 5 жыл бұрын
ewww
@IStMl
@IStMl 4 жыл бұрын
Linear Algebra basics
@Tony-ow9bo
@Tony-ow9bo 4 жыл бұрын
You're WEAK! Build your math muscles!
@Skander1996
@Skander1996 4 жыл бұрын
I am fairly new to coding and i also never used c++, i use python and right now i am exploring the dephts of JavaScript/html5 and css naturaly. Anyway i dont understand how people can downvote your tutorials... they are just perfect! you talk about alota important things i dont understand but thx too you i can google them and mostly they are important to me and my ambition. Just wanna say thank you for the great content and your way of teaching!
@montecrysto33
@montecrysto33 3 жыл бұрын
I love how he introduces game design in a two minutes intro. Btw command-line Tetris is beautiful on its own
@onuberonly7846
@onuberonly7846 6 жыл бұрын
Thank you Dude! you are an inspiration to intermediate programmers like me. I love this console stuff - The rawness - The unabashed purity of it !!
@javidx9
@javidx9 6 жыл бұрын
lol, thanks K Parks, the console is a great and underestimated vehicle for learning even advanced topics!
5 жыл бұрын
This is nice, but it is not compliant with the official Tetris Guideline. Most importantly, it does not implement the SRS (the Super Rotation System, which includes wall-kicks). See for more info: tetris.fandom.com/wiki/Tetris_Guideline Different Tetriminos have different centres of rotation and require different rotation functions, and when they are rotated next to a wall, they should be pushed away from the wall.
@groszak1
@groszak1 4 жыл бұрын
my Tetris game comes much closer to the Guideline. tetrisimplementation.netlify.app/
@pby1000
@pby1000 5 жыл бұрын
Great idea to show us the program before starting the lesson. Subscribed!
@javidx9
@javidx9 5 жыл бұрын
Thanks!
@thiagot7706
@thiagot7706 2 жыл бұрын
I have done the math and I think the formula for 270deg here in 7:10 should be i = 3 - y + (4*x). I think is a little error considering the next code, but it is good to warn. Good video.
@anhvo6020
@anhvo6020 Жыл бұрын
i second this
@PhilBoswell
@PhilBoswell 6 жыл бұрын
I wonder whether this might be a candidate for updating to use your nifty framework? Also, might it be an interesting exercise to encapsulate the Tetromino logic into a class?
@javidx9
@javidx9 6 жыл бұрын
Hi Phil, I've deliberately left this and FPS #1 out of olcCGE. Mainly because I did them before I created olcCGE, but also they make great exercises for other people to have a go at, which you may not be surprised is something people ask me about a fair bit!
@abrahambankhead359
@abrahambankhead359 6 жыл бұрын
Oh look everyone, a programmer who isn't pretentious and full of crap what a relief! Now I can finally get a true sense of how to continue my C++ journey.
@javidx9
@javidx9 6 жыл бұрын
Hi Abraham, Thanks, that's certainly one way to look at it! :D I hope your journey is long and fruitful!
@abrahambankhead359
@abrahambankhead359 6 жыл бұрын
Thanks for the high quality channel, I knew I could do it. Progging is fun!
@AaronCMounts
@AaronCMounts 3 жыл бұрын
I just finished walking through your tutorial, step by step and it worked! I had to make just a tiny amount of tweaks to make it work with C++ (changes to the way you wrote the 'sleep' lines), but it's incredible! It works exactly as advertised and it plays perfectly, too!
@rishabhgupta734
@rishabhgupta734 2 жыл бұрын
I am facing the same issue , can you please post any link to the tweaked code?
@Ogrodnik95
@Ogrodnik95 2 жыл бұрын
@@rishabhgupta734 using namespace std::chrono_literals; right above std::this_thread::sleep_for(50ms); should do the trick if you still need aid. still not sure how it works without that in vid and in file from github
@udaythakur7464
@udaythakur7464 2 жыл бұрын
@@Ogrodnik95 I am still getting error , if u can please post your C++ code here...
@Ogrodnik95
@Ogrodnik95 2 жыл бұрын
@@udaythakur7464 try: std::this_thread::sleep_for(std::chrono::milliseconds(50));
@NOWG0015
@NOWG0015 4 жыл бұрын
Why am I just now discovering this channel. Love this video.
@javidx9
@javidx9 4 жыл бұрын
Cheers buddy!
@jakebrowning2373
@jakebrowning2373 4 жыл бұрын
Some pieces in NES Tetris, and presumably others, spin around units in the piece though, like the L J T I (Z and S?), so this system of rotating would be slightly different I guess
@mortkebab2849
@mortkebab2849 5 жыл бұрын
I'm finding that there's way too many dependency errors when trying to get this to compile on my mingw setup. I think what I'll do is to limit my use of VS Code just for Python (which I use most of the time in my projects) and reinstall a fresh copy of Visual Studio with just the options needed (since there are so many, that was a learning curve the first time around) to develop in C++.
@shig4238
@shig4238 3 жыл бұрын
This might be the best game programming series on KZfaq 👌
@chastitywhiterose
@chastitywhiterose Жыл бұрын
5 minutes in and you are showing the exact formula I used in my Tetris game. In my case it was a[x+y*width]
@yohohohowo
@yohohohowo 2 жыл бұрын
First time using visual studio and coding in C++. Video was a little quick for following along but the explanation of the rotation algorithm and all the whiteboard stuff was the highlight for me. I ended up copy pasting the code and actually learned a lot by figuring out how to display lines and Level up each ten lines, changed speed increase to level and managed to show next piece. Toughest part was clearing the characters when next piece changes. I was really stumped by the score code till I figured out that
@javidx9
@javidx9 2 жыл бұрын
I'm pleased you've found it useful! I would use PGE for everything, and the CGE videos can be very easily implemented in PGE.
@davidsmith4811
@davidsmith4811 4 жыл бұрын
Am I the only one that noticed that the video ID is tHeCIA?
@callmejobson
@callmejobson 5 ай бұрын
Great video!! 3/23/24 - I changed the nScreenHeight from 80 to 120 and that l helped get everything appearing on the screen correctly. - make sure you put your methods before your the main method or have a header file with a declaration of the functions!
@atarixle
@atarixle 3 жыл бұрын
believe it or not, but I am coding on atari 8 bit computers for 29 years now, I even wrote a whole GUI in BASIC (pretty much useful, not just a tech-demo of what could be). But I never made it to make a Tetris game (which I tried but failed). I find your video very very interesting even if I only code in BASIC and may be some C.
Code-It-Yourself! First Person Shooter (Quick and Simple C++)
38:56
What Are Pointers? (C++)
41:55
javidx9
Рет қаралды 561 М.
Challenge matching picture with Alfredo Larin family! 😁
00:21
BigSchool
Рет қаралды 41 МЛН
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 14 МЛН
黑天使遇到什么了?#short #angel #clown
00:34
Super Beauty team
Рет қаралды 43 МЛН
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,5 МЛН
DIY Programming Language #1: The Shunting Yard Algorithm
37:10
Running "Hello World!" in 10 FORBIDDEN Programming Languages
18:07
Making TETRIS in C++ - SFML Gamedev - Devlog
8:13
Kofybrek
Рет қаралды 39 М.
Forbidden C++
33:07
javidx9
Рет қаралды 1 МЛН
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 345 М.
Back To Basics: C++ Containers
31:41
javidx9
Рет қаралды 181 М.
After 34 Years, Someone Finally Beat Tetris
16:47
aGameScout
Рет қаралды 13 МЛН