C++ Tutorial 21 - Simple Pong Game (Part 1)

  Рет қаралды 198,923

NVitanovic

NVitanovic

Күн бұрын

Пікірлер: 143
@DerMeteor1324
@DerMeteor1324 8 жыл бұрын
You make great and nice tutorials. I finally found a KZbinr that shows me how to program in C++. I just wanted to say thanks to you. Keep going with this!!
@hellomynameisorange2860
@hellomynameisorange2860 9 жыл бұрын
Thanks dude! I love your tutorials, you've gotten me into C++.
@ElderMoro
@ElderMoro 3 жыл бұрын
This guy is freakin amazing.
@karshtharyani4253
@karshtharyani4253 6 жыл бұрын
The random direction won’t change unless you add randomise() to the code, right? That’s why you got 6 twice. When you re-ran the program you got a 5 because it was a new seed. Am I correct?
@justanotherfangirl2398
@justanotherfangirl2398 4 жыл бұрын
Just do #include time.h at the start then put srand(time(NULL)) above direction = (eDir)((rand() % 6) + 1);
@justanotherfangirl2398
@justanotherfangirl2398 4 жыл бұрын
except that goes into negatives wtf
@anonymousmask3823
@anonymousmask3823 7 жыл бұрын
I love creating games on c++ Thxx for all the videos
@calvinmillett
@calvinmillett 8 жыл бұрын
Hey, im having a problem when i try to build the program it gives me an error for the class cBall. The exact error is ( 'cBall::Move': non-standard syntax; use '&' to create a pointer to member )
@viktornikolov1570
@viktornikolov1570 3 жыл бұрын
I really like the opening to the video. Great content as well. I hope you will have some time to do more in the future. Cheers.
@jorgeolguin3274
@jorgeolguin3274 5 жыл бұрын
how did i get negatives ex: ball [-1,-1][2] ? did i do it right ? it successfully built but i thought the numbers would only be 1-6?
@farahhawani5530
@farahhawani5530 7 жыл бұрын
why my program didnt recognise eDir? is it in C++ coding or not?
@farahhawani5530
@farahhawani5530 7 жыл бұрын
Puneet Verma okay thank you..!!
@leenahjune
@leenahjune Жыл бұрын
I have a question..when i code direction =(eDir)((rand()%6)+1) It show error...compiler say 'rand' not declare in this scope
@erlindamecate
@erlindamecate 3 жыл бұрын
bro this helps my mom is impressed ty bro she proud of me
@samuelshtefanio5029
@samuelshtefanio5029 8 жыл бұрын
I had a question to ask; what did you use to start the project? There are a whole bunch of .net options that are available but they don't seem to fit my needs for making a game like this. Help please!
@NVitanovic
@NVitanovic 8 жыл бұрын
In the newer versions of Visual Studio >2013 Visual C++ is not included by default. When installing the Visual Studio make sure you have checked that option. Then go to Other Languages -> Visual C++ -> Empty project.
@randall.o8995
@randall.o8995 5 жыл бұрын
can anyone explain to me how the friend function works at line 62 to 64 ? thanks in advance.
@Nguyenthao-oj9ku
@Nguyenthao-oj9ku 2 жыл бұрын
very late, maybe you do not need this information anymore: friend to access x and y that are private members of a class.and he uses an overridden operator, in this case,
@codergirl1518
@codergirl1518 8 жыл бұрын
Excellent tutorial, exactly what I was looking for!!
@daemon4683
@daemon4683 8 жыл бұрын
So I'm a Java guy, and I see this and I'm just like "what the fuck...?"
@LuRybz
@LuRybz 8 жыл бұрын
java tries to simplify things by describing the code (more verbose) c++ tries to simplify things reducing code. That's how I feel about them.
@daemon4683
@daemon4683 8 жыл бұрын
lucas pinto I prefer more the verbose path.
@ad0ns371
@ad0ns371 8 жыл бұрын
C++ is far more direct. Just like lucas pointed out . Also Java is more close to natural language than C++ even tough they both are high language and Python is too.
@billhosh9165
@billhosh9165 8 жыл бұрын
You are not a "java guy", but a guy who knows shit about programming. Except it and do not hide behind the excuses.
@BananaNerd-guzaboo
@BananaNerd-guzaboo 7 жыл бұрын
Accept* And don't call me a grammar nazi because if you're going to give out criticism you've got to be able to take it. :)
@immanuelsiburian2135
@immanuelsiburian2135 6 жыл бұрын
you are great. THAK YOU. keep going on sir
@seanmccain1450
@seanmccain1450 7 жыл бұрын
#include using namespace std; enum eDir {STOP = 0, Left = 1, UpLeft = 2, DOWNLEFT =3, RIGHT = 4, UPRIGHT = 5, DOWNRIGHT = 6}; class cBall { private: int x, y; int originalX, originalY; eDir direction; public: cBall(int posX, int posY) { originalX = posX; originalY = posY; x = posX; y = posY; direction = STOP; } void Reset() { x = originalX; y = originalY; direction = STOP; } void changeDirection(eDir d) { direction = d; } void randomDirection() { direction = (eDir)((rand() % 6) + 1); } inline int getX() { return x; } inline int getY() { return y; } inline eDir getDirection() { return direction } void Move() { switch (direction) { case STOP: break; case LEFT: x--; break; case RIGHT: x++; break; case UPLEFT: x--; y++; break; case DOWNLEFT: x--; y++; break; case UPRIGHT: x++; y--; break; case DOWNRIGHT: x++; y++; break; default: break; } } friend ostream & operator
@camranh_royal
@camranh_royal 6 жыл бұрын
zan q!
@Dexter101x
@Dexter101x 6 жыл бұрын
Have you got a video which states where you start off from? Like, because I am a beginner with Visual Studio
@paranomal2962
@paranomal2962 4 жыл бұрын
Bro your intro song is from "mein Bizeps brennt" hahaha
@hienvu5908
@hienvu5908 8 ай бұрын
mong a ra video nữa đi ạ huhu
@narahs22
@narahs22 8 жыл бұрын
Did you get your directions wrong? For example I thought DownRight should be x++,y--. and when you run the code at the end it says the dir'n is DownRight but it goes UpRight from (0,0) to (1,1)
@willway1234
@willway1234 8 жыл бұрын
When you go down, the y co-ord increases.
@shahmirkhan9481
@shahmirkhan9481 8 жыл бұрын
but why does the y co-ord increase when we go down? it must decrease right!!!
@modoamodoq168
@modoamodoq168 8 жыл бұрын
Because the way your screen is drawn, you screen draws from the top left pixel down to the bottom right, instead of saying that all the Y coordinates are negative, they just have them going positive instead. That is why the y co-ord is increasing as it goes down instead of decreasing.
@kavindukokila1543
@kavindukokila1543 3 жыл бұрын
I have an error:no matching function for call to'cBall::randomDirection()' what is it? Plz help
@Darksassy
@Darksassy 8 жыл бұрын
Can someone help me understand what this function does...and what inline int gety() { return y; } , is used for please. Thanks friend ostream & operator
@ParsaTaba
@ParsaTaba 4 жыл бұрын
I dunno bro
@alaaalmhsery718
@alaaalmhsery718 9 жыл бұрын
why my rand() need to include #include and your not?
@alaaalmhsery718
@alaaalmhsery718 9 жыл бұрын
+alaa almhsery im working on code blocks by the way
@vibecheck4121
@vibecheck4121 4 жыл бұрын
Can i make this with Dev C++?
@zelo_s6707
@zelo_s6707 8 жыл бұрын
Please help Im using Xcode on Mac and Im using conio.h , but it says error, file not found! Please Help Me.
@mariusvon6364
@mariusvon6364 6 жыл бұрын
Hi, i had the error while trying starting the "application" "C1010" then i done the steps what microsoft says and then i have two more errors after the second try starting i had two more errors "LNK2019" and "LNK1120" can you help me please?? rgds, marius
@francistabora1580
@francistabora1580 5 жыл бұрын
Great tutorial, thanks a lot ☻.
@crimsonwolf7579
@crimsonwolf7579 7 жыл бұрын
¨how do you get the boxed in - at lign for im still new to coding
@dhjslabxdhdj3152
@dhjslabxdhdj3152 6 жыл бұрын
I program with ubuntu and I do not have the library conio.h, how can I install it (I do not have an ide)
@Nguyenthao-oj9ku
@Nguyenthao-oj9ku 2 жыл бұрын
rand() does not give us a random, I tried to repeat the program many times, and the direction still is 6
@edriantiburana
@edriantiburana 6 жыл бұрын
I get this errors : Error 1 error C2614: 'cPaddle' : illegal member initialization: 'cPaddle' is not a base or member 3 IntelliSense: "cPaddle" is not a nonstatic data member or base class of class "cPaddle" please help. I'm new in programming.
@ehgh724
@ehgh724 6 жыл бұрын
hi - tnx for tutorial - i want to write a breakout game in c++ but i don't know how i can ,actually i don't know how to start, so i watched this tutorial. i want to know how i can use this tutorial and change it to a brakout game?
@omgitzzaaronn5788
@omgitzzaaronn5788 8 жыл бұрын
i get this error: 'return': cannot convert from 'int' to 'std::ostream &'
@piyush9705
@piyush9705 7 жыл бұрын
if its a function check if uve used '()'after it.. that's when I usually get that error
@classim3715
@classim3715 5 жыл бұрын
You should return o letter I not zero bro if you had int function you return a like like 0 like int main(); but with ostream I you should return the letter o;
@alexwashbach3315
@alexwashbach3315 5 жыл бұрын
i copied it exactly and got about 40 errors.
@jaideepsinghjeji8444
@jaideepsinghjeji8444 5 жыл бұрын
How?
@akazecik
@akazecik 7 жыл бұрын
Aren't functions defined inside a class inline by default?
@johnniegilkerson4724
@johnniegilkerson4724 Жыл бұрын
Your code does not work fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source? 1>C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml"
@mihai98is77
@mihai98is77 6 жыл бұрын
I have a problem. my application tells me that "rand" was not declared in this scope plese help me
@faceloltv2594
@faceloltv2594 6 жыл бұрын
#include use this then it is working
@electromobilegadget5300
@electromobilegadget5300 8 жыл бұрын
What is the game of the software that you are using to create this game?
@electromobilegadget5300
@electromobilegadget5300 8 жыл бұрын
Thank you :)
@HeldrikBoldhart
@HeldrikBoldhart 8 жыл бұрын
You can do this exact code in Notepad++ using C++ as the language, correct?
@Lou_0b1
@Lou_0b1 8 жыл бұрын
Correct.
@tomiikunxd
@tomiikunxd 8 жыл бұрын
you can, but you'd need to compile with which Notepadd++ does not include
@LostDarkKingEU
@LostDarkKingEU 9 жыл бұрын
Hey man i keep getting all kinds of errors when trying to run the code. even if i copy the full code listed in the discription. had the same problem with the snake game. tryed typing it over step by step but does't work. please HELP!
@alaaalmhsery718
@alaaalmhsery718 9 жыл бұрын
niels-yvo grummel i think that you have to sour what your typing cos its work
@LostDarkKingEU
@LostDarkKingEU 9 жыл бұрын
+alaa almhsery not saying it's the code but asking why is doest work on my pc
@NVitanovic
@NVitanovic 9 жыл бұрын
+niels-yvo grummel Please provide the error that you get.
@LostDarkKingEU
@LostDarkKingEU 9 жыл бұрын
+NVitanovic Here are some prt screen of my errors and a text file of the code i wrote. www.mediafire.com/folder/9rt66iwbeab8f//C%2B%2B%20Errors%20Ping%20Pong
@obx4454
@obx4454 9 жыл бұрын
how new are you to programming? some of these errors are baby mistage errors. for the undeclared identifier you misplaced some brackets or used x and y before declaring them take a look at your code logically
@tyru2
@tyru2 8 жыл бұрын
what project type is that
@seanmccain1450
@seanmccain1450 7 жыл бұрын
Im having a problem apparently rand is not declared in the scope
@showallmemes6268
@showallmemes6268 7 жыл бұрын
I get an error when I do direction = (eDir)((rand() % 6) + 1); it says that "rand" was not declared in this scope
@Mister_Gerbelle
@Mister_Gerbelle 7 жыл бұрын
did u forget #include "inustd.h"
@johnshalenko2551
@johnshalenko2551 7 жыл бұрын
Could you explain which kind of application this is?
@NVitanovic
@NVitanovic 7 жыл бұрын
It's a C++ application. If you are interested in which template in visual studio did I use, it's an Empty project, with added source file named main.cpp. Check out my first C++ Hello World tutorial for more info.
@johnshalenko2551
@johnshalenko2551 7 жыл бұрын
NVitanovic No need, I figured it out through just watching, decent tutorial by the way.
@daveygrean3798
@daveygrean3798 5 жыл бұрын
help it wont run, says cant locate iostream? do i need to download it from somewhere?
@daveygrean3798
@daveygrean3798 5 жыл бұрын
im using turbo c++
@daveygrean3798
@daveygrean3798 5 жыл бұрын
i just pasted the source code into turbo?
@yaboitroy8970
@yaboitroy8970 4 жыл бұрын
turbo c++ works horribly for most code, visual studio is much better
@edurd121
@edurd121 8 жыл бұрын
Excuse me but my code like only stays for like 1.500 milliseconds and then it closes
@vicc.8135
@vicc.8135 8 жыл бұрын
+Eduardo Bourget might want to try adding system(''pause''); return 0; at the end of your code if your using visual studio as an idea
@vicc.8135
@vicc.8135 8 жыл бұрын
ide*
@адекватникошмар
@адекватникошмар 8 жыл бұрын
will this work if i do this on notepad ?
@NVitanovic
@NVitanovic 8 жыл бұрын
It will work, if you compile it later properly.
@адекватникошмар
@адекватникошмар 8 жыл бұрын
Aj probacu
@Muzzycal
@Muzzycal 8 жыл бұрын
jel ti uspelo brate :D
@usama57926
@usama57926 6 жыл бұрын
you are great
@LopogaX
@LopogaX 7 жыл бұрын
C++ Primer plus rather than c++ primer?
@matt192
@matt192 7 жыл бұрын
Why this? error: 'rand' was not declared in this scope
@Karukami1
@Karukami1 7 жыл бұрын
add #include at the start
@nunocabrita7238
@nunocabrita7238 5 жыл бұрын
@@Karukami1 I can't find stdlib.h Help please
@charity2947
@charity2947 2 жыл бұрын
@@nunocabrita7238 bruh ya answered after 2 years wow.
@hodgsontetteh4058
@hodgsontetteh4058 6 жыл бұрын
boy do u sound sound like my Prof from ccny......Professor Amir
@manriqueiriarte8268
@manriqueiriarte8268 7 жыл бұрын
can someone explain to me why down left he uses y++ and up left he uses y--?
@elliot8275
@elliot8275 5 жыл бұрын
y-- refers to the fact of the position of the object other wise it will be high or to low, (remember in scratch when you tried to code and when you tapped forward and left or right it will only go one or the other) this prevents this
@classim3715
@classim3715 5 жыл бұрын
Someone just explain that the initial position (0;0) is not center that why if it was center then your logic is right but image the initial position on the top or or bottom it will different direction
@jeffreychen6591
@jeffreychen6591 7 жыл бұрын
#include using namespace std int main() { cout
@Mister_Gerbelle
@Mister_Gerbelle 7 жыл бұрын
use unity or unrealengine if u wanna get into c++ game development or use opengl
@Hazzardous2005
@Hazzardous2005 4 жыл бұрын
you forgot a semicolon
@peterbiswalo3896
@peterbiswalo3896 5 жыл бұрын
THis didn't work at all
@quantamzero7919
@quantamzero7919 7 жыл бұрын
can that source code page look any more sketchy lmao
@camranh_royal
@camranh_royal 6 жыл бұрын
up is y++ not y--...down should be y--...
@yh_hat_trick491
@yh_hat_trick491 6 жыл бұрын
In certain graphics API's, 0,0 it at the top right Some 0,0 is in the middle. Some have it at the bottom left
@rachitvasudeva7538
@rachitvasudeva7538 4 жыл бұрын
bro, in 2D games, the default cartesian system goes like this: right: +X left : -X up: -Y down: +Y
@atlantic_love
@atlantic_love 4 жыл бұрын
Try writing code before poo poo 'ing the basics of computer programming.
@LuRybz
@LuRybz 8 жыл бұрын
Code: pastebin.com/VXkJzGCb
@jonathankoivuneva6466
@jonathankoivuneva6466 7 жыл бұрын
thank
@Jiangyou666
@Jiangyou666 4 жыл бұрын
cool
@seanmccain1450
@seanmccain1450 7 жыл бұрын
my coding so far
@mihaelaafloroaie8515
@mihaelaafloroaie8515 6 жыл бұрын
9:58 *DEFAULT MUSIC STARTS PLAYING*
@mishalavik4595
@mishalavik4595 6 жыл бұрын
👍
@Ventinky
@Ventinky 4 жыл бұрын
bruh what project type? (ik i commented after 4 years)
@radulescustefan4532
@radulescustefan4532 4 жыл бұрын
@xxxjacob2 official idk. I use code blocks(console application). I have some problems when i writed the code so i decided to copy paste it from the link in the description but it sends me on porno sites. Could u please help me get the code?
@atlantic_love
@atlantic_love 4 жыл бұрын
Can hardly hear you.
@seanmccain1450
@seanmccain1450 7 жыл бұрын
Downloading visual studio 2017 to get the features that are used in this video lol im smart
@JohnJigsaw420
@JohnJigsaw420 7 жыл бұрын
Bruh slow down. I can't keep up fast enough to understand what's going on lol
@cd6737
@cd6737 7 жыл бұрын
You gotta see part one and all the other ones leading up to this one in that case
@parmstrong
@parmstrong 6 жыл бұрын
Try pausing the video.
@seanmccain1450
@seanmccain1450 7 жыл бұрын
whoops wrong part.
@alacastersoi8265
@alacastersoi8265 7 жыл бұрын
Honestly this formatting make me want to jump off a bridge. why did he use enumeration and there are so many needed functions. Use vectors. Like slope vx/vy you know basic algebra.
C++ Tutorial 21 - Simple Pong Game (Part 2)
14:40
NVitanovic
Рет қаралды 83 М.
Code-It-Yourself! First Person Shooter (Quick and Simple C++)
38:56
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Object Oriented Programming (OOP) in C++ Course
1:30:26
freeCodeCamp.org
Рет қаралды 2,6 МЛН
Let's make 16 games in C++: Outrun (Pseudo 3d racing)
3:29
FamTrinli
Рет қаралды 1,6 МЛН
Let's make 16 games in C++: TETRIS
4:06
FamTrinli
Рет қаралды 3,9 МЛН
Code-It-Yourself! Flappy Bird (Quick and Simple C++)
18:59
javidx9
Рет қаралды 241 М.
🔥Pong Game with C++ and Raylib - Beginner Tutorial
42:30
Programming With Nick
Рет қаралды 68 М.
C++ Tutorial 10 - Making a simple ship battle (sinking) game
18:56
Let's make 16 games in C++: Chess
4:09
FamTrinli
Рет қаралды 1,3 МЛН
OpenAI's o1 just hacked the system
26:31
AI Search
Рет қаралды 22 М.
Making A Game #1: Making The Game Loop : C++ And SDL2 Tutorial
25:32
Let's Make Games
Рет қаралды 491 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН