C++ Tutorial 18 - Simple Snake Game (Part 3)

  Рет қаралды 588,821

NVitanovic

NVitanovic

Күн бұрын

Пікірлер: 826
@Sora-hu2hq
@Sora-hu2hq 3 жыл бұрын
I'm still learning c++ and while watching this I'm smiling. It looks pretty cool. This encouraged me to practice code every day, thank you, man.
@borhan6414
@borhan6414 2 жыл бұрын
hello, i’m now quite new to c++ , and i’m wondering if a year was so enough to reach such a level ( creating such a game ) ??
@devery0622
@devery0622 2 жыл бұрын
​@@borhan6414 in one year you can learn even more, just don't lose your motivation
@sypher4735
@sypher4735 2 жыл бұрын
@@borhan6414 For me, it's been around 3-4 months, I started with DSA and practiced a lot through IDE and "LeetCode", and guess what, I did the Body part by myself, and I feel good haha.
@FoldingCrown
@FoldingCrown 9 жыл бұрын
Hey guys. Instead of using the variables "prevX and prev2X, and prevY prev2Y" to update the snake tails position, I came up with a more logically simplified approach which works for me very well. tailX[0] = x; tailY[0] = y; for (int i = totalTail; i > 0; i--) { tailX[i] = tailX[i - 1]; tailY[i] = tailY[i - 1]; } x and y are really the previous x and y positions because they are updated in the switch statement directly after this logic is executed. Therefore, we can go through the array of the snake's tail and update each element such that tail is equal to the previous tail in the element. Thanks for the tutorial!
@no_one2230
@no_one2230 7 жыл бұрын
i tried it but the second element of tail changes its position in different directions like Oooooo O oo o o o oooooO o o o oo O
@axiomer47
@axiomer47 5 жыл бұрын
@@no_one2230 same here
@batikanboraormanci7954
@batikanboraormanci7954 5 жыл бұрын
@No_one @Lalith Adithya for (int i = totalTail; i > 0; i--) { tailX[i] = tailX[i - 1]; tailY[i] = tailY[i - 1]; } tailX[0] = x; tailY[0] = y; this way it'll work.
@axiomer47
@axiomer47 5 жыл бұрын
@@batikanboraormanci7954 it's the same thing but in tailX and tailY are after
@batikanboraormanci7954
@batikanboraormanci7954 5 жыл бұрын
@@axiomer47 well, if you convert [0] before making [1] equal to [0], they'll end up being the same thing. That was the wrong part of your code
@rajatzsharma
@rajatzsharma 2 жыл бұрын
To remove the flickering you can replace" system("cls"); " with " SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), {0,0}); " it is in the windows.h library. What it basically does is just takes your cursor to first word of top line and starts to overwrite the text so the flickering just stops.
@jackied.v.carson6059
@jackied.v.carson6059 2 жыл бұрын
Thank you so much! This drastically improves the quality
@mr.president6922
@mr.president6922 2 жыл бұрын
it works thanks
@raismohaman6151
@raismohaman6151 2 жыл бұрын
Thank you very much, this is a game changer
@jpp_vh
@jpp_vh 2 жыл бұрын
also remove the cursor with : CONSOLE_CURSOR_INFO info; info.dwSize = 100; info.bVisible = false; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
@volf5116
@volf5116 Жыл бұрын
thanx
@ArcadeMystereo
@ArcadeMystereo 3 жыл бұрын
Thanks for making this little tutorial series. I jsut started with C++ programming, and didn't really know where to begin after I finished a C++ tutorial, but this really helps with getting to know the basic things, and making them useful. Your tutorial is appreciated even 5 years later ;)
@gnool
@gnool 9 жыл бұрын
Nice work man. I admit I do think the code could be nicer, but I did smile when the tail code starting working, and that's why I'm learning C++ :-) Thanks for the tutorial.
@gytisdramblewolfskis8521
@gytisdramblewolfskis8521 7 жыл бұрын
man learn any other language if you already ended school. other languages are much easier and more understandable. you can do almost anything you can do in all other languages combined with c++ but it's gonna be 100 times harder
@gytisdramblewolfskis8521
@gytisdramblewolfskis8521 7 жыл бұрын
that is true but as i said c++ is much harder, more unnecessarily complicated, and takes a ton of time to master. and all that makes it extremely boring, which means that if your first language is c++ you're much more likely to hate programming afterwards. btw java is somewhat similar to c++ in it being close to "meat" but it's much more appealing in my opinion. so it's a better option in my opinion, though even better choose stuff like c#, javascript etc.. those are languages that are used more in jobs, and will be used even more in future.
@maximalgamingnl9954
@maximalgamingnl9954 7 жыл бұрын
We should change the head to a C, and the tail by plusses
@καλαμ
@καλαμ 4 жыл бұрын
@@fosspointer Games like Terraria and Stardew Valley are written in C# :)
@lak7308
@lak7308 3 жыл бұрын
@@fosspointer hard af ngl and imagine for me a noob trying to do internal menu for GTAO lol
@Directer20
@Directer20 6 жыл бұрын
It looks easy when I'm watching the video, but I can't imagine how I'd be supposed to come up with all of this on my own. :|
@abdullaabdurashidov5057
@abdullaabdurashidov5057 5 жыл бұрын
same
@payatthepump1191
@payatthepump1191 4 жыл бұрын
you have to ask yourself 3 important questions. 1) what things do i need for the game. 2) what formulas (or logic) do i need to get those things. 3) what variable do i need to get for those formulas (logic); this is general problem solving and will apply to everything you need.
@deadchannel5933
@deadchannel5933 4 жыл бұрын
@@payatthepump1191 it's not just as simple as that! Trust me! I am a C++ programmer and it's not about "things and magic wonders and hope within God that" that you make a code! It is actually some pretty serious testing and learning, and it's not always as simple as selecting what you need and the good functions and stuff and that's it, no, it's way more than that!
@payatthepump1191
@payatthepump1191 4 жыл бұрын
@@deadchannel5933 I think you care confusing how to approach the problem and writing a successful code. There are way more steps in the development of the code. But if someone wants to know how to approach a problem to start the development process.. those 3 questions are the way to go.
@deadchannel5933
@deadchannel5933 4 жыл бұрын
@@payatthepump1191 whatever
@Secretcodrin
@Secretcodrin 8 жыл бұрын
today i woke up and i said. let's try to make a game. i started with unity but it was something too complicated and it felt like i rush things. but i tought. wait a second. maybe i can do something in c++. after i watched this tutorial i realized how idiot i am. this is verry verry complicated...
@tradermann
@tradermann 8 жыл бұрын
It is not actually that complicated. Just plain logic.
@tradermann
@tradermann 8 жыл бұрын
The cool thing is that you don't need any graphics. Just some C++ matrix manipulation knowledge.
@crazyagile1808
@crazyagile1808 7 жыл бұрын
The more you practice, the better you'll get. It looks complicated, but in actuality, w is up, s is down, a is left, d is right, and the score goes up when you touch the fruit. Not that complex.
@arthurmelo3022
@arthurmelo3022 6 жыл бұрын
You have to study to make agame man...
@arthurmelo3022
@arthurmelo3022 6 жыл бұрын
@@crazyagile1808 So why dont u made one too?
@Albalam
@Albalam 8 жыл бұрын
and now sell it to Microsoft for 1$
@komangadityapratama904
@komangadityapratama904 8 жыл бұрын
yeah lol
@oliverplay9216
@oliverplay9216 6 жыл бұрын
Hello
@Заработокденег-Горд
@Заработокденег-Горд 6 жыл бұрын
AZIZ tutorial
@arthurmelo3022
@arthurmelo3022 6 жыл бұрын
don't ask for my name Whats yout name?
@tashadurrahman
@tashadurrahman 6 жыл бұрын
Dude you can't sell it... Even a small compant won't buy it....! LOL XD
@123galandechaitanya
@123galandechaitanya 4 жыл бұрын
Loved it .! Really appreciated . I felt so good when the tail worked . Also , for a beginner programmer like me i understood everything . Thanks Mate. You've earned yourself a subscribe .
@Jo_x_han
@Jo_x_han 5 жыл бұрын
after watching this, i can make GOOD BYE CRUEL WORLD in C++
@fatimashirazi
@fatimashirazi 4 жыл бұрын
To use arrow keys for controlling the snake, do the following: #define KEY_UP 72 #define KEY_DOWN 80 #define KEY_LEFT 75 #define KEY_RIGHT 77 add this below "using namespace std" and in the switch statement, change the character cases to these cases like if (_kbhit()){//keyboard hit switch(_getch()){//get character case KEY_UP: dir = UP; break; case KEY_DOWN: dir =DOWN; break; case KEY_RIGHT: dir = RIGHT; break; case KEY_LEFT : dir = LEFT; break; default : break; } } You'll be able to then control the snake with the arrow keys on your keyboard!! Happy coding...
@StickmanFights.
@StickmanFights. Жыл бұрын
Thanks
@dudefrombelgium
@dudefrombelgium 3 жыл бұрын
Thank you , this is the first tutorial which simply and correctly introduces me to programming a sprite and controls, i dont yet understand what is written there to be honest and i have no idea how you came up with that but i now have a chance to study this code and understand the logic behind it , thank you
@blakceyedpeas
@blakceyedpeas 5 жыл бұрын
Instead of writing every symbol with cout you could make one string with everything and use only one cout per frame. By using this you can avoid this blinking :)
@broet5450
@broet5450 9 жыл бұрын
i thought this was a real good tut, nice work man !
@youngreezy363
@youngreezy363 7 жыл бұрын
Broet you said tut
@LorenHelgeson
@LorenHelgeson 6 жыл бұрын
Thanks for the excellent video. To anyone interested, I came up with a quick addition if you want to limit how long your snake's tail can get. At the top, where you define tailX and tailY, change it this: int const tailMax = 20; *
@juicewaffle4700
@juicewaffle4700 8 жыл бұрын
It's great tutorial for beginners, thx. but I have some difficulties in understanding things about prevX, prev2X, tailX[i].... etc. Could you make another tutorial describing details if you're not busy? I don't mind even if you don't make it, I can understand your situation :)
@SapphFire
@SapphFire 8 жыл бұрын
Yeah!
@romel_storm
@romel_storm 8 жыл бұрын
This is how I understand it: I believe he is just swapping the snakehead position with the rest of the snake If the snake looked like oo0 and the snakehead is at position x = 5 the one behind it will have x = 4 and the other x=3 But when it moves snakehead becomes x=6 so we have to swap old position the snake head with the ones behind it. That makes me sleep at night if anyone has anything better I'm all ears
@ivandy707
@ivandy707 6 жыл бұрын
Foster Brown wow man thx
@hanschristianpacarat7430
@hanschristianpacarat7430 6 жыл бұрын
@@romel_storm the box on my pc is still blinking. how to solve that?
@erdemyilmaz6172
@erdemyilmaz6172 5 жыл бұрын
and i thought it was only me who didnt understand
@Albert-lp8ql
@Albert-lp8ql 6 жыл бұрын
Thanks for your effort. It's a pretty good idea to make this kind of tutorial, much better than simply narrating boring concepts. Wish you make more.
@minecraftermad
@minecraftermad 8 жыл бұрын
lol the fruit can spawn inside of the snake's tail :D
@SameerKhan-nd5qb
@SameerKhan-nd5qb 4 жыл бұрын
hahahah
@theriturajsingh7464
@theriturajsingh7464 4 жыл бұрын
😂
@minecraftermad
@minecraftermad 3 жыл бұрын
@@Marie-qv6on on fruit spawn check if snake tail contains spawn attempt coordinate. While thats true try to make a new spawn.
@farcasiuandrei8555
@farcasiuandrei8555 3 жыл бұрын
@@minecraftermad can you write the code for this please?
@minecraftermad
@minecraftermad 3 жыл бұрын
@@farcasiuandrei8555 something along the lines of bool fail = true; while(fail){ fail = false; fruitSpawnTryX = random(); fruitSpawnTryY = random(); for(int i = 0; i < tailPiecesN; i++){ if(tailPieceY[i] == fruitSpawnTryX && tailPieceY[i] == fruitSpawnTryY) fail = true; } } fruitX = fruitSpawntryX; fruitY = fruitSpawntryY;
@Justanoobcoder
@Justanoobcoder 5 жыл бұрын
6:16 I think this is shorter and easier to understand: for(int i=nTail-1;i>0;i--) { tailX[i]=tailX[i-1]; tailY[i]=tailY[i-1]; } tailX[0]=x; tailY[0]=y;
@asadjarral9627
@asadjarral9627 5 жыл бұрын
yeah you re right bro
@Light-wz6tq
@Light-wz6tq 7 жыл бұрын
You can do this on Input() to don't let the user make opposite movement for example if you are going left u can't press D and go to the right : if (_kbhit()) { switch (_getch()) { case 'a': if (dir == RIGHT)// this lines break; // this lines dir = LEFT; break; case 'd': if (dir == LEFT)// this lines break; // this lines dir = RIGHT; break; case 'w': if (dir == DOWN) // this lines break; // this lines dir = UP; break; case 's': if (dir == UP)// this lines break; // this lines dir = DOWN; break; case 'x': gameOver = true; break; }
@onee0.01
@onee0.01 6 жыл бұрын
thanks. I finding it ^^
@C0DExTutorials
@C0DExTutorials 6 жыл бұрын
Actually, it should be like this because when the length is only 1 you should be able to move all directions... if (_kbhit()) { switch (_getch()) { case 'a': if (nTail > 0) { if (dir == RIGHT) break; } dir = LEFT; break; case 'd': if (nTail > 0) { if (dir == LEFT) break; } dir = RIGHT; break; case 'w': if (nTail > 0) { if (dir == DOWN) break; } dir = UP; break; case 's': if (nTail > 0) { if (dir == UP) break; } dir = DOWN; break; case 'x': gameOver = true; break; } }
@apektaiga3242
@apektaiga3242 6 жыл бұрын
Lol i also thought abt this
@PunkHippie1971
@PunkHippie1971 6 жыл бұрын
I’d love to see how you could use this code with some simple graphics
@razeezar
@razeezar 7 жыл бұрын
In the example demonstrated, there is a glitch that occurs every time the snake eats a piece of fruit. Each newly grown tail segment briefly appears in the top-left corner of the play field for one frame, before attaching to the snake body in the following frame. We can remove this glitch by re-organising Logic into the following sequence : - Check for fruit, increase nTail figure - Shift tail values in TailX /TailY arrays - Change position based on dir - Wall head & snake body collision detection
@Nick-jb4xi
@Nick-jb4xi 6 жыл бұрын
You have fast eyes! confirmed the bug!
@cupcake_maker
@cupcake_maker 5 жыл бұрын
also happened to me
@CosmJJ
@CosmJJ 6 жыл бұрын
Awesome! Thank you so much! I'm new in C++ and your videos are perfect and fun way to learn computer programming.
@ayubkazi9525
@ayubkazi9525 4 жыл бұрын
Done the whole code......and got the perfect output.....Thanks man ✌️✌️
@rueljoshuamojico4294
@rueljoshuamojico4294 4 жыл бұрын
Thank you for this tutorial it really helps me with my requirements on school really appreciated bro!!
@Szesorvs
@Szesorvs 6 жыл бұрын
This looks googs! It's my first game on C++. Thanks man. Realy nice.
@Caffeineshiba
@Caffeineshiba 4 жыл бұрын
This has been a great tutorial, thank you!
@danielmatthews12312
@danielmatthews12312 7 жыл бұрын
Great tutorial! I love the flickering feature!
@4547466
@4547466 6 жыл бұрын
Sarcasm detected in this comment... It's done in the basic console viewer if you want to do it in a different lib... use a different lib
@nananyfo4752
@nananyfo4752 6 жыл бұрын
Expert detected in this reply.... can u tell me how can i make the flicker stop (for the map)? :D
@michaelatorn8380
@michaelatorn8380 6 жыл бұрын
you cant stop the flickering in the console(cpu: complex, but slow), but you could create a graphical interface(gpu: fast). You could include sdl2 and eventually opengl in c++, but you need to download it first. There are KZbin tutorials for it, but ist difficult and wont probably work the first time. You need time and a lot of willpower to cross the canyon.
@mandar.vaidya
@mandar.vaidya 4 жыл бұрын
How to stop flickering ?
@enriquethethird7253
@enriquethethird7253 3 жыл бұрын
nniiice. watched all of the parts. i was amazed when the game finally was done. keep up the good work man!
@shubhamjaiswar7542
@shubhamjaiswar7542 2 жыл бұрын
In my terminal it is blinking so much.... Any solution for this???
@martynasausrota8611
@martynasausrota8611 4 жыл бұрын
so i fixed some problems and did some quality upgrades: 1)whenever he takes we fruit the "o" pops up at the top left corner of the map. to fix that go to logic() and change from: for(int i=1; i < nTail; i++) to: for(int i=1; i
@Ganger81
@Ganger81 4 жыл бұрын
i had the idea of pause too but it only pauses in the beginning . after snake eats at least one fruit and you press x to pause game is over
@skoddskar3D
@skoddskar3D 4 жыл бұрын
These are great fixes thank you! To fix the fruit spawning in inside the tail you need to create a new bool at the top. Name it whatever makes sense to you, I called it fruitTail. In Setup() where you set gameOver to false, do the same for fruitTail in Logic() at the bottom under the if statement for eating a fruit and creating a new fruit position you'll write this code: for (int f = 0; f < nTail; f++) { if (fruitX == tailX[f] && fruitY == tailY[f]) fruitTail = true; } if (fruitTail == true) { fruitX = rand() % width; fruitY = rand() % height; fruitTail = false; } I'm still pretty new to coding but I'm pretty sure that you want to make sure this code is after the code for eating a fruit. I'm also not sure if you should set fruitTail back to false at the start or at the end of the other two lines of code to update a new position for the fruit. But this has worked very well for the couple of times I tested it.
@Punicia
@Punicia 3 жыл бұрын
Thanks for the second one, about the backtrack and instantly killing yourself. That was annoying
@sonaliverma3123
@sonaliverma3123 4 жыл бұрын
It's amazing man...especially for beginners...keep it up...keep doing the good..
@overrevvv
@overrevvv 2 жыл бұрын
Thank you for this project it helped me a lot to wrap my brain around the real details about programming
@applezhe19
@applezhe19 2 жыл бұрын
Thanks for the tutorial man! You're the legend and I also learned new stuff from this tutorial!!
@marktriestolive1781
@marktriestolive1781 5 жыл бұрын
include this if u want the fruit to really be randomly placed anywhere within the map. i noticed the fruit pattern every time i play it. #include then put srand(time(0)); on the void Setup(); just above the fruit x and y random coordinate.
@NVitanovic
@NVitanovic 5 жыл бұрын
Just beware that if ctime is not available to be included try to include time.h.
@OMGWTFBBQHAXXORZ
@OMGWTFBBQHAXXORZ 4 жыл бұрын
My fruit stopped spawning after 9. Then I added random timer and the fruit will stop spawning at a random number. The highest amount of fruits I've eaten was 15. How can I fix this bug?
@Punicia
@Punicia 3 жыл бұрын
You're a legend thank you
@coolbrotherf127
@coolbrotherf127 7 жыл бұрын
I'm going to try and use what I learned here to make a pong game by myself.
@amrsamy9007
@amrsamy9007 5 жыл бұрын
u did it ?
@DhanaAbishek
@DhanaAbishek 9 жыл бұрын
That was really cool man..
@runngun5759
@runngun5759 4 жыл бұрын
Pretty nice tutorial it really helps to understand the fundamentals of programing. I really had fun doing this. I also added some bug fixes in the movement and added some small fun things.
@arhantbararia380
@arhantbararia380 3 жыл бұрын
Using enum dir was very clever, we can specify heads of the snake, using > , < , ^ , V .
@juvenildr
@juvenildr 6 жыл бұрын
i thought i was smart till i wanted to solve tails coordination :(
@quadroninja2708
@quadroninja2708 3 жыл бұрын
It is more about observation, when you understand that segments are moving to the position of next segment that is closer to the head, it becomes obvious that we need to remember the place before the last segment and show it when grow
@jonsnow8543
@jonsnow8543 4 жыл бұрын
In addition to replacing endl with " !" and only doing an endl at the end of the very last statement "Score:" statement there's something else that helps the redraw/refresh smoothness . It is to have a larger buffer for cout so that you can update the output stream for a full screenfull before flushing. I use a larger play area size (50x25), and adding some extra char space for other, i declare a larger buffer in global scope: char outputbuf[1300]; .... // and then to the Setup function I add these configs: std::cout.rdbuf()->pubsetbuf(outputbuf, sizeof(outputbuf)); ios::sync_with_stdio(false); this gives smoother screen updates
@galaktoza
@galaktoza 5 жыл бұрын
Hvala puno, odličan video!
@Dany.498
@Dany.498 Жыл бұрын
This channel is so underrated❤❤
@henry5788
@henry5788 7 жыл бұрын
Awesome tutorial and works perfectly! Give a nice insight for beginners!
@seongyeoncho3794
@seongyeoncho3794 3 жыл бұрын
can this still work if you use a integrated terminal within vs code??
@jonsnow8543
@jonsnow8543 4 жыл бұрын
for better performance replace every occurence of endl with " " instead. endl also flushes the output stream. Best to only do a flush at the end of a whole screen draw rather than intermittently throughout
@SupernaturalBBI
@SupernaturalBBI 9 жыл бұрын
Very good video! Excellent work! I learned a lot from the 3 videos about the snake game, now i can create a game on my own! Thank You for the videos!!!
@francescosorce5189
@francescosorce5189 6 жыл бұрын
I adore the fact that you only used standard libraries
@matthijs2101
@matthijs2101 9 жыл бұрын
Thank you very much for this tutorial. I wanted to learn c++ so i can be a better programmer for my arduino. Watched some vids, but your video really learned me to understand the code more quickly because it was a fun project. Thanx
@jctagaming9774
@jctagaming9774 4 жыл бұрын
(nice game) i did the game and i was wondering how i can change the color of thing in the game???
@lunedefroid8817
@lunedefroid8817 8 жыл бұрын
Thanks! I shall try do this game with classes.
@Mtfupsilon
@Mtfupsilon 3 жыл бұрын
That is nice project buy when I tried it's not letting me play like when I open it , it says press any key to close windows...... idk how to fix it , its been a while I am trying otherwise the gameboard , snakehead, fruit is there but can't play.
@guyrogen9911
@guyrogen9911 2 жыл бұрын
Thank you kind sir, with your wisdom I have made my first C++ game
@youtubefreek87
@youtubefreek87 7 жыл бұрын
you have the best tutorial for snake game in c++
@jrsturmvvehr802
@jrsturmvvehr802 6 жыл бұрын
So, what about that bug at 10:48? It seems to be drawing way too many spaces
@TranceManiack
@TranceManiack 9 жыл бұрын
Thank you very much for all tutorials,keep working !
@MrHilario1984
@MrHilario1984 2 жыл бұрын
Brilliant exercise! And thanks for sharing here. I had some 10 years holidays in C++ and programming in general, and while I went through going back I found this amazing and simple exercise... It has awakened my brain cells. I watched the first 2 parts and I wrote it till it worked; then I came back to compare the logical thinking for the tail. I was impressed with the simplicity... In my code I have things like: class TailSeg { private: int seg_Xcoord; int seg_Ycoord; public: TailSeg(const int _x, const int _y) { //Constructor this->seg_Xcoord = _x; this->seg_Ycoord = _y; } int get_seg_Xcoord() { return this->seg_Xcoord; } int get_seg_Ycoord() { return this->seg_Ycoord; } void setCoords(const int xx, const int yy) { this->seg_Xcoord; this->seg_Ycoord; } }; vector Tail; //Tail is defined as a vector of tail segments (Global object) Proven: there are thousands of ways to solving the same problem. For me that's the most beautiful part of programming Regards, VH, Mozambique
@Onedot.
@Onedot. 5 жыл бұрын
thank you NVitanovic ...🤗🤗🤗
@ionlyemergeafterdark
@ionlyemergeafterdark 3 жыл бұрын
Thanks for great stuff, most helpful.
@DarikAndualem
@DarikAndualem 10 ай бұрын
Special 🎉love it 🎉❤❤❤ more pls
@lukazotovic5
@lukazotovic5 Жыл бұрын
Brate, svaka cast, vrlo interesantno ali najbitnije mnogo sam naucio
@NoChillAustin
@NoChillAustin 7 жыл бұрын
After watching this, now I want to make pacman
@SrbijaCG
@SrbijaCG 5 жыл бұрын
@NVitanovic, how long have you been working with c++ until you can make something like a snake game?
@yabashe
@yabashe 6 жыл бұрын
Thanks for the tutorial! Was nice to follow along!
@Trendingtech2
@Trendingtech2 4 жыл бұрын
Great efforts...
@idknuttin
@idknuttin 7 жыл бұрын
are there any libraries specifically for making games in c++ so that the screen won't flicker like that and so you can add real graphics and sound effects? For example make the snake look like a long rectangle where each segment of the tail is a square?
@mysta3152
@mysta3152 7 жыл бұрын
Look into OpenGL if you want to produce serious graphics. (The GL stands for Graphics Library.)
@punjabiwithjasman135
@punjabiwithjasman135 7 жыл бұрын
Kraz z can u explain a bit more
@divingtim
@divingtim 6 жыл бұрын
Just do it with ui instead of console
@Tritone
@Tritone 6 жыл бұрын
Use the native Win32 library to make a console screen buffer.
@blakceyedpeas
@blakceyedpeas 5 жыл бұрын
If you want to get rid of blinking you can make one string that contains whole screen and use one cout.
@1vmc459
@1vmc459 3 жыл бұрын
thanks a lot! this is my first mini project
@janssenbailio197
@janssenbailio197 4 жыл бұрын
Very cool. Love it ❤️
@jeremynx
@jeremynx 4 жыл бұрын
thank you for videos!!! Your explanation is awesome
@FREEZarts
@FREEZarts 2 жыл бұрын
that was great man i learned a lot thank you
@Cacowninja
@Cacowninja 6 жыл бұрын
0:00 Begin!
@martin_skachkov6016
@martin_skachkov6016 2 жыл бұрын
Hey, great video but i have struggles with the part where we write the logic about the tail, I don't quite get it. It apparently works but I tried debugging it in my mind to think about how the values would change but I always end up of everything being zero for the prevX, prevY and prev2X and prev2Y. Cant understand how they change their values to different from just zeroes.
@peter4722
@peter4722 2 жыл бұрын
My thinking is same as yours. How in the world?
@harischaudhry9401
@harischaudhry9401 5 жыл бұрын
Thanks for the tutorial.
@amrsamy9007
@amrsamy9007 5 жыл бұрын
Thnx for the tutorial love u 3000;
@steveli3163
@steveli3163 5 жыл бұрын
Half way in my first semester learn C++ , I bascially understand the logic until it goes to the array. Anyway, it is a simple game. Even not so fancy yet.
@juliocesarvelandia3386
@juliocesarvelandia3386 4 жыл бұрын
NVitanovic, muchas gracias... " Si funciona ". Seguimos contando contigo para más proyectos
@springscale1811
@springscale1811 6 жыл бұрын
I feel like the Draw() should be behind the Input() and Logic(), otherwise, the screen is "lagged" a little bit and made near wall fruits almost impossible to pick up. Also, I added a while loop that "trys to respawn the fruit while the fruit is in the tail of the snake", but other than that, this tutorial helped me a lot! thank you!
@galaxy-music9138
@galaxy-music9138 5 жыл бұрын
This tutorial was very helpful I will try to study over this
@leondelrosario1149
@leondelrosario1149 6 жыл бұрын
Thanks for the tutorial dude👌
@hamzaawan76
@hamzaawan76 8 жыл бұрын
Good job ! The tutorial and source code is very easy to understand. But can you upload a video on how to make simple Space invader game in c++?
@TheBrickagon
@TheBrickagon 4 жыл бұрын
Is there any way you can do the map look more like a square keeping the same size for the width and height?
@gavin8535
@gavin8535 8 жыл бұрын
for some parts you did not explain how they are there, like prevX and prev2X....many other parts are still confusing
@SapphFire
@SapphFire 8 жыл бұрын
Yep
@4547466
@4547466 6 жыл бұрын
Theres an awesome way to find out yourself: Comment it out or remove it and look for differences with the game!
@JordanMetroidManiac
@JordanMetroidManiac 6 жыл бұрын
If it wasn't there, you'd have to do some weird workarounds to fix the errors you'd find.
@mikiscoffield1815
@mikiscoffield1815 4 жыл бұрын
@@JordanMetroidManiac inappropriate and uncalled for
@JordanMetroidManiac
@JordanMetroidManiac 4 жыл бұрын
miki scoffield1 I edited it so it is no longer disrespectful. I apologize...
@ArhisAlight
@ArhisAlight 4 жыл бұрын
Wow!!! It came like a sip of inspiration to me!! Thanks buddy a lot! Now I am thinking about to rebuild it with classes and proper methods! Incrediable! Only with terminal we got such a game=) Now I am thinking about making the Tetris :D
@bigbang2a
@bigbang2a 6 жыл бұрын
Hi! Simpler way to change the tailX and tailY values : for ( int i = nTail-1 ; i > 0 ; i-- ) { tailX[i] = tailX[i-1]; tailY[i] = tailY[i-1]; } tailX[0] = x; tailY[0] = y; Thanks for this great tutorial btw :D
@juvenildr
@juvenildr 6 жыл бұрын
why it doesnt work for: for(int i=0; i
@madgepereira2891
@madgepereira2891 4 жыл бұрын
This seems to be easy coz some things are familiar for me. Wow great job. Thanks. I'll try this.
@samuelperez2223
@samuelperez2223 4 жыл бұрын
Even though you said that this game is simple, this was so hard to understand since I am still learning the fundamentals of C++. This was a cool project though!
@antares6998
@antares6998 3 жыл бұрын
this was fun thanks!
@shyamkachhadiya4964
@shyamkachhadiya4964 6 жыл бұрын
dude thats really awesome
@DanielBerzinskas
@DanielBerzinskas 3 жыл бұрын
Do I have to license it to redistribute it?
@yogihendrawan3991
@yogihendrawan3991 4 жыл бұрын
Nice game, i so enjoy it to make and play the Snake Game. Thanks :)
@programmingandfinance8239
@programmingandfinance8239 9 жыл бұрын
love the tutorial
@hunt3r58
@hunt3r58 6 жыл бұрын
thanks bro just needed that complicated algorithm that moves the coordinates of the snake head to the following scales(tails) ...ive build the game in complete c++ graphics
@carljohnson7342
@carljohnson7342 8 жыл бұрын
Super si veliko hvala
@jacobhein4949
@jacobhein4949 9 жыл бұрын
If you change the coding within void logic so that it looks like if (x > width || x < 0 || y > height || y
@Skiuba
@Skiuba 4 жыл бұрын
I love this tutorial but is there a chance that you could make new snake game tutorial where u explain all the commands that you use?
@eraytutmaz1331
@eraytutmaz1331 7 жыл бұрын
I'm beginner of c++ And thank you so much
@lijack456
@lijack456 7 жыл бұрын
thanks a lot ,i really learn something!
@V-for-Vendetta01
@V-for-Vendetta01 8 жыл бұрын
can u explain why u did that in 6:00
@_tanujpokhriyal
@_tanujpokhriyal 3 жыл бұрын
After watching this video i can print hello world😂
@ihsannurrahman9629
@ihsannurrahman9629 5 жыл бұрын
this is good,thanks man :D
C++ Tutorial 19 - Dynamic memory
12:40
NVitanovic
Рет қаралды 89 М.
C++ Tutorial 18 - Simple Snake Game (Part 1)
11:16
NVitanovic
Рет қаралды 2,2 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
C++ Tutorial 18 - Simple Snake Game (Part 2)
12:24
NVitanovic
Рет қаралды 753 М.
Snake learns with NEUROEVOLUTION (implementing NEAT from scratch in C++)
28:08
C++ Tutorial 15 - Making simple Tic Tac Toe game (Part 1)
23:46
NVitanovic
Рет қаралды 289 М.
Game Boy Development Environment
9:07
NesHacker
Рет қаралды 257 М.
How to program in Godot - GDScript Tutorial
58:10
Brackeys
Рет қаралды 892 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 679 М.
Coding Challenge #3: The Snake Game
27:27
The Coding Train
Рет қаралды 3,4 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 100 М.
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 629 М.