The default (even the latest) CodeBlocks installer will install GCC 4.8.1 toolchain (as of Feb 15 2016).
Hence, the following steps don't require you to upgrade/re-install CodeBlocks.
To compile your bot, you need GCC compiler version > 4.8.X
. CodeBlocks doesn't tie you down with a particular compiler and you can install and use a different compiler that works for you.
You can ignore the installation of
TDM GCC
if you already have a working installation ofGCC > 4.8.X
.
##Installing TDM-GCC
Install TDM-GCC
if you have GCC <= 4.8.X
.
Download it from here, choose the version for your machine: 32/64 bit.
- Make sure you are connected to internet, during the installation (it will download an Update manifest).
- Choose the option to Create a new
TDM-GCC
installation. - Choose MinGW 32/64 bit based installation.
- Install it at the default
C:\TDM-GCC-XX
directory.
##Setting up the TDM-GCC
Compiler in CodeBlocks
- Go to Settings option in the menu bar (top) and select compiler from the drop down.
- In Toolchain executables tab
- Change Compiler's installation Directory path to the folder where
TDM-GCC
is installed. - Under Program Files tab change the fields as shown in the image. Press the
...
button to browse. These executables are @C:\TDM-GCC-XX\bin\
.
- Change Compiler's installation Directory path to the folder where
- In Compiler settings tab
- Under Compiler Flags tab
- Untick
use std = c++11
, we'll be using thec++14
standard. - If you wish, enable all Compiler warnings
[-Wall]
option under warnings section.
- Untick
- Under Other Compilers tab type
-std=c++14
.
- Under Compiler Flags tab
- Save the settings.
##Opening a new project for mybot
- Go to File (in the menu bar) -> new -> project
- Select Empty project from the project template window.
- Set Project title to mybot.
- Choose the path to cpp-starter-pack-win* folder.
- Finish the project creation.
##Adding files to the project
- Right click on the project under Workspace section (left pane).
- Select Add files from the drop down.
- Select All files from the
mybot
folder.
- Select All files from the
- Edit project properties (right click on the project under the workspace section)
- Under Build Targets tab change the destination folder to
mybot\
(not the default)
The Game Engine will look for executeables in
mybot\
whereas default CodeBlocks behaviour is to save the executable inproj-folder\bin\Releases
. - Under Build Targets tab change the destination folder to
- Save the settings.
##Compiling mybot
- Edit bot_template.cpp as you wish (this is where your bot resides).
- Open bot_launcher.cpp file and build this file (
ctrl
F9
). This file links all the rquired headers andbot_template.cpp
. - Ignore all warnings regarding type casting. Most of them are not generated by
bot_template.cpp
. If this irritates you, untick the-Wall
flag from the Compiler Settings. - Check the build logs not the build messages, verify that the build was successful.
- The
.exe
should have been created inmybot\
(as per the settings we changed).
#Compiling other sample
Bots
Follow the same procedure, create projects for all the three sample bots. Here's a checklist that you can use to verify that you followed all the steps correctly:
- Open a new empty project, project name must be same as the folder-name, ie, it must end in
_launcher
.
For,
hard_coded
bot:
- folder-name
hard_coded_launcher
- project-name
hard_coded_launcher
- Add source and header files.
- Change the build target to
samples\
.
The game Engine looks for sample-bot-executables in
samples\
. By default the executeables go insamples\<proj-name>\bin\Releases
- Compile
<bot-name>_launcher.cpp
. - Verify that the
<bot-name>_launcher.exe
is now available insamples\
. - Do the above for all sample-bots.
#Run a Game
CodeBlocks is now completely setup for Battle of Bots. You can double-click on the launcher.bat
to run games now!
Good Luck!