This guide explains the process involved in creating projects when using Tier 2 on the Microsoft Windows platform. It will primarily deal with Visual Studio 2008 but the steps for VS2010 and VS2013 should be similar.
What you need
You will need the following files and packages. The total download size for Visual Studio can be several gigabytes, and varies greatly between versions.
Microsoft Visual C++ 2008, 2010, or 2013 (available from here)
Microsoft Windows SDK 7.1 (available from here) (7.1 is the last release to target XP)
Windows XP / Vista / Windows 7 / Windows 8 / Windows 8.1
Preparation: AGK Files
The following steps will show you how to set up the necessary files for the project.
NOTE: This section is only necessary if you can't write to Program Files (x86). If you have admin rights or otherwise have write access to Program Files (x86), you can skip straight to Creating a New Game Project.
Open AGK2. If you've launched it previously, click on Tools > Install Additional Files. If you haven't previously launched AGK2, the dialogue should open automatically.
In the C++ Libraries box, type or browse for a folder where you have write access (eg. C:\Users\[Name]\Documents\AGKLibs\) and click Install. Close AGK.
NOTE: If you want to manually link the include files and libraries, they can be found at these locations:
Include Files:
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\common\include\
Libraries (VS 2008)
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\Debug\
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\Release\
Libraries (VS 2010)
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\VS2010\Debug\
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\VS2010\Release\
Libraries (VS 2013)
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\VS2013\Debug\
C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\platform\windows\Lib\VS2013\Release\
Creating a New Game Project
The following steps will show you how to set up a new project. Once you've completed all the Preparation sections of this guide, this is where you should start from each time you want to make a new project.
NOTE: If you completed the Prepatation: AGK Files section, the apps\ folder will be found in whichever folder you decided to use. Otherwise, it will be found in C:\Program Files (x86)\The Game Creators\AGK2\Tier 2\
Navigate to apps\ and make a copy of the template_windows or template_windows_vs2010 folder, depending on which version of Visual Studio you have. This will be your new project folder, and you can rename it as you wish. In this example I've created one called Really Cool Program.
Modifying Your Game
The following steps will show you how to make to modifications to your code, recompile and run your project.
You can now open the project by double-clicking on Template.sln in your project's folder. This should launch Visual Studio.
In the Solution Explorer on the left-hand side, you should see template.h and template.cpp - these are you main two source code files. For now, double-click template.cpp to open it for editing.
NOTE: As you can see, the code is very simply broken into three functions:
Begin: This is where you can place your inital setup code.
Loop: This is where you can place your main game logic.
End: This is where you can place resource clean-up code.
Just before the Sync command, add a Print command and save the file. I used the following:
agk::Print( "Hello! I'm speaking to you from inside AGK-land!" );
agk::Print( "Hello! I'm speaking to you from inside AGK-land!" );
Click on Build > Build Solution (or just press F7) to compile the project.
If you get errors saying something about HTOUCHINPUT, you need to link the Windows SDK:
Click on Project > Template Properties, then on the left-hand side, open Configuration Properties > C/C++ > General. Click on Additional Include Directories, then click the small ellipsis (three-dots) button that appears
In the dialogue that appears, add a new folder: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Include\ (or wherever you installed the Windows SDK). Click OK.
Now open Configuration Properties > Linker > General and click on Additional Library Directories, then click the small ellipsis button.
Add a new folder: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Lib\. Click OK, and then OK again. Now try recompiling (press F7).
If you get errors saying something about cannot open include file 'afxres.h', you're probably using an Express version of Visual Studio, which doesn't include the MFC libraries. To fix:
Double-click the error to open its location in the source code. This should open template.rc.
Change the line #include "afxres.h" to #include "windows.h" and save the file.
Now try recompiling (press F7).
Click on Debug > Start Debugging (or just press F5) to run your project!