Skip to content

Commit a2b56db

Browse files
author
James M. Hasbrouck
committed
Folder containing source code and executable
1 parent be32282 commit a2b56db

38 files changed

+1159
-0
lines changed

Game Of Life/Button.cpp

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#include "Button.h"
2+
#include "SDL.h"
3+
4+
Button::Button(int width, int height)
5+
{
6+
xPos = 0;
7+
yPos = 0;
8+
pushedButton = false;
9+
BUTTON_WIDTH = width;
10+
BUTTON_HEIGHT = height;
11+
fillRect = { 0, 0, 0, 0 };
12+
13+
}
14+
Button::Button()
15+
{
16+
}
17+
void Button::SetDimensions(int width, int height)
18+
{
19+
20+
}
21+
void Button::ChangeState()
22+
{
23+
if (pushedButton)
24+
{
25+
pushedButton = false;
26+
}
27+
else
28+
{
29+
pushedButton = true;
30+
}
31+
render();
32+
}
33+
void Button::setStateFalse()
34+
{
35+
pushedButton = false;
36+
render();
37+
}
38+
void Button::setStateTrue()
39+
{
40+
pushedButton = true;
41+
render();
42+
}
43+
Button::~Button()
44+
{
45+
}
46+
void Button::SetPosition(int x, int y)
47+
{
48+
xPos = x;
49+
yPos = y;
50+
render();
51+
}
52+
void Button::HandleEvent(SDL_Event* e)
53+
{
54+
if (e->type == SDL_MOUSEMOTION || e->type == SDL_MOUSEBUTTONDOWN || e->type == SDL_MOUSEBUTTONUP)
55+
{
56+
int x, y;
57+
SDL_GetMouseState(&x, &y);
58+
bool inside = false;
59+
if (xPos > x)
60+
{
61+
inside = false;
62+
}
63+
else if (xPos + BUTTON_WIDTH < x)
64+
{
65+
inside = false;
66+
}
67+
else if (yPos > y)
68+
{
69+
inside = false;
70+
}
71+
else if (yPos + BUTTON_HEIGHT < y)
72+
{
73+
inside = false;
74+
}
75+
else
76+
{
77+
inside = true;
78+
}
79+
if (inside && e->type == SDL_MOUSEBUTTONDOWN)
80+
{
81+
if (pushedButton)
82+
{
83+
pushedButton = false;
84+
}
85+
else
86+
{
87+
pushedButton = true;
88+
}
89+
90+
}
91+
}
92+
93+
}
94+
void Button::render()
95+
{
96+
97+
fillRect = { xPos, yPos, BUTTON_WIDTH - 1, BUTTON_HEIGHT - 1 };
98+
99+
}
100+
SDL_Rect Button::getRect()
101+
{
102+
return fillRect;
103+
}
104+
bool Button::getState()
105+
{
106+
return pushedButton;
107+
}
108+
int Button::getHeight()
109+
{
110+
return BUTTON_HEIGHT;
111+
}
112+
int Button::getWidth()
113+
{
114+
return BUTTON_WIDTH;
115+
}
116+
int Button::getX()
117+
{
118+
return xPos;
119+
}
120+
int Button::getY()
121+
{
122+
return yPos;
123+
}

Game Of Life/Button.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
#include "SDL.h"
3+
#include <vector>
4+
class Button
5+
{
6+
public:
7+
Button();
8+
Button(int width, int height);
9+
~Button();
10+
void SetPosition(int x, int y);
11+
void HandleEvent(SDL_Event* e);
12+
void render();
13+
bool getState();
14+
SDL_Rect getRect();
15+
int getHeight();
16+
int getWidth();
17+
int getX();
18+
int getY();
19+
void SetDimensions(int width, int height);
20+
void ChangeState();
21+
void setStateTrue();
22+
void setStateFalse();
23+
private:
24+
int BUTTON_WIDTH;
25+
int BUTTON_HEIGHT;
26+
int xPos;
27+
int yPos;
28+
SDL_Event* EVENT = NULL;
29+
SDL_Point mPosition;
30+
bool pushedButton;
31+
SDL_Rect fillRect;
32+
};
33+

Game Of Life/Debug.zip

3.67 MB
Binary file not shown.

Game Of Life/Debug/Button.obj

29.3 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\vc120.pdb
2+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\vc120.idb
3+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\button.obj
4+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\grid.obj
5+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\rules.obj
6+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\source.obj
7+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\debug\game of life.ilk
8+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\debug\game of life.exe
9+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\debug\game of life.pdb
10+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\cl.command.1.tlog
11+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\cl.read.1.tlog
12+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\cl.write.1.tlog
13+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\link.command.1.tlog
14+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\link.read.1.tlog
15+
c:\users\james\documents\visual studio 2013\gameoflife\game of life\game of life\debug\game of life.tlog\link.write.1.tlog

Game Of Life/Debug/Game Of Life.log

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Build started 10/1/2015 10:06:54 AM.
2+
1>Project "C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Game Of Life\Game Of Life.vcxproj" on node 2 (Build target(s)).
3+
1>Link:
4+
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Debug\Game Of Life.exe" /INCREMENTAL /NOLOGO SDL2.lib SDL2main.lib SDL2_image.lib SDL2_ttf.lib SDL2_mixer.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug /PDB:"C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Debug\Game Of Life.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Debug\Game Of Life.lib" /MACHINE:X86 Debug\Button.obj
5+
Debug\Grid.obj
6+
Debug\Rules.obj
7+
Debug\Source.obj
8+
1>MSVCRTD.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
9+
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
10+
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError
11+
1>C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Debug\Game Of Life.exe : fatal error LNK1120: 2 unresolved externals
12+
1>Done Building Project "C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\Game Of Life\Game Of Life.vcxproj" (Build target(s)) -- FAILED.
13+
14+
Build FAILED.
15+
16+
Time Elapsed 00:00:00.18
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
2+
Debug|Win32|C:\Users\James\Documents\Visual Studio 2013\Projects\GameOfLife\Game Of Life\|
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��

Game Of Life/Debug/Game Of Life.tlog/unsuccessfulbuild

Whitespace-only changes.

Game Of Life/Debug/Grid.obj

440 KB
Binary file not shown.

Game Of Life/Debug/Rules.obj

449 KB
Binary file not shown.

Game Of Life/Debug/Source.obj

32.3 KB
Binary file not shown.

Game Of Life/Debug/lazy.ttf

101 KB
Binary file not shown.

Game Of Life/Debug/vc120.idb

771 KB
Binary file not shown.

Game Of Life/Debug/vc120.pdb

548 KB
Binary file not shown.

Game Of Life/Debug/vc140.idb

675 KB
Binary file not shown.

Game Of Life/Debug/vc140.pdb

588 KB
Binary file not shown.

Game Of Life/Game Of Life.vcxproj

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{B83C204A-3AD8-4D8F-A3CA-A86D4FBCBE24}</ProjectGuid>
15+
<RootNamespace>GameOfLife</RootNamespace>
16+
<WindowsTargetPlatformVersion>10</WindowsTargetPlatformVersion>
17+
</PropertyGroup>
18+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
20+
<ConfigurationType>Application</ConfigurationType>
21+
<UseDebugLibraries>true</UseDebugLibraries>
22+
<PlatformToolset>v140</PlatformToolset>
23+
<CharacterSet>MultiByte</CharacterSet>
24+
</PropertyGroup>
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
26+
<ConfigurationType>Application</ConfigurationType>
27+
<UseDebugLibraries>false</UseDebugLibraries>
28+
<PlatformToolset>v140</PlatformToolset>
29+
<WholeProgramOptimization>true</WholeProgramOptimization>
30+
<CharacterSet>MultiByte</CharacterSet>
31+
</PropertyGroup>
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
33+
<ImportGroup Label="ExtensionSettings">
34+
</ImportGroup>
35+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
36+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
37+
</ImportGroup>
38+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
</ImportGroup>
41+
<PropertyGroup Label="UserMacros" />
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43+
<IncludePath>C:\Users\James\Documents\Visual Studio 2013\SDL2-2.0.3\include;$(IncludePath)</IncludePath>
44+
<LibraryPath>C:\Users\James\Documents\Visual Studio 2013\SDL2-2.0.3\lib\x86;$(LibraryPath)</LibraryPath>
45+
</PropertyGroup>
46+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
47+
<ClCompile>
48+
<WarningLevel>Level3</WarningLevel>
49+
<Optimization>Disabled</Optimization>
50+
<SDLCheck>true</SDLCheck>
51+
<AdditionalIncludeDirectories>C:\Users\James\Documents\Visual Studio 2013\SDL2-2.0.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
52+
</ClCompile>
53+
<Link>
54+
<GenerateDebugInformation>true</GenerateDebugInformation>
55+
<SubSystem>Windows</SubSystem>
56+
<AdditionalDependencies>SDL2.lib;SDL2main.lib;SDL2_image.lib;SDL2_ttf.lib;SDL2_mixer.lib;%(AdditionalDependencies)</AdditionalDependencies>
57+
</Link>
58+
</ItemDefinitionGroup>
59+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
60+
<ClCompile>
61+
<WarningLevel>Level3</WarningLevel>
62+
<Optimization>MaxSpeed</Optimization>
63+
<FunctionLevelLinking>true</FunctionLevelLinking>
64+
<IntrinsicFunctions>true</IntrinsicFunctions>
65+
<SDLCheck>true</SDLCheck>
66+
</ClCompile>
67+
<Link>
68+
<GenerateDebugInformation>true</GenerateDebugInformation>
69+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
70+
<OptimizeReferences>true</OptimizeReferences>
71+
</Link>
72+
</ItemDefinitionGroup>
73+
<ItemGroup>
74+
<ClCompile Include="Button.cpp" />
75+
<ClCompile Include="Grid.cpp" />
76+
<ClCompile Include="Rules.cpp" />
77+
<ClCompile Include="Source.cpp" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<ClInclude Include="Button.h" />
81+
<ClInclude Include="Grid.h" />
82+
<ClInclude Include="Rules.h" />
83+
</ItemGroup>
84+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
85+
<ImportGroup Label="ExtensionTargets">
86+
</ImportGroup>
87+
</Project>
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="Source.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
<ClCompile Include="Button.cpp">
22+
<Filter>Source Files</Filter>
23+
</ClCompile>
24+
<ClCompile Include="Grid.cpp">
25+
<Filter>Source Files</Filter>
26+
</ClCompile>
27+
<ClCompile Include="Rules.cpp">
28+
<Filter>Source Files</Filter>
29+
</ClCompile>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ClInclude Include="Button.h">
33+
<Filter>Header Files</Filter>
34+
</ClInclude>
35+
<ClInclude Include="Grid.h">
36+
<Filter>Header Files</Filter>
37+
</ClInclude>
38+
<ClInclude Include="Rules.h">
39+
<Filter>Header Files</Filter>
40+
</ClInclude>
41+
</ItemGroup>
42+
</Project>

0 commit comments

Comments
 (0)