Added: 4 years ago
From: xoaxdotnet
Views: 156,668
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (200)

Sign In or Sign Up now to post a comment!
  • Question: at this point "if ( cSquare1 != '1' )", why do you only test the "side win conditions, 1 2 3 and 1 4 7" ? Instead of adding the middle "1 5 9".

  • aburrido

  • why wont it let me debug? its greyed out in the sub menu and when i hit ctrl+f5 nothing happens

  • I've done pretty much everything the same way, but when I run the program, it tells me that "Player 1 wins!" at the moment I input a number. Even if its a number like 5234!!

    This even happens when I try to run the downloadable code from xoax.net

    help?

  • Fking SUBSCRIBED!

  • this shit is hurdddd... :(

  • if (cNextMove == '1' && sq1 = '1')

    cNextMove gives me this message: "Expression must be a modifiable lvalue."

    any ideas?

  • @prestigeScript You only put 1 equals it should be sq1 == '1'

  • Also a note to everyone saying that there is a better way:

    This lesson is meant to give new programmers a fun exercise to tie everything they learned in lessons 1-8 together. It also intentionally demonstrates situations that would better suited with arrays. The observant viewer would notice that lesson 10 is one-dimensional arrays.

    Another great thing about this lesson is that it introduces very subtly global and local scope which is later covered in detail in lesson 11.

  • to fix this code just a tad you need to move the

    iPlayerTurn = 1;

    so it is inside the nested

    if (cPlayAgain == 'y')

    otherwise the next else statement will not be referenced with the if and will generate an error.

  • @Arieken The else doesn't belong to that if statement, it belongs to if(bGameOver)

  • to viewers: you should visit their website xoax (dot) net

    its a great websitte

  • Dude ur cool helps me alot from my school stuff

  • i love you

  • Why do i keep recieving this message when debugging the code: main.cpp

    MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

  • You should definitely be a teacher or something!

  • that was confusing

  • AH! I see my problem, I tried to program the game with a while loop instead using a do while loop!! UGH!

  • Got it all now what :$ I can't play it ... lol

  • on a side not how to turn on the line numbers since mine is currently blank unless i dubble click which just adds a mark on that one line...

  • you should be typing the code and telling us what it means as you go and then do the over view...im not learning a fucking thing from you

  • i did not understand that code... i should go and learn more about chars. 

  • i feel like a boss changing up the code every-so-often to make it better.

  • Also don't just tell me where to download the code. Scroll over the code so i can actually see and type it my self instead of bouncing all around an not showing somethings...

  • all that code to play tic tac toe with numbers in a console window.... i have a new found respect for games like skyrim

  • I find this to be a good way to remind myself about the basics before, say, a test.

  • It will be easier to read your code if its Allman style :)

  • I would add a light rain sound effect in the background so the mic static doesn't sound bad.:)

  • Simple and lucid explanation and also very useful unlike many other tutorials that just yield a do nothing Hello World. Thanks.

  • the guy reminds me of garfield for some reason

  • Could you use the system("clr"); command for the refresh so the boards wouldn't get stacked?

  • Isn't there a possibility to play against the computer?

    Is there a code wich clears the screen??

    I don't like it if the display bord loads again and again which causes the dialog to get full

    where should I put it??

  • @MDSNproductions Using just things you have learned to this point...

    just after your include, add another include for stdlib.h

    This library allows you to use the system() function to pass DOS Console commands.

    CLS is the console command to clear screen so...

    system("CLS");

    There are better ways, but they are for later. ;)

  • Comment removed

  • I programmed something very similar, only python, and made it all by myself! :)

  • i did it, but i haven't really learned anything just copied :(. no way i could do this again without this video up. Practice makes perfect i guess... maybe if i do this 5 time i will start to actually understand what's behind it.

  • if u pause at 0:10 you will notice binary in the background.... on a c++ tutorial...

    seems like the dog is rounding up the chickens, as we say in the south.

  • @Sikeman214 So...? What's the problem with that? Boolian code is binary... so it would make sense... (BTW sorry for replying 10 months later <.<)

  • @0Raidenz0 well dammy diggy, didn't dang know a pro would be watching a beginner C++ Tutorial, hot diggidy, as my confederate "negras" call me!

  • @Sikeman214 I'm learning too, except i'm actually learning, and i didn't diggidy hot shmiggidy understand a shit you said

  • I'm 11 and i can follow your tutorials, Your awesome, just, awesome.

  • great vid i just want to know though what comes at the end every time i enter the current code there are build errors

  • I....I did it!!

  • You're doing great, continue the good work, thank you

  • You're doing great, continue the good work, thank you

  • thank you, you're doing great, continue the good work

  • i never knew tic tac toe could be so complicated...

  • I can't tell if there's a space between bGameOver and (true). Does it matter if I add a space or not? Or will that mess it up?

  • @GeekingForJesus It doesn't matter, but it is neater if you do add a space.

  • awesome info keep up the good work. your lessons are really helping me learn!

  • Awesome! Nice and fun exercise, great tutorial and easy to understand source code as well.

  • Heh, I'm 13 and this all makes sense to me. This is my first time learning to program and this dude is a LOT of help. I'd love to make this but it seems time consuming but at least I know how to :D

  • @MegaCamu if you use void main() you cant use return 0. try changing void main() to int main() or erasing return 0 :)

  • When i try to use the main.cpp file, and build it, i get this error: ´::main´must return ínt´

  • 18 people don't know what tic-tac-toe is :p

  • you, are my c++ hero

  • to keep from using std at the beginning of every console output and input i could just type using namespace std: at the beginning of the code rite?

  • he makes sense unlike others, haha

  • Yes, he's using Hungarian notation. And robbbert, why do you care about making your code less lines if you're just stacking code and making it less readable? It's okay to have a code that is a lot of lines, I'd rather read 200 lines of well written code than 40 lines of badly written, jumbled up code. Although you could condense some of this in a neat way by using arrays couldn't you?

  • now i have a console project but how can i play this game???

  • Great tutorial as always...................

    If I type 1x it recognize the move, as 2o, and so on, and never pop up the invalid move as should be.....Why is this happening, the program is asking for equal to '1' or '2',

    1x should be pooping invalid move and not accepting in ???

  • Is there any reason why you call them cSquares? Or is that just a little naming convention you've got a habbit of?

  • @Ethaninja I believe he is using Hungarian notation, where the name of a variable indicates the variable's type.

  • I got an error when compiling the original program. ' ::main' must return 'int'

    What do I do?

  • Nevermind I found out the answer after searching a bit.

    USE - int main(void)

    DO NOT USE - void main()

  • @OpenTheo i just leave the brackets empty as long as its a one string code like this

  • You lost me here meh >.< This is way out of my league ;D

  • I tried to make a tic tac toe game without looking at this video (as a challenge). However, I didn't realize it was with two REAL players in mind. I thought it was Player vs Computer. My player vs AI version works, but the AI isn't proper. Rather than actively seeking out to make a straight line, the computer simply chooses (at random) a square that hasn't been filled out yet.

  • @DasPooperTrooper How'd you make it choose a random square?

  • Type in somewhere in the beginning...

    system("TITLE anything you want");

    system("COLOR 9");

  • @LilLokoteX3 If this is what you want, then you should at the very least add if statements around this, that checks the OS platform your're running, in order to be able to adopt the logic across OS platforms. Not that it matters a lot in these games but maybe it does for some, so i'll stfu from here on and out, cheers.

  • checking for a valid move entry from the player is much longer than it needs to be. Using an array of characters for the game board instead of 9 separately named integers:

    cin >> nextMove;

    int move = atoi(&nextMove); // converts the character to an int

    if (board[move-1] == nextMove)

    { // move is valid

    }

    else // move is invalid

  • Almost completed this one. How the fuck is tictactoe so hard. I cant even imagine the code for a game like Oblivion IV

  • @Semperfi918 dude it couldnt be any longer than 250,000 lines of code

  • @thedarklordx Wth only 250,000 thats alot then again it takes 4 0r 5years to make with hundreds of people working on it I guess thats reasonable.

  • @Semperfi918 250,000 lines wouldnt actually take years to do unless you barely worked

  • @thedarklordx Really thats a relief. I am making 3d animations in 3d max and then code it with microsoft studio. It takes me 6 or 7 hours just to make 1 charachter, make the mesh, then the bones, rig it, give it textures and finnaly paint it. I have alot more respect for the makers of video games.

  • @Semperfi918 good good im glad i helped

  • Comment removed

  • Hehe, the tic tac toe game is simple and straight forward, so take your own suggestion seriously :) high-end game development is an endless supply of coffee as I am sure some say. Oh and these complex games apart from the physics algorithms that lure your 3d objects around on the screen are hard to comprehend but also the 3d object have to be designed and I would never claim that it's a job for one man alone ;)

  • Dude what's with the systems Hungarian?

  • I didn't understand any thing From this lesson but i am sure that a few did

  • this is neat but you can do this a lot easily doing for loops. still, a good exercise.

  • ok i am extremely lost here..i managed to copy everything and it didnt work..i have an error saying "error expecting a '}'"...can anyone help me? ive also tried grabbing the code off the site and tht didnt work either...i dnt get a board just sum symbols, numbers, and letters and it saying Press any key to continue" so can sum1 kindly lve me a message on sum help!!! i rly wanna learn this stuff

  • @epidemiq666 :HAHA, u probly missed the } at the end of the program, the { and } help start and end the program i hope that helped

  • @epidemiq666 "error expecting a '}'" means you're missing a closing curly bracket somewhere. I downloaded the code and it worked. Did you double click the .sln file to open it?

  • hmm. How come in your program you didnt type in after the include statements using namespace std instead of having to type in std::cout over and over again?

  • did you make this by yourself? This is awesome.

  • i see at 2:53 theres pretty much elseif expressions(or whatever), does c++ support select case...case... expressions? , cos vb does and its more simple than using elseif for me

  • @Wegzo The selective structure: switch. google cplusplus reference

  • i only know like really really basic c++ like nearly nothing but i was able to make a simple calculator. It took me 6 lines of code. Nothing too special.

  • Mine just shows the TicTacToe field and then stops.........damn

  • Is "Do" anything like the "For" command? Im familiar with "While", but I haven't seen anything like "Do". Only in Dark Basic, which I didn't learn very well.

  • @Gr8gabe As explained in the previous videos, while and do while are basically the same, only with do while the code is run at least once because the condition is checked at the end of the loop, not at the beginning.

  • @NyubisVideos I see. Thanks very much. I'm much more familiar with ActionScript which I've been told is very close to C. And from what I can tell, there's not much of a difference. Thanks for posting, as well.

  • @Gr8gabe Not very familiar with actionscript but the important part of c++ is that it's object oriented while C is procedural. the tic tac toe game as the video guy made it could be C as well, it's not a program well suited to demonstrate C++.. However from a learning point of view, some argue that it's better to learn procedural programming at first.

  • There is a shorter way to code the win game condition with the '||' operator instead of using all those 'if' statements.

  • I'm using Xcode and it gives me the error on line 3, " '::main' must return 'int' ". I tried a couple things, but I'm new, so I am not sure what to do. It's really annoying, since it is the only error/ warning. Any help? (please keep in mind that I'm new.)

  • @xoxILoveCatsxox thats simple i had the same issue just change void main to int main and at the end of the program just put return 0;

  • @pimpdog93 Im also having trouble with that, but after i change it to int main () it says primary expression expected before 'char'. Any ideas?

  • @LordFlippy559 um its best if i saw your code but my best guess would be you didn't put a ; at the end of the statment before char or the line that char is on is indented improperly if you have any more trouble email me at ghostshooter@live.com

  • @pimpdog93 Thanks for the help. I figured it out, I was trying to use numbers in the char name, such as "char 1 ('1');, but i changed it to "char one ('1') and it worked fine.

  • WTF?

  • If you enter "123456" you will get six moves without mistakes.

  • i like your intro music it matches your tutorials

  • is saying:

    char cSquare1('1');

    or

    bool bGameOver(true);

    The same as:

    char cSquare1 = '1';

    or

    bool bGameOver = true;

    can the "()" be replaced with "="? because i have learnt to use the = sign...

  • I did a tic tac toe in c++, it was full of gotos.

  • @johnzkeePW gotos are rarely needed in modern programming.

  • @requimrar gotos are a no no in programming...i did my tic tac toe game using fuctions and 2 array ...i did it before watching this tutorial and it is alot shorter even than this one ;)

  • have you tried writing this game using a multi-dimensional array?

  • @Traviezo173 thats what i would do taswell.

  • Make that into Int Main with a Return 0;

    and have system("cls"); after each player's move

  • i copyed everything i saw down and it works fine for me but is there a way to get rid of all the suff on the screen?

  • system("clear");

  • didnt work but i found out what does...

    system("cls");

  • close enough :) yet dont use it if your using serious about making proper apps

    since its windows specific it creates massive problems

  • can someone give me a complete code for these??? pls.. im begging... need to study it...

  • You could have just read the videos info on the right and navigated to the website to grab it.

  • is there a way to put the number of the line next to the code in visual c++?

  • So, should I be able to recreate the whole thing before moving on. I understand mostly whats going on but at the moment I would not be able to make my own without help.

  • in the else statement of bGameOver has the Alternate player turn if(iPlayerTurn ==1){iPlayerTurn = 2;} else {iPlayerTurn = 1;}

  • My first tic-tac-toe was 558 lines :(

  • LOL

  • haha i made a battleships game in c++ and i did a similar thing. i totally over-coded it because i didn't know any neat shortcuts, or anything much about structuring code efficiently.

    damn i could write it so much better now, i should give it another shot. you should to, it will make you feel better how much you've improved ;)

  • mine was 1000, but it had a full on unbeatable AI system.

  • I did that once in gamemaker, it was 5000 lines

  • @wildboy One, they have lots of people working on the project. Two, its not only C++, they are also using OpenGL or Allegro or SDL, some kind of object oriented programming library and they are also using the Blizard's Engine to make the maps and the items, so the code only handles the actual value's of each items, not everything about the game.

    Hopefully this helped :D

  • Cool. Im already into OpenGL And want to learn it 100% through examples...

    C++ And Open Gl Would be a good start to start

    a proffessional game..? Assuming I had endless Time to make that game..?

    And of course 3dSMAX 9 for animations and Models.:)

    THats it? right?:P

  • Im gonna invest heavily in ONE game engine

    then make ALOT of games through that engine:D

  • spot on, this is how Valve does it

  • Good luck, the ONLY company to get lucky like that is Valve.

  • oh dmn it's like alot of programming for the most simple game

  • not if you really really look at what he types.

    everything is understandable in relation to the output created.

  • thats intense... how do people make wow useing this stuff?

  • Yes abit more respect for the programmers no eh?:;P

  • mmm guys i have a problem... how to create a multi letter constant? char doesn't work... plz help me!

  • double????

  • I can't seem to remember all of this stuff. Maybe i'm just stupid

  • Yes.

  • nah, i can't keep it in my head either ;P

  • It helps if you use multiple tutorials. Sometimes its boriong to just study c++, but if you really want to get the code in your head without ti becmong super annoying watch different peoples tutorials. That way you leanr it over a few times in a different way.

    A really could tutorial series is

    antiRTFM 's tutorials. If you are stupid don't worry trust me it doesn't get any simpler than his explanations

  • I tried Anti-RTFMs tutorials, but he's got like, 80 + 10 minute tutorials. And they were all so drawn out and soooo boring.

    XoaXs seem to help alot better, straight to the point.

  • oh ya i know his are pretty boring lol.

    I just mentioned them because the fact that they're so drawn out makes ti easy to remember everything.

    Like maybe use this tutorial, which gets straight to the point, then use his for futher understanding.

    Or just practice lol I guess it doesn't matter.

  • yea, me too. {We are both stupid = "true" ;}

  • I feel stupid too

  • I thought I would try to make my own Tic Tac Toe game using what I had learned inthe first 8 videos. I did it and was proud that it was only 150 lines of code, so I checked what they had... and they only had 69... *cry*

  • @BigHomieJet You can't measure the quality of the program by counting the lines..

  • @MrKiller00224 fewer lines of code are always better

  • @MrKiller00224 actually as a rule of thumb if a programmer manages to do the same thing as you in less lines of code than you there usually the more experienced/better programmer

  • @thedarklordx r u even a programmer?? that statement is completely invalid, u can say that for assembly but not for high level programming... actually, if u were a computer science student anywhere, u would know this...

  • @Santijiwi what statement? i made like 5 your gonna have to be more specific

  • @thedarklordx thats not true. It depends on the coding style, some people like to express them selfs using more code, but allowing that code to describe it self more easily, also in many situations less code does not mean that the program is faster. So generically thats a false argument you brought up there. Less code could however reduce the number of bugs in a system, since you got some 15 - 50 errors per 1000 lines of code (industry average), and growing with a stochastic exponential.

  • @guldahlrahmi really i didnt know that

  • @BigHomieJet so? hes only 2x better than you +12 that means your pretty good considering that hes prolly been doin this for years and that your just learning

  • @BigHomieJet

    Rof 69 only??

  • @BigHomieJet I did it in 31 lines of code usimng a trick I developed.

  • @robbbert229 Care to share with the rest of the class? :P

  • @Ethaninja Yes the way to do it with so little is to trey to remove retoricle featyres. and to stack simular code. EX

    cout << "blah"; cout <<"\nBlah again";

    int a; int b; int c; int d;

    and if you do this be careful to have a backed up original.

    by the way in my tictactoe beating the ai is inposible. I have challenged my friends to beat it and they have never one. the trick is always to get the ai to try and get the spot agacent to the players picked one. Anyways the key to computer programming

  • @robbbert229 is Logic because all computer programming is for is for directing and using the programmed logic.after all all a computer is made up of is trillions of transistors. Transistors are like a valve that when a small current activates it lets a huge one pass through.

  • @robbbert229

    Stacking code can be bad for readability though...

  • @BigHomieJet Have a bad feeling you are trying to show off; but maybe you are not!

  • Lol

    I just made tic-tac-toe and it was 1000 lines of code

  • all that just for a simple game of tic tac toe???WTF YEAH RIGHT...LOL I COULD IMAGE HOW MUCH IT IS FOR A BIG ASS PROGRAM...GOSH..

  • Guys, void main() is not C++. main() must return an int in C++ (and it does in C, too).

  • lool; funnies comment all day.

  • hey, will anbody tell me the link from where i can download the code for this game?

    i tried but i could not get

  • I wrote the code just like it is but gives me that error | fatal error C1075: end of file found before the left brace '{' at 'c:\...(bla bla)main.cpp(20)' was matched | what shall i do wrong? Please Reply