 What's up guys John Hammond here coming back at you with their video and this is kind of a special one because Someone who asked me in the comments like hey, John Can you showcase just some like tic-tac-toe game or any similar kind of simple game in pure see your C++? So like yeah, sure absolutely It's gonna take me a little bit because I gotta kind of wipe the wipe the dust off shake all the rust off of my C&C++ programming, but I can showcase kind of what I did and how I got things started for a simple tic-tac-toe game So let's get a place to work I'm gonna call directory tic-tac-toe and let's get in there and start to create a main source code file So I'll put this in sublime That's my text editor of choice and this is just gonna be called Once I get to a place to save it just main dot CPP easy I'm just going to include IO stream Do an Main function. Oh, see I'm rusty. I'm like already fumbling on the default parameters for a main function Oh, you can use our using namespace standard too, so we don't have to use the std namespace or Standard namespace for everything that we end up working with so Now if we wanted to we can g++ main dot CPP and now we've just got a dot out and it tells us hello world cool So let's go ahead and create a make file So we don't have to do that every time so I'm just going to call this make file and then I don't know if you know the syntax for a make file But we have a file that we want to compile or our real objects here, so we'll give it the rules for how to do that I'm going to use g++ and I'm going to specify the source code here And I'm specify the output file as just main and I do want to use I think it's standard equals C++ 17 yeah, so we can use the latest C++ version and I'm going to run a clean object so we can make clean and I'll just remove the Regular like compiled binary so now if I wanted to since that make file exists Get rid of the old a dot out if I wanted to run it make it will compile it for me So now make sorry the main binary exists if I wanted to make clean now it removes it and we're back in action Okay, cool, so a simple make file just for easy things that we're working with Now that we're kind of moving Let's go ahead and figure out how we want to Create this grid in Well, see see plus plus let's we're probably gonna want I'm considering it as like an Array like a multi-dimensional array of characters and By default they will be Like one through nine, so it's a three by three grid like you'd see in tic-tac-toe So you as the player would get to choose a number like okay I want to be I want to move at the position one or position eight, etc. Etc. And you would fill in your your Character value like an X or an O there I think by default I'll just have the player be X and the computer be oh And then you'll be able to just play like first thing So I want to get the basic functionality to be able to generate the grid and then display the grid out on the screen Just get that over with and done in this video. So let's define a Macro little thing here just so we can say grid size equals three and Now we can create a character grid character grid and we'll make it Grid size grid size again multi-dimensional ray. So we've got that three by three grid here and Let's create something that will generate the grid. So I'm going to do that with an Integer number that I'm going to keep track of okay what we're actually iterating on and then we'll do four into X equals zero X is less than grid size X plus plus Now we've got one loop. We want to do the same for our Y So we can iterate through the entire grid and we can just populate it with the number here So I'm using integer to loop though and keep track of The kind of index that we're working with but we're going to want that as a Character in our grid so I'm going to do this with the string Library or module or I don't even know what they're even called and see not gonna lie and see plus plus So that will let me use two string on This integer and it'll cast it to a string like a C plus plus I'll string So we can take the C string of that So it's just an array of characters and then we can get the first character out of it And we'll set that to grid X and grid Y So that will populate the grid and then a number plus equals one So I did that in its own loop and now I want to create a pretty much identical loop just to print that stuff out and we will separate this into a Game object that will have these functions on its own in the next video probably But I do want to Create these separate loops now so we can just make them as easy functions when we're moving forward So now we've got an iterator X and Y and we can just go ahead and say all right Let's print F. I'm gonna print out with the format specifier the character that we're looking at and Then a vertical bar so it looks like it's gonna build out like blocks or the squares for each individual Character that's in the grid so grid X and Y so we get the current character that we're looking at in the grid and that will happen as we're moving along but At least one of the dimensions, but as we finish the end of that dimension either X or Y then we can print the new line that Is going to be actually displaying the sides or the Kind of like the bars in the grid if that makes any sense Probably not. It's really weird to talk through this stuff So actually let's have that go just before so we have a bar at the very top and then for every line or every row We have another line going through So let's see if this looks good Let's run make no errors yet. How does our program look? Okay, cool. Just about perfect So I guess we don't need that new line just at the start because there's an extra space there and let's get one more hyphen to just build out the grid for us. Oh Got a compile. I can make clean and make and then we'll do it dot slash main Okay, cool. So now we've got a grid being generated and Spit out on the screen and now we can get started for our tic-tac-toe game. So cool. Thanks for watching guys Hope you're enjoying this simple start just jumping right back in to doing some C and C++ stuff. It's been a while I'm a little rusty. So maybe it'll suck. I'm not the best, you know Tell me what I'm doing wrong. Tell me what you could do better. Etc. Etc. But if you did like the video, please Press that like button Leave me a comment. Tell me what you think. Tell me what I could do better. Etc. Subscribe if you're feeling willing and hey if you're much if you want to do that and you know what? I'll see you in the next video