| Programming Tutorial - Part 2 |
Getting the tools together To get started there’s really only one thing you’ll need. Go to http://www.microsoft.com/Express/Download and get “Microsoft Visual C++ 2008 Express Edition” (the yellowy/orange one). Download the installer (“>> Download”), run it, and set it up. I’d suggest you want to do the following: - Read & accept the license terms, but don’t let them download RSS feeds. - On the next page uncheck Silverlight and Microsoft SQL Server 2008 – they’re not necessary. - Use the default directory and then Install Away! - Make a cup of tea! All ready?Then let’s begin! Start by running “Microsoft Visual C++ 2008 Express Edition” from the start menu. This is your IDE (Integrated Development Environment) where all the fun happens. The main window has 3 parts – a solution explorer, a main window (probably with a Start Page in it), and a “Code Definition Window” or similar at the bottom. A “solution” is a collection of projects (remember a Project is a collection of source files). We’ll only have one project in any one solution, so they really mean the same thing for us. Visual Studio can make quite a number of different projects with different amounts of initial help. We’re going to start Hard Core with a totally empty project. First select New->Project… from the menu at the top left. You should have the New Project dialog with a few different Project Types to choose from. We’re going to make a very simple console application, so choose the Win32 Project Type from the list on the left. Now we choose the type of project. Let’s go for Win32 Console Application on the right and enter a name in the “Name:” box. Mine is called “Bigones”. The Location doesn’t really matter for now, so click OK. It should now say “Welcome to the Win32 Application Wizard”. Does it? Good! You need to go to the Application Settings and check that we have a Console application selected. Also check the “Empty project” button, then Finish. Hopefully at this point the Solution Explorer at the left has sprung into life, showing you the contents of your new solution! It should contain 1 project (Bigones) with 3 empty “folders” of files in it – Headers, Resources and Source. Close the Start window (X at top right) and you’re all ready to rock! First steps First we need a Source file to put code into. Right click on “Source files” and select “Add -> New Item…”. On the left select “Code” and then “C++ File” on the right. You can call the file anything you want at the bottom, but mine will be “Main.cpp”. The .cpp is important, but if you don’t add it then Visual Studio will pop it on for you. Now you should have an empty text file on the right and “Main.cpp” in the Source Files view on the left. All OK? Let’s Code! Type: int main(){// Make a game. Give it good graphics. And great sound. return 0; } Into Main.cpp and hit F7 (Shortcut for Build/Build Solution). Hopefully the window at the bottom will change to the Output window and you’ll get some Stuff printed, including: 1>Compiling... 1>Main.cpp 1>Linking... 1>Bigones - 0 error(s), 0 warning(s)Here we can see the main parts of the compilation process. Visual Studio compiles all the files in the project one after the other (here only one file). Then it Links them all together. Finally it tells us that everything is Fine – we’ve made an Executable! As you may have guessed, this executable makes a great game! No, actually, it doesn't really do anything at all, but if you get this far then you're all set to Program Properly in the next part! |
| Last Updated on Friday, 22 August 2008 10:11 |









