Merged labs and exmaples binaries, normalized build output directories

This commit is contained in:
Nick Cano
2016-06-15 01:39:43 -07:00
parent 1f6f72e6e5
commit bd95b160af
37 changed files with 2069 additions and 233 deletions
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -18,13 +18,17 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -38,9 +38,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}</ProjectGuid>
<RootNamespace>Chapter1__01</RootNamespace>
<ProjectName>Chapter1_BasicMemory</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>allegro-5.0.10-monolith-md-debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)game.map" "$(OutDir)game.map" /y &amp;&amp; copy "$(SolutionDir)arial.ttf" "$(OutDir)arial.ttf" /y </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)game.map" "$(OutDir)game.map" /y &amp;&amp; copy "$(SolutionDir)arial.ttf" "$(OutDir)arial.ttf" /y </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="game-BasicMem.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-BasicMem.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{3c8b02c5-3b42-4b99-9dbc-d301f719fc1c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Hiles">
<UniqueIdentifier>{1c064fd6-e3d1-47a5-b1c0-ea67fd84ce18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-BasicMem.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="game-BasicMem.cpp">
<Filter>Source Hiles</Filter>
</ClCompile>
</ItemGroup>
</Project>
+50
View File
@@ -0,0 +1,50 @@
struct Location
{
int x;
int y;
Location(){}
Location(int x, int y)
{
this->x = x;
this->y = y;
}
const bool operator == (const Location &o)
{
return (o.x == this->x && o.y == this->y);
}
const bool operator != (const Location &o)
{
return !(*this == o);
}
const Location operator + (const Location &o)
{
return Location(this->x + o.x, this->y + o.y);
}
const Location operator - (const Location &o)
{
return Location(this->x - o.x, this->y - o.y);
}
const Location operator = (const Location &o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
const Location operator += (const Location &o)
{
this->x += o.x;
this->y += o.y;
return *this;
}
const Location operator -= (const Location &o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
};
+222
View File
@@ -0,0 +1,222 @@
#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <stdio.h>
#include "..\allegro_linkers.h"
#include "Location-BasicMem.h"
Location selfLocation(12, 16);
Location ballLocation(15, 13);
BYTE map[24][32];
int keys[255];
bool checkWin()
{
return (map[ballLocation.y][ballLocation.x] == 4);
}
void drawBackground()
{ for (int i = 0; i <= 24; i++)
{
for (int t = 0; t <= 32; t++)
{
if (map[i][t] == 1)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(128, 255, 255));
else if(map[i][t] == 2)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(255, 128, 0));
else if(map[i][t] == 3)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(255, 0, 0));
else if(map[i][t] == 4)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(0, 0, 0));
}
}
}
void drawObjects()
{
al_draw_filled_rectangle(selfLocation.x * 20, selfLocation.y * 20,
(selfLocation.x + 1) * 20, (selfLocation.y + 1) * 20,
al_map_rgb(255, 255, 255));
al_draw_filled_circle(ballLocation.x * 20 + 10, ballLocation.y * 20 + 10,
10, al_map_rgb(100, 100, 100));
}
void drawHUD(ALLEGRO_FONT *font)
{
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 10, 0, "Arrow Keys: Move");
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 25, 0, "Spacebar: Swap");
}
void keyboardEvent()
{
Location moveOffset;
if (keys[ALLEGRO_KEY_UP])
moveOffset = Location(0, -1);
else if (keys[ALLEGRO_KEY_DOWN])
moveOffset = Location(0, 1);
else if (keys[ALLEGRO_KEY_LEFT])
moveOffset = Location(-1, 0);
else if (keys[ALLEGRO_KEY_RIGHT])
moveOffset = Location(1, 0);
else if (keys[ALLEGRO_KEY_SPACE])
{
moveOffset = ballLocation - selfLocation;
if (abs(moveOffset.x) + abs(moveOffset.y) <= 1)
{
moveOffset = selfLocation; //placehold
selfLocation = ballLocation;
ballLocation = moveOffset;
}
return;
}
else
return;
Location newSelf = selfLocation + moveOffset;
Location newBall = ballLocation;
if (newSelf == newBall)
newBall += moveOffset;
if (map[newBall.y][newBall.x] == 1 || map[newSelf.y][newSelf.x] == 1)
return;
ballLocation = newBall;
selfLocation = newSelf;
}
int main(void)
{
char* error = "";
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_FONT *font = NULL;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
do
{
ZeroMemory(&keys, 255);
FILE* file = fopen("game.map", "rb");
if (!file)
{
error = "failed to initialize map!";
break;
}
else
{
fread(map, 1, 24*32, file);
fclose(file);
}
if(!al_init())
{
error = "failed to initialize allegro!";
break;
}
if(!al_init_primitives_addon())
{
error = "failed to initialize primitives!";
break;
}
al_init_font_addon();
if(!al_init_ttf_addon())
{
error = "failed to initialize ttfs!";
break;
}
if(!al_install_keyboard())
{
error = "failed to initialize keyboard!";
break;
}
if(!(font = al_load_ttf_font("arial.ttf", 18, 0)))
{
error = "failed to initialize font!";
break;
}
if(!(timer = al_create_timer(1.0 / 10)))
{
error = "failed to initialize timer!";
break;
}
if(!(display = al_create_display(640, 480)))
{
error = "failed to initialize display!";
break;
}
if(!(event_queue = al_create_event_queue()))
{
error = "failed to initialize event_queue!";
break;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_start_timer(timer);
while(1)
{
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
{
break;
}
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN)
{
if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
break;
else if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = true;
}
else if (ev.type == ALLEGRO_EVENT_KEY_UP)
{
if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = false;
}
else if (ev.type == ALLEGRO_EVENT_KEY_CHAR)
keyboardEvent();
if (al_is_event_queue_empty(event_queue))
{
al_clear_to_color(al_map_rgb(255, 255, 255));
drawBackground();
drawObjects();
if (checkWin())
{
al_draw_text(font, al_map_rgb(200, 200, 200), 320, 240, 1, "Good job! You've completed the first lab!");
al_flip_display();
continue;
}
drawHUD(font);
al_flip_display();
}
}
} while (0);
if (strlen(error) > 0)
{
al_show_native_message_box(NULL, NULL, "error", error, NULL, NULL);
return -1;
}
al_destroy_timer(timer);
al_destroy_display(display);
al_destroy_event_queue(event_queue);
return 0;
}
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}</ProjectGuid>
<RootNamespace>Chapter1__01</RootNamespace>
<ProjectName>Chapter1_MemoryPointers</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>allegro-5.0.10-monolith-md-debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)game.map" "$(OutDir)game.map" /y &amp;&amp; copy "$(SolutionDir)arial.ttf" "$(OutDir)arial.ttf" /y </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)game.map" "$(OutDir)game.map" /y &amp;&amp; copy "$(SolutionDir)arial.ttf" "$(OutDir)arial.ttf" /y </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="game-MemPointer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-MemPointer.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="game.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{3c8b02c5-3b42-4b99-9dbc-d301f719fc1c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Hiles">
<UniqueIdentifier>{1c064fd6-e3d1-47a5-b1c0-ea67fd84ce18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,93 @@
struct Location
{
int x;
int y;
Location(){}
Location(int x, int y)
{
this->x = x;
this->y = y;
}
const bool operator == (const Location &o)
{
return (o.x == this->x && o.y == this->y);
}
const bool operator != (const Location &o)
{
return !(*this == o);
}
const Location operator + (const Location &o)
{
return Location(this->x + o.x, this->y + o.y);
}
const Location operator - (const Location &o)
{
return Location(this->x - o.x, this->y - o.y);
}
const Location operator = (const Location &o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
const Location operator += (const Location &o)
{
this->x += o.x;
this->y += o.y;
return *this;
}
const Location operator -= (const Location &o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
};
class LocationPointerSimulator
{
public:
~LocationPointerSimulator()
{
delete this->step->step->location;
delete this->step->step;
delete this->step;
}
Location* getLocation()
{
return step->step->location;
}
static LocationPointerSimulator* NewLocationPointer(Location* loc)
{
LocationPointerSimulator* locationPointer1 = new LocationPointerSimulator();
LocationPointerSimulator2* locationPointer2 = new LocationPointerSimulator2();
LocationPointerSimulator3* locationPointer3 = new LocationPointerSimulator3();
locationPointer3->location = loc;
locationPointer1->step = locationPointer2;
locationPointer2->step = locationPointer3;
return locationPointer1;
}
private:
struct LocationPointerSimulator3
{
char placeholders[32];
Location* location;
};
struct LocationPointerSimulator2
{
char placeholders[64];
LocationPointerSimulator3* step;
};
char placeholders[128];
LocationPointerSimulator2* step;
};
+268
View File
@@ -0,0 +1,268 @@
#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <stdio.h>
#include "..\allegro_linkers.h"
#include "Location-MemPointer.h"
bool testRunning = false;
int testState = 0;
int testTime = 0;
Location selfLocation(12, 16);
LocationPointerSimulator* ballLocation = LocationPointerSimulator::NewLocationPointer(new Location(15, 13));
BYTE map[24][32];
int keys[255];
bool checkWin()
{
Location* blocation = ballLocation->getLocation();
return (map[blocation->y][blocation->x] == 4);
}
void drawBackground()
{ for (int i = 0; i <= 24; i++)
{
for (int t = 0; t <= 32; t++)
{
if (map[i][t] == 1)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(128, 255, 255));
else if(map[i][t] == 2)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(255, 128, 0));
else if(map[i][t] == 3)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(255, 0, 0));
else if(map[i][t] == 4)
al_draw_filled_rectangle(t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, al_map_rgb(0, 0, 0));
}
}
}
void drawObjects()
{
Location* blocation = ballLocation->getLocation();
al_draw_filled_rectangle(selfLocation.x * 20, selfLocation.y * 20,
(selfLocation.x + 1) * 20, (selfLocation.y + 1) * 20,
al_map_rgb(255, 255, 255));
al_draw_filled_circle(blocation->x * 20 + 10, blocation->y * 20 + 10,
10, al_map_rgb(100, 100, 100));
}
void drawHUD(ALLEGRO_FONT *font)
{
if (!testRunning)
{
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 10, 0, "Arrow Keys: Move");
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 25, 0, "Spacebar: Swap");
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 40, 0, "Tab: Begin Test");
}
else
{
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 10, 0, "Automated test running, input disabled.");
char text[128];
sprintf(text, "Wins: %d/10", testState);
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 25, 0, text);
sprintf(text, "Time: %1.1fs", testTime / 1000.00);
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 40, 0, text);
}
}
void keyboardEvent()
{
if (testRunning)
return;
Location* blocation = ballLocation->getLocation();
Location moveOffset;
if (keys[ALLEGRO_KEY_UP])
moveOffset = Location(0, -1);
else if (keys[ALLEGRO_KEY_DOWN])
moveOffset = Location(0, 1);
else if (keys[ALLEGRO_KEY_LEFT])
moveOffset = Location(-1, 0);
else if (keys[ALLEGRO_KEY_RIGHT])
moveOffset = Location(1, 0);
else if (keys[ALLEGRO_KEY_TAB])
{
testRunning = true;
return;
}
else if (keys[ALLEGRO_KEY_SPACE])
{
moveOffset = Location(blocation->x, blocation->y) - selfLocation;
if (abs(moveOffset.x) + abs(moveOffset.y) <= 1)
{
moveOffset = selfLocation; //placehold
selfLocation.x = blocation->x;
selfLocation.y = blocation->y;
blocation->x = moveOffset.x;
blocation->y = moveOffset.y;
}
return;
}
else
return;
Location newSelf = selfLocation + moveOffset;
Location newBall = Location(blocation->x, blocation->y);
if (newSelf == newBall)
newBall += moveOffset;
if (map[newBall.y][newBall.x] == 1 || map[newSelf.y][newSelf.x] == 1)
return;
blocation->x = newBall.x;
blocation->y = newBall.y;
selfLocation = newSelf;
}
int main(void)
{
char* error = "";
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_FONT *font = NULL;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
do
{
ZeroMemory(&keys, 255);
FILE* file = fopen("game.map", "rb");
if (!file)
{
error = "failed to initialize map!";
break;
}
else
{
fread(map, 1, 24*32, file);
fclose(file);
}
if(!al_init())
{
error = "failed to initialize allegro!";
break;
}
if(!al_init_primitives_addon())
{
error = "failed to initialize primitives!";
break;
}
al_init_font_addon();
if(!al_init_ttf_addon())
{
error = "failed to initialize ttfs!";
break;
}
if(!al_install_keyboard())
{
error = "failed to initialize keyboard!";
break;
}
if(!(font = al_load_ttf_font("arial.ttf", 18, 0)))
{
error = "failed to initialize font!";
break;
}
if(!(timer = al_create_timer(1.0 / 10)))
{
error = "failed to initialize timer!";
break;
}
if(!(display = al_create_display(640, 480)))
{
error = "failed to initialize display!";
break;
}
if(!(event_queue = al_create_event_queue()))
{
error = "failed to initialize event_queue!";
break;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_start_timer(timer);
while(1)
{
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
{
break;
}
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN)
{
if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
break;
else if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = true;
}
else if (ev.type == ALLEGRO_EVENT_KEY_UP)
{
if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = false;
}
else if (ev.type == ALLEGRO_EVENT_KEY_CHAR)
keyboardEvent();
if (testRunning)
testTime += 100;
if (al_is_event_queue_empty(event_queue))
{
bool won = checkWin();
al_clear_to_color(al_map_rgb(255, 255, 255));
drawBackground();
drawObjects();
if (won && testRunning && testState < 50)
{
testState++;
auto clean = ballLocation;
ballLocation = LocationPointerSimulator::NewLocationPointer(new Location(15 + (testState % 4), 13 + (testState % 2)));
delete clean;
}
else if (testRunning && testState >= 50)
{
al_draw_text(font, al_map_rgb(200, 200, 200), 320, 240, 1, "Good job! You've completed the lab!");
al_flip_display();
continue;
}
else if (testRunning && testTime >= 11000)
{
al_draw_text(font, al_map_rgb(200, 200, 200), 320, 240, 1, "Lab failed! Ball must be moved to the winning spot 50 times in 10 seconds!");
al_flip_display();
continue;
}
drawHUD(font);
al_flip_display();
}
}
} while (0);
if (strlen(error) > 0)
{
al_show_native_message_box(NULL, NULL, "error", error, NULL, NULL);
return -1;
}
al_destroy_timer(timer);
al_destroy_display(display);
al_destroy_event_queue(event_queue);
return 0;
}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="game.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{3c8b02c5-3b42-4b99-9dbc-d301f719fc1c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Hiles">
<UniqueIdentifier>{1c064fd6-e3d1-47a5-b1c0-ea67fd84ce18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DEDDE9C4-3230-433C-B829-BE8981E645C9}</ProjectGuid>
<RootNamespace>Chapter1__01</RootNamespace>
<ProjectName>Chapter2_BasicDebugging</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>allegro-5.0.10-monolith-md-debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="game-BasicDebugging.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-BasicDebugging.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,50 @@
struct Location
{
int x;
int y;
Location(){}
Location(int x, int y)
{
this->x = x;
this->y = y;
}
const bool operator == (const Location &o)
{
return (o.x == this->x && o.y == this->y);
}
const bool operator != (const Location &o)
{
return !(*this == o);
}
const Location operator + (const Location &o)
{
return Location(this->x + o.x, this->y + o.y);
}
const Location operator - (const Location &o)
{
return Location(this->x - o.x, this->y - o.y);
}
const Location operator = (const Location &o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
const Location operator += (const Location &o)
{
this->x += o.x;
this->y += o.y;
return *this;
}
const Location operator -= (const Location &o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
};
@@ -0,0 +1,119 @@
#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <stdio.h>
#include "..\allegro_linkers.h"
#include "Location-BasicDebugging.h"
Location ballLocation(10, 20);
Location ballIncrement(6, 3);
void drawFrame(ALLEGRO_FONT *font)
{
ballLocation.x += ballIncrement.x;
ballLocation.y += ballIncrement.y;
if (ballLocation.x > 630 || ballLocation.x < 10)
ballIncrement.x = ballIncrement.x * -1;
if (ballLocation.y > 470 || ballLocation.y < 10)
ballIncrement.y = ballIncrement.y * -1;
al_clear_to_color(al_map_rgb(128, 128, 255));
al_draw_filled_rectangle(320, 0, 321, 480, al_map_rgb(166, 166, 166));
if (ballLocation.x >= 320)
{
al_draw_filled_rectangle(ballLocation.x-1, 0, ballLocation.x+1, 480, al_map_rgb(196, 196, 196));
al_draw_text(font, al_map_rgb(50, 50, 50), 10, 10, 0, "Ball hidden..");
}
else
al_draw_filled_circle(ballLocation.x, ballLocation.y, 10, al_map_rgb(100, 100, 100));
al_flip_display();
}
int main(void)
{
char* error = "";
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_FONT *font = NULL;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
do
{
if(!al_init())
{
error = "failed to initialize allegro!";
break;
}
if(!al_init_primitives_addon())
{
error = "failed to initialize primitives!";
break;
}
al_init_font_addon();
if(!al_init_ttf_addon())
{
error = "failed to initialize ttfs!";
break;
}
if(!(font = al_load_ttf_font("arial.ttf", 18, 0)))
{
error = "failed to initialize font!";
break;
}
if(!(timer = al_create_timer(1.0 / 20)))
{
error = "failed to initialize timer!";
break;
}
if(!(display = al_create_display(640, 480)))
{
error = "failed to initialize display!";
break;
}
if(!(event_queue = al_create_event_queue()))
{
error = "failed to initialize event_queue!";
break;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_start_timer(timer);
while(1)
{
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
break;
if (al_is_event_queue_empty(event_queue))
drawFrame(font);
}
} while (0);
if (strlen(error) > 0)
{
al_show_native_message_box(NULL, NULL, "error", error, NULL, NULL);
return -1;
}
al_destroy_timer(timer);
al_destroy_display(display);
al_destroy_event_queue(event_queue);
return 0;
}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="game.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{3c8b02c5-3b42-4b99-9dbc-d301f719fc1c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Hiles">
<UniqueIdentifier>{1c064fd6-e3d1-47a5-b1c0-ea67fd84ce18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B7A15C0B-6532-432F-864B-5381256B4D58}</ProjectGuid>
<RootNamespace>Chapter1__01</RootNamespace>
<ProjectName>Chapter3_CloseMutex</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>allegro-5.0.10-monolith-md-debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="game-CloseMutex.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-CloseMutex.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+50
View File
@@ -0,0 +1,50 @@
struct Location
{
int x;
int y;
Location(){}
Location(int x, int y)
{
this->x = x;
this->y = y;
}
const bool operator == (const Location &o)
{
return (o.x == this->x && o.y == this->y);
}
const bool operator != (const Location &o)
{
return !(*this == o);
}
const Location operator + (const Location &o)
{
return Location(this->x + o.x, this->y + o.y);
}
const Location operator - (const Location &o)
{
return Location(this->x - o.x, this->y - o.y);
}
const Location operator = (const Location &o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
const Location operator += (const Location &o)
{
this->x += o.x;
this->y += o.y;
return *this;
}
const Location operator -= (const Location &o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
};
+257
View File
@@ -0,0 +1,257 @@
#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <stdio.h>
#include "..\allegro_linkers.h"
#include "Location-CloseMutex.h"
Location ballLocation(30, 20);
Location ballIncrement(6, 3);
Location playerPaddle(0, 235);
Location computerPaddle(0, 235);
int keys[255];
int score = 0;
int highscore = 0;
bool gameRunning = true;
void getHighscorePath(wchar_t* path)
{
wchar_t temp[MAX_PATH];
GetTempPathW(MAX_PATH, &temp[0]);
wsprintfW(path, L"%s\\gh_hs_p.dat", temp);
}
void loadHighscore()
{
wchar_t path[MAX_PATH+40];
getHighscorePath(path);
FILE* file = _wfopen(path, L"rb");
if (file)
{
fread(&highscore, 1, 4, file);
fclose(file);
}
}
void saveHighscore()
{
wchar_t path[MAX_PATH+40];
getHighscorePath(path);
FILE* file = _wfopen(path, L"wb");
if (file)
{
fwrite(&highscore, 1, 4, file);
fclose(file);
}
}
void drawFrame(ALLEGRO_FONT *font)
{
if (gameRunning)
{
ballLocation.x += ballIncrement.x;
ballLocation.y += ballIncrement.y;
if (ballLocation.y > 470 || ballLocation.y < 10)
ballIncrement.y = ballIncrement.y * -1;
if (ballLocation.x > 625)
ballIncrement.x = ballIncrement.x * -1;
if (ballLocation.x < 16 && ballIncrement.x < 0)
{
ballLocation.x = 16;
if (ballLocation.y >= playerPaddle.y - 35 && ballLocation.y <= playerPaddle.y + 35)
{
score += 10;
if (score > highscore)
highscore = score;
if (score % 50 == 0)
{
ballIncrement.x *= 1.5;
ballIncrement.y *= 1.5;
}
ballIncrement.x = ballIncrement.x * -1;
}
else
gameRunning = false;
}
}
if (ballIncrement.x > 0)
{
if (computerPaddle.y < ballLocation.y && ballLocation.y - computerPaddle.y > 4)
computerPaddle.y += 8;
else if (computerPaddle.y > ballLocation.y && computerPaddle.y - ballLocation.y > 4)
computerPaddle.y -= 8;
if (computerPaddle.y < 35)
computerPaddle.y = 35;
else if (computerPaddle.y > 445)
computerPaddle.y = 445;
}
al_clear_to_color(al_map_rgb(128, 128, 255));
al_draw_filled_circle(ballLocation.x, ballLocation.y, 10, al_map_rgb(100, 100, 100));
al_draw_filled_rectangle(0, playerPaddle.y - 35, 5, playerPaddle.y + 35, al_map_rgb(196, 196, 196));
al_draw_filled_rectangle(635, computerPaddle.y - 35, 640, computerPaddle.y + 35, al_map_rgb(196, 196, 196));
if (!gameRunning)
al_draw_text(font, al_map_rgb(200, 200, 200), 320, 240, 1, "Game over!");
else
{
char scoretext[1024];
sprintf(scoretext, "Score: %d", score);
al_draw_text(font, al_map_rgb(200, 200, 200), 300, 3, 0, scoretext);
sprintf(scoretext, "High Score: %d", highscore);
al_draw_text(font, al_map_rgb(200, 200, 200), 300, 22, 0, scoretext);
}
al_flip_display();
}
void keyboardEvent()
{
if (!gameRunning)
return;
Location moveOffset;
if (keys[ALLEGRO_KEY_UP])
moveOffset = Location(0, -8);
else if (keys[ALLEGRO_KEY_DOWN])
moveOffset = Location(0, 8);
else
return;
Location newPaddle = playerPaddle + moveOffset;
if (newPaddle.y < 35)
newPaddle.y = 35;
else if (newPaddle.y > 445)
newPaddle.y = 445;
playerPaddle = newPaddle;
}
int main(void)
{
char* error = "";
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_FONT *font = NULL;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
HANDLE mutex = CreateMutex(NULL, FALSE, "Chapter3_CloseMutex-Mutex");
if (GetLastError() == ERROR_ALREADY_EXISTS) {
MessageBoxA(GetForegroundWindow(), "Only one instance of the game can run at a time.", "Chapter3_CloseMutex", MB_OK);
return 0;
}
do
{
loadHighscore();
if(!al_init())
{
error = "failed to initialize allegro!";
break;
}
if(!al_init_primitives_addon())
{
error = "failed to initialize primitives!";
break;
}
al_init_font_addon();
if(!al_init_ttf_addon())
{
error = "failed to initialize ttfs!";
break;
}
if(!al_install_keyboard())
{
error = "failed to initialize keyboard!";
break;
}
if(!(font = al_load_ttf_font("arial.ttf", 18, 0)))
{
error = "failed to initialize font!";
break;
}
if(!(timer = al_create_timer(1.0 / 20)))
{
error = "failed to initialize timer!";
break;
}
if(!(display = al_create_display(640, 480)))
{
error = "failed to initialize display!";
break;
}
if(!(event_queue = al_create_event_queue()))
{
error = "failed to initialize event_queue!";
break;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_start_timer(timer);
while(1)
{
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
break;
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN)
{
if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
break;
else if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = true;
}
else if (ev.type == ALLEGRO_EVENT_KEY_UP)
{
if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = false;
}
else if (ev.type == ALLEGRO_EVENT_KEY_CHAR)
keyboardEvent();
if (al_is_event_queue_empty(event_queue) && ev.type == ALLEGRO_EVENT_TIMER)
drawFrame(font);
}
} while (0);
if (mutex)
CloseHandle(mutex);
if (strlen(error) > 0)
{
al_show_native_message_box(NULL, NULL, "error", error, NULL, NULL);
return -1;
}
al_destroy_timer(timer);
al_destroy_display(display);
al_destroy_event_queue(event_queue);
saveHighscore();
return 0;
}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="game.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{3c8b02c5-3b42-4b99-9dbc-d301f719fc1c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Hiles">
<UniqueIdentifier>{1c064fd6-e3d1-47a5-b1c0-ea67fd84ce18}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4188B6F0-3948-4CB8-90C6-038CED132E11}</ProjectGuid>
<RootNamespace>Chapter1__01</RootNamespace>
<ProjectName>Chapter3_FindingFiles</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)BuildTemp\$(ProjectName)$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>allegro-5.0.10-monolith-md-debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="game-FindingFiles.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Location-FindingFiles.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,50 @@
struct Location
{
int x;
int y;
Location(){}
Location(int x, int y)
{
this->x = x;
this->y = y;
}
const bool operator == (const Location &o)
{
return (o.x == this->x && o.y == this->y);
}
const bool operator != (const Location &o)
{
return !(*this == o);
}
const Location operator + (const Location &o)
{
return Location(this->x + o.x, this->y + o.y);
}
const Location operator - (const Location &o)
{
return Location(this->x - o.x, this->y - o.y);
}
const Location operator = (const Location &o)
{
this->x = o.x;
this->y = o.y;
return *this;
}
const Location operator += (const Location &o)
{
this->x += o.x;
this->y += o.y;
return *this;
}
const Location operator -= (const Location &o)
{
this->x -= o.x;
this->y -= o.y;
return *this;
}
};
+247
View File
@@ -0,0 +1,247 @@
#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <stdio.h>
#include "..\allegro_linkers.h"
#include "Location-FindingFiles.h"
Location ballLocation(30, 20);
Location ballIncrement(6, 3);
Location playerPaddle(0, 235);
Location computerPaddle(0, 235);
int keys[255];
int score = 0;
int highscore = 0;
bool gameRunning = true;
void getHighscorePath(wchar_t* path)
{
wchar_t temp[MAX_PATH];
GetTempPathW(MAX_PATH, &temp[0]);
wsprintfW(path, L"%s\\gh_hs_p.dat", temp);
}
void loadHighscore()
{
wchar_t path[MAX_PATH+40];
getHighscorePath(path);
FILE* file = _wfopen(path, L"rb");
if (file)
{
fread(&highscore, 1, 4, file);
fclose(file);
}
}
void saveHighscore()
{
wchar_t path[MAX_PATH+40];
getHighscorePath(path);
FILE* file = _wfopen(path, L"wb");
if (file)
{
fwrite(&highscore, 1, 4, file);
fclose(file);
}
}
void drawFrame(ALLEGRO_FONT *font)
{
if (gameRunning)
{
ballLocation.x += ballIncrement.x;
ballLocation.y += ballIncrement.y;
if (ballLocation.y > 470 || ballLocation.y < 10)
ballIncrement.y = ballIncrement.y * -1;
if (ballLocation.x > 625)
ballIncrement.x = ballIncrement.x * -1;
if (ballLocation.x < 16 && ballIncrement.x < 0)
{
ballLocation.x = 16;
if (ballLocation.y >= playerPaddle.y - 35 && ballLocation.y <= playerPaddle.y + 35)
{
score += 10;
if (score > highscore)
highscore = score;
if (score % 50 == 0)
{
ballIncrement.x *= 1.5;
ballIncrement.y *= 1.5;
}
ballIncrement.x = ballIncrement.x * -1;
}
else
gameRunning = false;
}
}
if (ballIncrement.x > 0)
{
if (computerPaddle.y < ballLocation.y && ballLocation.y - computerPaddle.y > 4)
computerPaddle.y += 8;
else if (computerPaddle.y > ballLocation.y && computerPaddle.y - ballLocation.y > 4)
computerPaddle.y -= 8;
if (computerPaddle.y < 35)
computerPaddle.y = 35;
else if (computerPaddle.y > 445)
computerPaddle.y = 445;
}
al_clear_to_color(al_map_rgb(128, 128, 255));
al_draw_filled_circle(ballLocation.x, ballLocation.y, 10, al_map_rgb(100, 100, 100));
al_draw_filled_rectangle(0, playerPaddle.y - 35, 5, playerPaddle.y + 35, al_map_rgb(196, 196, 196));
al_draw_filled_rectangle(635, computerPaddle.y - 35, 640, computerPaddle.y + 35, al_map_rgb(196, 196, 196));
if (!gameRunning)
al_draw_text(font, al_map_rgb(200, 200, 200), 320, 240, 1, "Game over!");
else
{
char scoretext[1024];
sprintf(scoretext, "Score: %d", score);
al_draw_text(font, al_map_rgb(200, 200, 200), 300, 3, 0, scoretext);
sprintf(scoretext, "High Score: %d", highscore);
al_draw_text(font, al_map_rgb(200, 200, 200), 300, 22, 0, scoretext);
}
al_flip_display();
}
void keyboardEvent()
{
if (!gameRunning)
return;
Location moveOffset;
if (keys[ALLEGRO_KEY_UP])
moveOffset = Location(0, -8);
else if (keys[ALLEGRO_KEY_DOWN])
moveOffset = Location(0, 8);
else
return;
Location newPaddle = playerPaddle + moveOffset;
if (newPaddle.y < 35)
newPaddle.y = 35;
else if (newPaddle.y > 445)
newPaddle.y = 445;
playerPaddle = newPaddle;
}
int main(void)
{
char* error = "";
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_FONT *font = NULL;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
do
{
loadHighscore();
if(!al_init())
{
error = "failed to initialize allegro!";
break;
}
if(!al_init_primitives_addon())
{
error = "failed to initialize primitives!";
break;
}
al_init_font_addon();
if(!al_init_ttf_addon())
{
error = "failed to initialize ttfs!";
break;
}
if(!al_install_keyboard())
{
error = "failed to initialize keyboard!";
break;
}
if(!(font = al_load_ttf_font("arial.ttf", 18, 0)))
{
error = "failed to initialize font!";
break;
}
if(!(timer = al_create_timer(1.0 / 20)))
{
error = "failed to initialize timer!";
break;
}
if(!(display = al_create_display(640, 480)))
{
error = "failed to initialize display!";
break;
}
if(!(event_queue = al_create_event_queue()))
{
error = "failed to initialize event_queue!";
break;
}
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
al_start_timer(timer);
while(1)
{
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
break;
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN)
{
if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
break;
else if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = true;
}
else if (ev.type == ALLEGRO_EVENT_KEY_UP)
{
if (ev.keyboard.keycode <= 255)
keys[ev.keyboard.keycode] = false;
}
else if (ev.type == ALLEGRO_EVENT_KEY_CHAR)
keyboardEvent();
if (al_is_event_queue_empty(event_queue) && ev.type == ALLEGRO_EVENT_TIMER)
drawFrame(font);
}
} while (0);
if (strlen(error) > 0)
{
al_show_native_message_box(NULL, NULL, "error", error, NULL, NULL);
return -1;
}
al_destroy_timer(timer);
al_destroy_display(display);
al_destroy_event_queue(event_queue);
saveHighscore();
return 0;
}
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -39,11 +39,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -42,11 +42,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
+3 -1
View File
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -40,11 +40,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -38,9 +38,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -1,216 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Direct3D Hook"
ProjectGUID="{784C482A-F6EC-4BCB-851E-07BE782BB040}"
RootNamespace="Direct3DHook"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies=""
OutputFile="$(OutDir)\Chapter8_Direct3DHook.dll"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
SubSystem="2"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories=";&quot;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies=""
OutputFile="$(OutDir)\Chapter8_Direct3DHook.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\CDirectX.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\CDirectX.h"
>
</File>
<File
RelativePath=".\main.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -38,10 +38,10 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\BuildTemp\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\bin\DEBUG_BUILDS\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\BuildTemp\$(ProjectName)_$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<ExecutablePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ExecutablePath)</ExecutablePath>
@@ -50,8 +50,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Microsoft Research\ms detours 1.5 src\src;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LOLORACLEHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -76,8 +76,8 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Microsoft Research\ms detours 1.5 src\src;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LOLORACLEHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
+39
View File
@@ -25,6 +25,25 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter11_StateMachines", "
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter11_SearchAlgorithms", "Chapter11_SearchAlgorithms\Chapter11_SearchAlgorithms.vcxproj", "{35470A34-CBB0-41D1-A54B-E1CF3DE9A3B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{454BEDF4-C177-4DB3-85D1-20813E9EBDCC}"
ProjectSection(SolutionItems) = preProject
LuaScripts\Chapter1_SearchingForAssemblyPatterns.lua = LuaScripts\Chapter1_SearchingForAssemblyPatterns.lua
LuaScripts\Chapter1_SearchingForStrings.lua = LuaScripts\Chapter1_SearchingForStrings.lua
LuaScripts\Chapter5_CountLinkedListNodes.lua = LuaScripts\Chapter5_CountLinkedListNodes.lua
LuaScripts\Chapter5_VerifyLinkedList.lua = LuaScripts\Chapter5_VerifyLinkedList.lua
LuaScripts\Chapter5_VerifyMap.lua = LuaScripts\Chapter5_VerifyMap.lua
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter1_BasicMemory", "Chapter1_BasicMemory\Chapter1_BasicMemory.vcxproj", "{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter1_MemoryPointers", "Chapter1_MemoryPointers\Chapter1_MemoryPointers.vcxproj", "{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter2_BasicDebugging", "Chapter2_BasicDebugging\Chapter2_BasicDebugging.vcxproj", "{DEDDE9C4-3230-433C-B829-BE8981E645C9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter3_FindingFiles", "Chapter3_FindingFiles\Chapter3_FindingFiles.vcxproj", "{4188B6F0-3948-4CB8-90C6-038CED132E11}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chapter3_CloseMutex", "Chapter3_CloseMutex\Chapter3_CloseMutex.vcxproj", "{B7A15C0B-6532-432F-864B-5381256B4D58}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -79,6 +98,26 @@ Global
{35470A34-CBB0-41D1-A54B-E1CF3DE9A3B7}.Debug|Win32.Build.0 = Debug|Win32
{35470A34-CBB0-41D1-A54B-E1CF3DE9A3B7}.Release|Win32.ActiveCfg = Release|Win32
{35470A34-CBB0-41D1-A54B-E1CF3DE9A3B7}.Release|Win32.Build.0 = Release|Win32
{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}.Debug|Win32.ActiveCfg = Debug|Win32
{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}.Debug|Win32.Build.0 = Debug|Win32
{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}.Release|Win32.ActiveCfg = Release|Win32
{AB736FAE-3FEF-40C0-B426-BFC3E3FA569F}.Release|Win32.Build.0 = Release|Win32
{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}.Debug|Win32.ActiveCfg = Debug|Win32
{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}.Debug|Win32.Build.0 = Debug|Win32
{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}.Release|Win32.ActiveCfg = Release|Win32
{3DEAB7C6-98B4-43F0-8F71-001EB28CAE84}.Release|Win32.Build.0 = Release|Win32
{DEDDE9C4-3230-433C-B829-BE8981E645C9}.Debug|Win32.ActiveCfg = Debug|Win32
{DEDDE9C4-3230-433C-B829-BE8981E645C9}.Debug|Win32.Build.0 = Debug|Win32
{DEDDE9C4-3230-433C-B829-BE8981E645C9}.Release|Win32.ActiveCfg = Release|Win32
{DEDDE9C4-3230-433C-B829-BE8981E645C9}.Release|Win32.Build.0 = Release|Win32
{4188B6F0-3948-4CB8-90C6-038CED132E11}.Debug|Win32.ActiveCfg = Debug|Win32
{4188B6F0-3948-4CB8-90C6-038CED132E11}.Debug|Win32.Build.0 = Debug|Win32
{4188B6F0-3948-4CB8-90C6-038CED132E11}.Release|Win32.ActiveCfg = Release|Win32
{4188B6F0-3948-4CB8-90C6-038CED132E11}.Release|Win32.Build.0 = Release|Win32
{B7A15C0B-6532-432F-864B-5381256B4D58}.Debug|Win32.ActiveCfg = Debug|Win32
{B7A15C0B-6532-432F-864B-5381256B4D58}.Debug|Win32.Build.0 = Debug|Win32
{B7A15C0B-6532-432F-864B-5381256B4D58}.Release|Win32.ActiveCfg = Release|Win32
{B7A15C0B-6532-432F-864B-5381256B4D58}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+23
View File
@@ -0,0 +1,23 @@
#pragma comment(lib, "allegro-5.0.10-static-md.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "winmm.LIB")
#pragma comment(lib, "shlwapi.lib")
#pragma comment(lib, "psapi.lib")
#ifdef _ALLEGRO_FONT_DLL
#include <allegro5/allegro_ttf.h>
#pragma comment(lib, "freetype-2.4.8-static-md.lib")
#pragma comment(lib, "allegro_font-5.0.10-static-md.lib")
#pragma comment(lib, "allegro_ttf-5.0.10-static-md.lib")
#endif
#ifdef _ALLEGRO_DIALOG_DLL
#pragma comment(lib, "allegro_dialog-5.0.10-static-md.lib")
#endif
#ifdef _ALLEGRO_PRIM_DLL
#pragma comment(lib, "allegro_primitives-5.0.10-static-md.lib")
#endif
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@