Archives from S:\ Drive

Good to keep around methinks
This commit is contained in:
Amrit Panesar committed 2015-04-01 21:23:15 -07:00
1 parent eadaf70b9e
commit 6dd63cc439
606 files changed
+50212

No files matched your search

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Blackjack", "Blackjack\Blackjack.vcproj", "{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}.Debug|Win32.ActiveCfg = Debug|Win32
{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}.Debug|Win32.Build.0 = Debug|Win32
{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}.Release|Win32.ActiveCfg = Release|Win32
{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,14 @@
#include <iostream>
#include <string>
#include <ctime>
#include "game.h"
#include "deck.h"
#include "card.h"
#include "GenericPlayer.h"
#include "Player.h"
#include "House.h"
#include "Player.h"
using namespace std;
@@ -0,0 +1,228 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="Blackjack"
ProjectGUID="{F3A17DD5-8FF3-46B4-84DC-3ADF7C508D4F}"
RootNamespace="Blackjack"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<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=".\Deck.cpp"
>
</File>
<File
RelativePath=".\Game.cpp"
>
</File>
<File
RelativePath=".\GenericPlayer.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=".\Blackjack.h"
>
</File>
<File
RelativePath=".\Card.h"
>
</File>
<File
RelativePath=".\Deck.h"
>
</File>
<File
RelativePath=".\Game.h"
>
</File>
<File
RelativePath=".\GenericPlayer.h"
>
</File>
<File
RelativePath=".\House.h"
>
</File>
<File
RelativePath=".\Player.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>
@@ -0,0 +1,23 @@
#ifndef CARD_H
#define CARD_H
#include "Blackjack.h"
class Card
{
private:
bool isFaceUp;
public:
enum RANK { ACE=1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING };
enum SUIT { CLUBS, DIAMONDS, HEARTS, SPADES };
Card(RANK rank = ACE, SUIT suit = SPADES, bool isFaceUp = true);
int getValue();
void flip();
protected:
RANK rank;
SUIT suit;
};
#endif
@@ -0,0 +1,2 @@
#include "Blackjack.h"
@@ -0,0 +1,18 @@
#ifndef DECK_H
#define DECK_H
#include "Blackjack.h"
class Deck : public Hand
{
private:
public:
Deck();
virtual ~Deck();
void populate();
void shuffle();
void deal();
void additionalCards(GenericPlayer &aGenericPlayer);
};
#endif
@@ -0,0 +1,2 @@
#include "Blackjack.h"
@@ -0,0 +1,20 @@
#ifndef GAME_H
#define GAME_H
#include "Blackjack.h"
class Game
{
private:
Deck deck;
House house;
Player player;
public:
Game(const string &name);
~Game();
bool play();
};
#endif
@@ -0,0 +1 @@
#include "Blackjack.h"
@@ -0,0 +1,22 @@
#ifndef GENERICPLAYER_H
#define GENERICPLAYER_H
#include "Blackjack.h"
class GenericPlayer : public Hand
{
private:
string name;
public:
GenericPlayer();
virtual ~GenericPlayer();
virtual bool isHitting();
bool isBusted();
bool bust();
string getName();
void setName(string name);
};
#endif
@@ -0,0 +1,16 @@
#ifndef HOUSE_H
#define HOUSE_H
#include "Blackjack.h"
class House : public GenericPlayer
{
private:
public:
House(const string &name = "Dealer");
virtual ~House();
virtual bool isHitting();
void firstFirstCard();
};
#endif
@@ -0,0 +1,18 @@
#ifndef PLAYER_H
#define PLAYER_H
#include "Blackjack.h"
class Player : public GenericPlayer
{
private:
public:
Player(const string &name = "");
virtual ~Player();
virtual bool isHitting();
bool win();
bool loose();
bool push();
};
#endif
@@ -0,0 +1,21 @@
#include "Blackjack.h"
int main()
{
string name;
while (true)
{
cout << "Welcome to Blackjack 77260" << endl;
cout << "What is your name?" << endl << ":";
cin >> name;
getch();
}
while (true)
{
Game game(const string &name);
if (game.play())
{
break;
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Blackjack", "Blackjack\Blackjack.vcxproj", "{6A8CDB95-25A4-49DF-B82C-C56428FE5389}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A8CDB95-25A4-49DF-B82C-C56428FE5389}.Debug|Win32.ActiveCfg = Debug|Win32
{6A8CDB95-25A4-49DF-B82C-C56428FE5389}.Debug|Win32.Build.0 = Debug|Win32
{6A8CDB95-25A4-49DF-B82C-C56428FE5389}.Release|Win32.ActiveCfg = Release|Win32
{6A8CDB95-25A4-49DF-B82C-C56428FE5389}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,19 @@
#ifndef BLACKJACK_H
#define BLACKJACK_H
#include <iostream>
#include <string>
#include <ctime>
#include "game.h"
#include "deck.h"
#include "card.h"
#include "GenericPlayer.h"
#include "Player.h"
#include "House.h"
#include "Player.h"
using namespace std;
#endif
@@ -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>{6A8CDB95-25A4-49DF-B82C-C56428FE5389}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Blackjack</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="deck.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="GenericPlayer.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Blackjack.h" />
<ClInclude Include="card.h" />
<ClInclude Include="deck.h" />
<ClInclude Include="game.h" />
<ClInclude Include="GenericPlayer.h" />
<ClInclude Include="House.h" />
<ClInclude Include="Player.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="deck.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="game.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GenericPlayer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Blackjack.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="deck.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="game.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GenericPlayer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="House.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="card.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1 @@
#include "Blackjack.h"
@@ -0,0 +1,22 @@
#ifndef GENERICPLAYER_H
#define GENERICPLAYER_H
#include "Blackjack.h"
class GenericPlayer : public Hand
{
private:
string name;
public:
GenericPlayer();
virtual ~GenericPlayer();
virtual bool isHitting();
bool isBusted();
bool bust();
string getName();
void setName(string name);
};
#endif
@@ -0,0 +1,16 @@
#ifndef HOUSE_H
#define HOUSE_H
#include "Blackjack.h"
class House : public GenericPlayer
{
private:
public:
House(const string &name = "Dealer");
virtual ~House();
virtual bool isHitting();
void firstFirstCard();
};
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

@@ -0,0 +1,18 @@
#ifndef PLAYER_H
#define PLAYER_H
#include "Blackjack.h"
class Player : public GenericPlayer
{
private:
public:
Player(const string &name = "");
virtual ~Player();
virtual bool isHitting();
bool win();
bool loose();
bool push();
};
#endif
@@ -0,0 +1,23 @@
#ifndef CARD_H
#define CARD_H
#include "Blackjack.h"
class Card
{
private:
bool isFaceUp;
protected:
RANK rank;
SUIT suit;
public:
enum RANK { ACE=1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING };
enum SUIT { CLUBS, DIAMONDS, HEARTS, SPADES };
Card(RANK rank = ACE, SUIT suit = SPADES, isFaceUp = true);
int getValue();
void flip();
}
#endif
@@ -0,0 +1,2 @@
#include "Blackjack.h"
@@ -0,0 +1,18 @@
#ifndef DECK_H
#define DECK_H
#include "Blackjack.h"
class Deck : public Hand
{
private:
public:
Deck();
virtual ~Deck();
void populate();
void shuffle();
void deal();
void additionalCards(GenericPlayer &aGenericPlayer);
};
#endif
@@ -0,0 +1,2 @@
#include "Blackjack.h"
@@ -0,0 +1,20 @@
#ifndef GAME_H
#define GAME_H
#include "Blackjack.h"
class Game
{
private:
Deck deck;
House house;
Player player;
public:
Game(const string &name);
~Game();
bool play();
};
#endif
@@ -0,0 +1,21 @@
#include "Blackjack.h"
int main()
{
string name;
while (true)
{
cout << "Welcome to Blackjack 77260" << endl;
cout << "What is your name?" << endl << ":";
cin >> name;
getch();
}
while (true)
{
Game game(const string &name);
if (game.play())
{
break;
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COM203Midterm", "COM203Midterm\COM203Midterm.vcproj", "{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Debug|Win32.ActiveCfg = Debug|Win32
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Debug|Win32.Build.0 = Debug|Win32
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Release|Win32.ActiveCfg = Release|Win32
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,240 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: Account.h *
* Descript: This file contains methods declared in Account.h. This file *
* contains the source of the run function as well as the doMenu *
* function. The account number and account balanced are randomized*
* in the constructor for the Account class. *
* For more information see Account.h and main.cpp *
*****************************************************************************/
#include "Account.h"
/******************************************************************************
* Function: Account::Account(string) - Constructor *
* Abstract: The constructor initalizes the accountName with the parameter *
* specified. The member variabled accountBalance and accountNum *
* are assigned some random value using their respective set procs *
******************************************************************************/
Account::Account(string namein)
{
// The constructor initializes the accountName with the parameter specified
// The member variables accountBalance and accountNum are assigned some random value
setaccountName(namein);
unsigned int power = (unsigned int)pow((float)2,31); // pow(2,31) does not compile on visual studio 2008
setaccountNumber(rand()%power);
setaccountBalance((float)(rand()%power));
}
/******************************************************************************
* Function: Account::~Account() - Destructor *
* Abstract: Write the appropriate destructor, set and display functions. *
* This destructor prints that it has been called as per the sample *
* output provided. *
******************************************************************************/
Account::~Account()
{
// Write appropriate destructor, set, get and display functions
cout << "Destructor Called" << endl;
}
/******************************************************************************
* Function: Account::setaccountName(string) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountName member variable. *
******************************************************************************/
void Account::setaccountName(string namein)
{
// Write appropriate destructor, set, get and display functions
accountName = namein;
}
/******************************************************************************
* Function: Account::getaccountName() - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountName member variable. *
******************************************************************************/
string Account::getaccountName()
{
// Write appropriate destructor, set, get and display functions
return accountName;
}
/******************************************************************************
* Function: Account::setaccountBalance(float) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountBalance member variable *
******************************************************************************/
void Account::setaccountBalance(float balancein)
{
// Write appropriate destructor, set, get and display functions
accountBalance = balancein;
}
/******************************************************************************
* Function: Account::getaccountBalance() - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountBalance member variable *
******************************************************************************/
float Account::getaccountBalance()
{
// Write appropriate destructor, set, get and display functions
return accountBalance;
}
/******************************************************************************
* Function: Account::setaccountNumber(float) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountNumber member variable *
******************************************************************************/
void Account::setaccountNumber(unsigned int accnumbin)
{
// Write appropriate destructor, set, get and display functions
accountNumber = accnumbin;
}
/******************************************************************************
* Function: Account::getaccountNumber(float) - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountNumber member variable *
******************************************************************************/
unsigned int Account::getaccountNumber()
{
// Write appropriate destructor, set, get and display functions
return accountNumber;
}
/******************************************************************************
* Function: Account::displayAccountInformation() - Display *
* Abstract: Write the appropriate destructor, set and display functions. *
* This function displays the account balance, number, and name *
******************************************************************************/
void Account::displayAccountInformation()
{
// Write appropriate destructor, set, get and display functions
cout << "Here is the account Information:" << endl;
cout << "Account for: " << getaccountName() << endl;
cout << "Account #: " << getaccountNumber() << endl;
cout << "Balance: $" << getaccountBalance() << endl;
}
/******************************************************************************
* Function: Account::doExit() - Display *
* Abstract: Write the appropriate destructor, set and display functions. *
* This function is called at exit and displays a goodbye message *
******************************************************************************/
void Account::doExit()
{
cout << "Thank you for using Banking program" << endl;
}
/******************************************************************************
* Function: Account::withdraw() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
* The withdraw function checks to see if balance is sufficient for *
* withdrawal. If so, decrements balance by amount; if not, prints *
* an appropriate message indicating insufficient funds and displays*
* the current balance. *
******************************************************************************/
void Account::withdraw()
{
// The class will also contain member functions named menu, withdraw, and deposit
float withdraw;
cout << "Enter the amount you want to withdraw" << endl << ":";
cin >> withdraw;
if (withdraw > getaccountBalance())
{
cout << "ERROR: Cannot withdraw amount due to Insufficient Funds !" << endl;
cout << "Your balance remains at: $" << getaccountBalance() << endl;
}
else
{
setaccountBalance(getaccountBalance() - withdraw);
cout << "Withdrawing $" << withdraw << " from account #" << getaccountNumber() << endl;;
cout << "Your account balance is now: $" << getaccountBalance() << endl;
}
}
/******************************************************************************
* Function: Account::Deposit() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
******************************************************************************/
void Account::deposit()
{
// The class will also contain member functions named menu, withdraw, and deposit
float deposit;
cout << "Enter the amount you want to deposit" << endl << ":";
cin >> deposit;
setaccountBalance(getaccountBalance() + deposit);
cout << "Depositing $" << deposit << " into account #" << getaccountNumber() << endl;
cout << "Your account balance is now: $" << getaccountBalance() << endl;
}
/******************************************************************************
* Function: Account::Menu() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
******************************************************************************/
void Account::menu()
{
// The class will also contain member functions named menu, withdraw, and deposit
int choice;
enum { ACC_BALANCE = 1, DEPOSIT, WITHDRAW, EXIT };
while (true)
{
cout << "*******************************************************************************" << endl;
cout << "| Main Menu |" << endl;
cout << "*******************************************************************************" << endl;
cout << "| 1. Check account balance |" << endl;
cout << "| 2. Deposit amount |" << endl;
cout << "| 3. Withdraw amount |" << endl;
cout << "| 4. Exit |" << endl;
cout << "*******************************************************************************" << endl;
cout << "Please make a selection" << endl << ":";
cin >> choice;
switch (choice)
{
case ACC_BALANCE:
system("cls");
displayAccountInformation();
break;
case DEPOSIT:
system("cls");
displayAccountInformation();
deposit();
break;
case WITHDRAW:
system("cls");
displayAccountInformation();
withdraw();
break;
case EXIT:
doExit();
break;
default:
cout << "ERROR: You have made an invalid selection, please chose a different option." << endl;
}
if (choice == EXIT)
{
break;
}
}
}
/******************************************************************************
* Function: Account::run() - Utility *
* Abstract: Initially calls a function to display the account information, *
* then calls the menu function. *
******************************************************************************/
void Account::run()
{
system("cls");
displayAccountInformation();
menu();
}
@@ -0,0 +1,64 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: Account.h *
* Descript: This file contains the function prototypes and declarations *
* of data members in use with the banking application midterm. *
* Setters and getters for each member variable are provided as *
* public members. The constructor for the accont class requires *
* a string for the account name. *
* For more information see Account.cpp and main.cpp *
*****************************************************************************/
#include <string>
#include <iostream>
#include <ctime>
#include <cmath>
#include <Windows.h>
using namespace std;
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account {
private:
// Class contains 3 private data members called accountBalance, accountName and accountNum.
// Choose appropriate data types for these variables
float accountBalance;
string accountName;
unsigned int accountNumber;
public:
// Write an overloaded constructorthat takes one parameter of the type string.
Account(string name);
// Write appropriate destructor, set, get and display functions
~Account();
//Write appropriate destructor, set, get and display functions
float getaccountBalance();
void setaccountBalance(float balance);
string getaccountName();
void setaccountName(string name);
unsigned int getaccountNumber();
void setaccountNumber(unsigned int acccountNumber);
void displayAccountInformation();
// The class will also contain member functions named menu, withdraw, and deposit
void menu();
void withdraw();
void deposit();
void doExit();
void run();
};
#endif
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="COM203Midterm"
ProjectGUID="{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}"
RootNamespace="COM203Midterm"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
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="1"
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"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
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=".\Account.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=".\Account.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>
@@ -0,0 +1,46 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: main.cpp *
* Descript: This file contains the main method for the Banking application *
* it prompts the user for a name, seeds the random function, and *
* creates an instance of the Account class. *
* For more information see Account.cpp and Account.h *
*****************************************************************************/
#include "Account.h"
int main()
{
//even though there is No need to use rand function, I find it easier.
srand((unsigned int)time(NULL));
//some place to store the name
string accountName;
//begin name choosing loop.
while (true)
{
cout << "Welcome to the Bank Account program" << endl;
cout << "What is your name?" << endl << ":";
cin >> accountName;
cout << "Your name is " << accountName << ". Is that correct?" << endl << "[Y/n]:";
char choice;
cin >> choice;
if (toupper(choice) == 'Y') // toupper() because Yes, yes, Y and y will all be converted to Y
{
break;
}
}
Account acc(accountName);
acc.run();
system("pause"); // a call to Windows.h, makes the pause thingy
return 0; //success
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Com203Midterm", "Com203Midterm\Com203Midterm.vcxproj", "{15660994-69D3-4D19-9752-3E9FB1F75092}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15660994-69D3-4D19-9752-3E9FB1F75092}.Debug|Win32.ActiveCfg = Debug|Win32
{15660994-69D3-4D19-9752-3E9FB1F75092}.Debug|Win32.Build.0 = Debug|Win32
{15660994-69D3-4D19-9752-3E9FB1F75092}.Release|Win32.ActiveCfg = Release|Win32
{15660994-69D3-4D19-9752-3E9FB1F75092}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,238 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: Account.h *
* Descript: This file contains methods declared in Account.h. This file *
* contains the source of the run function as well as the doMenu *
* function. The account number and account balanced are randomized*
* in the constructor for the Account class. *
* For more information see Account.h and main.cpp *
*****************************************************************************/
#include "Account.h"
/******************************************************************************
* Function: Account::Account(string) - Constructor *
* Abstract: The constructor initalizes the accountName with the parameter *
* specified. The member variabled accountBalance and accountNum *
* are assigned some random value using their respective set procs *
******************************************************************************/
Account::Account(string namein)
{
// The constructor initializes the accountName with the parameter specified
// The member variables accountBalance and accountNum are assigned some random value
setaccountName(namein);
setaccountNumber(rand()%(unsigned int)pow(2,31));
setaccountBalance(rand()%(unsigned int)pow(2,31));
}
/******************************************************************************
* Function: Account::~Account() - Destructor *
* Abstract: Write the appropriate destructor, set and display functions. *
* This destructor prints that it has been called as per the sample *
* output provided. *
******************************************************************************/
Account::~Account()
{
// Write appropriate destructor, set, get and display functions
cout << "Destructor Called" << endl;
}
/******************************************************************************
* Function: Account::setaccountName(string) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountName member variable. *
******************************************************************************/
void Account::setaccountName(string namein)
{
// Write appropriate destructor, set, get and display functions
accountName = namein;
}
/******************************************************************************
* Function: Account::getaccountName() - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountName member variable. *
******************************************************************************/
string Account::getaccountName()
{
// Write appropriate destructor, set, get and display functions
return accountName;
}
/******************************************************************************
* Function: Account::setaccountBalance(float) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountBalance member variable *
******************************************************************************/
void Account::setaccountBalance(float balancein)
{
// Write appropriate destructor, set, get and display functions
accountBalance = balancein;
}
/******************************************************************************
* Function: Account::getaccountBalance() - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountBalance member variable *
******************************************************************************/
float Account::getaccountBalance()
{
// Write appropriate destructor, set, get and display functions
return accountBalance;
}
/******************************************************************************
* Function: Account::setaccountNumber(float) - Setter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This sets the accountNumber member variable *
******************************************************************************/
void Account::setaccountNumber(unsigned int accnumbin)
{
// Write appropriate destructor, set, get and display functions
accountNumber = accnumbin;
}
/******************************************************************************
* Function: Account::getaccountNumber(float) - Getter *
* Abstract: Write the appropriate destructor, set and display functions. *
* This gets the accountNumber member variable *
******************************************************************************/
unsigned int Account::getaccountNumber()
{
// Write appropriate destructor, set, get and display functions
return accountNumber;
}
/******************************************************************************
* Function: Account::displayAccountInformation() - Display *
* Abstract: Write the appropriate destructor, set and display functions. *
* This function displays the account balance, number, and name *
******************************************************************************/
void Account::displayAccountInformation()
{
// Write appropriate destructor, set, get and display functions
cout << "Here is the account Information:" << endl;
cout << "Account for: " << getaccountName() << endl;
cout << "Account #: " << getaccountNumber() << endl;
cout << "Balance: $" << getaccountBalance() << endl;
}
/******************************************************************************
* Function: Account::doExit() - Display *
* Abstract: Write the appropriate destructor, set and display functions. *
* This function is called at exit and displays a goodbye message *
******************************************************************************/
void Account::doExit()
{
cout << "Thank you for using Banking program" << endl;
}
/******************************************************************************
* Function: Account::withdraw() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
* The withdraw function checks to see if balance is sufficient for *
* withdrawal. If so, decrements balance by amount; if not, prints *
* an appropriate message indicating insufficient funds and displays*
* the current balance. *
******************************************************************************/
void Account::withdraw()
{
// The class will also contain member functions named menu, withdraw, and deposit
float withdraw;
cout << "Enter the amount you want to withdraw" << endl << ":";
cin >> withdraw;
if (withdraw > getaccountBalance())
{
cout << "ERROR: Cannot withdraw amount due to Insufficient Funds !" << endl;
cout << "Your balance remains at: $" << getaccountBalance() << endl;
}
else
{
setaccountBalance(getaccountBalance() - withdraw);
cout << "Withdrawing $" << withdraw << " from account #" << getaccountNumber() << endl;;
cout << "Your account balance is now: $" << getaccountBalance() << endl;
}
}
/******************************************************************************
* Function: Account::Deposit() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
******************************************************************************/
void Account::deposit()
{
// The class will also contain member functions named menu, withdraw, and deposit
float deposit;
cout << "Enter the amount you want to deposit" << endl << ":";
cin >> deposit;
cout << "Depositing $" << deposit << " into account #" << getaccountNumber() << endl;
cout << "Your account balance is now: $" << getaccountBalance() << endl;
}
/******************************************************************************
* Function: Account::Menu() - Utility *
* Abstract: The class will also contain member functions named menu, *
* withdraw, and deposit. *
******************************************************************************/
void Account::menu()
{
// The class will also contain member functions named menu, withdraw, and deposit
int choice;
enum { ACC_BALANCE = 1, DEPOSIT, WITHDRAW, EXIT };
while (true)
{
cout << "*******************************************************************************" << endl;
cout << "| Main Menu |" << endl;
cout << "*******************************************************************************" << endl;
cout << "| 1. Check account balance |" << endl;
cout << "| 2. Deposit amount |" << endl;
cout << "| 3. Withdraw amount |" << endl;
cout << "| 4. Exit |" << endl;
cout << "*******************************************************************************" << endl;
cout << "Please make a selection" << endl << ":";
cin >> choice;
switch (choice)
{
case ACC_BALANCE:
system("cls");
displayAccountInformation();
break;
case DEPOSIT:
system("cls");
displayAccountInformation();
deposit();
break;
case WITHDRAW:
system("cls");
displayAccountInformation();
withdraw();
break;
case EXIT:
doExit();
break;
default:
cout << "ERROR: You have made an invalid selection, please chose a different option." << endl;
}
if (choice == EXIT)
{
break;
}
}
}
/******************************************************************************
* Function: Account::run() - Utility *
* Abstract: Initially calls a function to display the account information, *
* then calls the menu function. *
******************************************************************************/
void Account::run()
{
system("cls");
displayAccountInformation();
menu();
}
@@ -0,0 +1,63 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: Account.h *
* Descript: This file contains the function prototypes and declarations *
* of data members in use with the banking application midterm. *
* Setters and getters for each member variable are provided as *
* public members. The constructor for the accont class requires *
* a string for the account name. *
* For more information see Account.cpp and main.cpp *
*****************************************************************************/
#include <string>
#include <iostream>
#include <ctime>
#include <Windows.h>
using namespace std;
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account {
private:
// Class contains 3 private data members called accountBalance, accountName and accountNum.
// Choose appropriate data types for these variables
float accountBalance;
string accountName;
unsigned int accountNumber;
public:
// Write an overloaded constructorthat takes one parameter of the type string.
Account(string name);
// Write appropriate destructor, set, get and display functions
~Account();
//Write appropriate destructor, set, get and display functions
float getaccountBalance();
void setaccountBalance(float balance);
string getaccountName();
void setaccountName(string name);
unsigned int getaccountNumber();
void setaccountNumber(unsigned int acccountNumber);
void displayAccountInformation();
// The class will also contain member functions named menu, withdraw, and deposit
void menu();
void withdraw();
void deposit();
void doExit();
void run();
};
#endif
@@ -0,0 +1,88 @@
<?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>
<ItemGroup>
<ClInclude Include="Account.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Account.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{15660994-69D3-4D19-9752-3E9FB1F75092}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Com203Midterm</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Account.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Account.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,46 @@
/*****************************************************************************
* Program: Banking Application Midterm *
* Author: Amrit Panesar *
* Date: 06/26/2013 *
* Course: COM 203 - S. Ganore *
* Abstract: A bank account class with methods to deposit, withdraw, *
* and check the balance of the account instance *
* Depends: Account.h, Standard C Library *
* File: main.cpp *
* Descript: This file contains the main method for the Banking application *
* it prompts the user for a name, seeds the random function, and *
* creates an instance of the Account class. *
* For more information see Account.cpp and Account.h *
*****************************************************************************/
#include "Account.h"
int main()
{
//even though there is No need to use rand function, I find it easier.
srand((unsigned int)time(NULL));
//some place to store the name
string accountName;
//begin name choosing loop.
while (true)
{
cout << "Welcome to the Bank Account program" << endl;
cout << "What is your name?" << endl << ":";
cin >> accountName;
cout << "Your name is " << accountName << ". Is that correct?" << endl << "[Y/n]:";
char choice;
cin >> choice;
if (toupper(choice) == 'Y') // toupper() because Yes, yes, Y and y will all be converted to Y
{
break;
}
}
Account acc(accountName);
acc.run();
system("pause"); // a call to Windows.h, makes the pause thingy
return 0; //success
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hangman", "Hangman\Hangman.vcproj", "{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}.Debug|Win32.ActiveCfg = Debug|Win32
{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}.Debug|Win32.Build.0 = Debug|Win32
{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}.Release|Win32.ActiveCfg = Release|Win32
{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,456 @@
#include "stdhangman.h"
Hangman::Hangman()
{
attempts = 0;
wordLength = 0;
secretWord = "";
wordList = vector<hangword>();
adminList = vector<string>();
//readdmins();
readFromFile();
blankguesses();
doseed();
}
void Hangman::blankguesses()
{
attempts = 0;
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (unsigned int i = 0; i < alpha.length(); i++)
{
alphabet[i] = alpha[i];
}
}
void Hangman::displayMenu()
{
while (true)
{
cls();
fflush(stdout);
centerline("Main Menu",1);
centerline("==========================",2);
centerline("1. Game Administration",3);
centerline("2. Begin a game",4);
centerline("3. Exit",5);
centerline("==========================",6);
cursorpos(1,7);
cout << "Please make a selection" << endl << ":";
string input;
cin >> input;
switch (input[0])
{
case '1':
while(doadmin());
break;
case '2':
while(playGame());
break;
case '3':
break;
default:
writeline("Please make a valid selection [1-3]");
writeline(2);
}
if ( input[0] == '3' )
{
break;
}
}
}
bool Hangman::playGame()
{
chooseword();
blankguesses();
while (attempts <= 6)
{
while(!handleinput());
if (revealedword == secretWord)
{
break;
}
}
cls();
if (attempts >= 6)
{
centerline("Hangman - Loss", 1);
centerline(secretWord, 4);
centerline("Sorry! You loose this round", 8);
}
else
{
centerline("Hangman - Winner", 1);
centerline(secretWord, 4);
centerline("Congradulations! You guessed correctly",8);
}
writeline(2);
string input;
while (true)
{
cout << "Play again?" << endl << "[Y/n]";
cin >> input;
if (toupper(input[0]) == 'Y')
{
return true;
}
else if (toupper(input[0]) == 'N')
{
return false;
}
else
{
cout << "Please enter either Yes or No" << endl;
}
}
return true;
}
bool Hangman::notguessed(char inguess)
{
for (int j = 0; j < 26; j++)
{
if (alphabet[j] == inguess)
{
alphabet[j] = ' ';
return true;
}
}
return false;
}
bool Hangman::doadmin()
{
cls();
centerline("Hangman - Administration",1);
centerline("Hangman Administrator Login",4);
cursorpos(1,10);
cout << "Please enter your password" << endl << ":";
return false;
}
bool Hangman::isinword(char inguess)
{
string secret = getSecretWord();
for (unsigned int i = 0; i < secret.length(); i++)
{
if (secret[i] == toupper(inguess))
{
return true;
}
}
return false;
}
void Hangman::drawletters()
{
for (int i = 0; i < 26; i++)
{
if (i == 0)
{
cursorpos (4,6);
}
if (i == 8)
{
cursorpos (4,8);
}
if (i == 16)
{
cursorpos (4,10);
}
if ( i == 24 )
{
cursorpos(4, 12);
}
cout << alphabet[i] << " ";
}
cursorpos(4, 18);
cout << revealedword;
}
bool Hangman::handleinput()
{
cls(); // clear screen
drawseperator(); // do the sepeaator thing
centerline("Hangman",1); // screen title
drawhangman();
drawletters();
fflush(stdout);
cursorpos(0, 20);
writeline("Please enter a letter");
cout << ":";
string input;
cin >> input;
char guess = input[0];
guess = toupper(guess);
if (isalpha(guess) && notguessed(guess))
{
if (isinword(guess))
{
revealchar(guess);
}
else
{
attempts++;
}
return true;
}
else
{
cout << guess << " is an invalid input, please try again";
pause();
return false;
}
}
void Hangman::revealchar(char input)
{
string secret = getSecretWord();
for (unsigned int i = 0; i < secret.length(); i++)
{
if (secret[i] == input)
{
revealedword[i] = secret[i];
}
}
}
void Hangman::readFromFile()
{
/*
hangword holdword;
ifstream hangmanfile ("wordlist.bin", ios::in|ios::binary|ios::ate);
if (hangmanfile.is_open())
{
while(!hangmanfile.eof())
{
holdword.Read(hangmanfile);
wordList.push_back(holdword);
}
}
else
{
cout << "Unable to open wordlist.bin for reading. Trying to create it.." << endl;
*/
initFile();
// }
}
void Hangman::initFile()
{
hangword holdword;
ifstream hangwordtxt ("hangmanwordlist.txt", ios::in);
int id = 1;
if (hangwordtxt.is_open())
{
while (!hangwordtxt.eof())
{
string word = "";
getline(hangwordtxt,word);
for (unsigned int j = 0; j < word.length(); j++)
{
word[j] = toupper(word[j]);
}
holdword.setword(word);
holdword.setid(id);
wordList.push_back(holdword);
id++;
}
}
else
{
cout << "Error unable to open hangmanwordlist.txt for reading" << endl;
pause();
}
hangwordtxt.close();
if (wordList.size() != 0)
{
ofstream hangmanbin ("wordlist.bin", ios::out|ios::binary|ios::app);
if (hangmanbin.is_open())
{
for (unsigned int i = 0; i < wordList.size(); i++)
{
wordList[i].Write(hangmanbin);
}
}
else
{
cout << "Error unable to open wordlist.bin for writing" << endl;
pause();
}
}
else
{
cout << "No words in the wordlist. Not creating file." << endl;
pause();
}
}
void Hangman::chooseword()
{
if (wordList.size() == 0)
{
hangword hang;
hang.setid(0);
hang.setword("TEST");
wordList.push_back(hang);
}
int wordindex = rand()%wordList.size();
setSecretWord(wordList[wordindex].getword());
string rev = string(getSecretWord().length(),'_');
revealedword = rev;
}
void Hangman::drawhangman()
{
cursorpos(55, 10);
switch (attempts)
{
case 0:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" |" << endl;
cursorpos(55, 13);
cout <<" |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 1:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 2:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" | |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 3:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /| |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 4:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 5:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 6:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" / |" << endl;
break;
case 7:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" / \\ |" << endl;
break;
}
cursorpos(55, 16);
cout <<" ________|________" << endl;
cursorpos(55, 17);
cout <<" / | /|" << endl;
cursorpos(55, 18);
cout <<"/________________/ /" << endl;
cursorpos(55, 19);
cout <<"|________________|/" << endl;
}
void Hangman::setSecretWord(string word)
{
secretWord = word;
}
string Hangman::getSecretWord()
{
return secretWord;
}
void Hangman::setWordLength(int length)
{
wordLength = length;
}
int Hangman::getWordLength()
{
return wordLength;
}
/***********************************
___
| |
@ |
/|\ |
| |
/ \ |
________|________
/ | /|
/________________/ /
|________________|/
************************************/
@@ -0,0 +1,45 @@
#ifndef HANGMAN_H
#define HANGMAN_H
#include "stdhangman.h"
class Hangman
{
private:
int attempts;
vector<hangword> wordList;
vector<string> adminList;
string secretWord;
string revealedword;
int wordLength;
char alphabet[26];
bool emessage;
string message;
public:
Hangman();
bool playGame();
void enterNewWords();
bool isWin();
void convertToUpper();
void readFromFile();
void setSecretWord(string word);
string getSecretWord();
void setWordLength(int length);
int getWordLength();
void initFile();
bool notguessed(char guess);
bool isinword(char guess);
bool doadmin();
void displayMenu();
void drawhangman();
bool handleinput();
void blankguesses();
void revealchar(char reveal);
void chooseword();
void drawletters();
};
#endif
@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="Hangman"
ProjectGUID="{49C28840-F8EF-4E80-A3D4-4DCCC30C1414}"
RootNamespace="Hangman"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<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=".\Hangman.cpp"
>
</File>
<File
RelativePath=".\Hangword.cpp"
>
</File>
<File
RelativePath=".\Main.cpp"
>
</File>
<File
RelativePath=".\Stdhangman.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Hangman.h"
>
</File>
<File
RelativePath=".\Hangword.h"
>
</File>
<File
RelativePath=".\stdhangman.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>
@@ -0,0 +1,76 @@
#include "stdhangman.h"
int hangword::getid()
{
return id;
}
void hangword::setid(int id)
{
this->id = id;
}
void hangword::setword(string word)
{
this->word = word;
}
string hangword::getword()
{
return word;
}
void hangword::Read(ifstream& file)
{
setid(readid(file));
setword(readword(file));
}
void hangword::Write(ofstream& file)
{
int id = getid();
writeid(file, id);
writeword(file, getword());
}
void hangword::writeword(ofstream& file,const string& str)
{
// get the length of the string data
unsigned int len = str.size();
// write the size:
file.write( reinterpret_cast<const char*>( &len ), sizeof(len) );
// write the actual string data:
file.write( str.c_str(), len );
}
string hangword::readword(ifstream& file)
{
// this probably isn't the optimal way to do it, but whatever
string str;
// get the length
unsigned int len;
file.read( reinterpret_cast<char*>( &len ), sizeof(len) );
// we can't read to string directly, so instead, create a temporary buffer
if(len > 0)
{
char* buf = new char[len];
file.read( buf, len );
str.append( buf, len );
delete[] buf;
}
return str;
}
inline void hangword::writeid(ofstream& file, int& num)
{
file.write(reinterpret_cast<char *>(&num),sizeof(int));
}
int hangword::readid(ifstream& file)
{
int num;
file.read(reinterpret_cast<char *>(&num),sizeof(int));
return num;
}
@@ -0,0 +1,28 @@
#ifndef WORD_H
#define WORD_H
#include "stdhangman.h"
class hangword
{
private:
int id;
string word;
public:
void setid(int in);
int getid();
void setword(string in);
string getword();
void Read(ifstream& file);
void Write(ofstream& file);
void writeword(ofstream& file,const string& str);
string readword(ifstream& file);
void writeid(ofstream& file, int& num);
int readid(ifstream& file);
};
#endif
@@ -0,0 +1,10 @@
#include "stdhangman.h"
int main()
{
Hangman game;
game.displayMenu();
pause();
return 0;
}
@@ -0,0 +1,94 @@
#include "stdhangman.h"
// Pause() use conio.h's get character to pause the program
void pause()
{
int c;
cout << endl << "Press any key to continue . . ." << endl;
c = _getch();
if (c == 0 || c == 224) // getch will return a 0 or 244 on error
{
_getch(); // try again
}
}
// cursorpos(X,Y) use ConsoleAPI to place the cursor at a particular position
void cursorpos(int X, int Y)
{
if ( X < 0 ) // off the screen
{
X = 0;
}
if ( Y < 0 )
{
Y = 0;
}
HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); //grab the stdout handle
COORD newpos = { X, Y }; // use the Coord struct to stage the new position
SetConsoleCursorPosition( hStdOut, newpos ); // set the new curser position
}
// take the input modulous the length by 80, set the cursor position there
void centerline(string input, int linenum)
{
if (input.length() > 80) // over 80 characters? must be centered already
{
cursorpos(0,linenum);
}
int mod = (80-input.length())/2; // formula: input length subtracted from console line length divided by 2
cursorpos(mod,linenum); // set where to write
cout << input << endl; // write it
}
// write a line
void writeline(string input)
{
cout << ' ' << input << endl; // simple function to begin a line with a ' '
}
// write a blank line
void writeline(int num)
{
for (int i = 0; i <= num; i++) // easy function for multiple blank lines
{
cout << endl;
}
}
// do the seperator thing
void drawseperator()
{
for (int i = 2; i < 24; i++) // sepearates the hangman from the words
{
cursorpos(50,i);
cout << "|";
}
}
// seed using micro time. much better than grabbing a random pointer.
void doseed()
{
unsigned __int64 freq;
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
double timerFrequency = (1.0/freq);
unsigned __int64 startTime;
QueryPerformanceCounter((LARGE_INTEGER *)&startTime);
srand(startTime*freq);
}
// use the console api to fill the screen with spaces
void cls() {
HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {0, 0};
DWORD written;
CONSOLE_SCREEN_BUFFER_INFO screen_attr;
unsigned size;
GetConsoleScreenBufferInfo(screen, &screen_attr);
size = screen_attr.dwSize.X * screen_attr.dwSize.Y;
FillConsoleOutputCharacterW(screen, ' ', size, pos, &written);
SetConsoleCursorPosition(screen, pos);
}
@@ -0,0 +1,100 @@
fluorine
steapsin
gadoid
optics
master
uninvasive
nettable
preintend
scourge
clinah
planking
autogenetic
inweaved
peipus
corneal
descendant
premonopolizing
wadmoll
grimily
anatolic
uniced
unendeared
geothermic
tarsier
hartmann
actuarially
caffein
antiexpressive
refasten
hostelling
sacculus
teazeling
resolution
demoralised
fletcherizing
decently
mitrephorus
reverser
eudora
comestible
kilpatrick
peroneal
corporate
provisional
plaice
atheneum
juicing
wintery
ellipsoid
avigation
republicanism
bocage
frederika
cleruch
counterbracing
uninstigated
undocumented
voyeurism
catchfly
scatomas
overwore
radiably
rhoecus
eighteenmo
imperfectness
siziness
curable
gradin
breadroot
heresy
ophytic
cosmopolitanizing
cannoneer
haverhill
abingdon
mentor
dissimulator
fazenda
syrphid
rockier
inobservance
hipbone
duckiest
interclub
mollendo
touche
dionysius
impedible
intoner
cichoriaceous
nondrinkable
nevada
pithecanthropus
upswinging
humectant
diakinesis
capacitively
nonaccord
cilice
exuviate
@@ -0,0 +1,23 @@
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <ctime>
#include <ctype.h>
#include <Windows.h>
#include <conio.h>
#include "Hangman.h"
#include "hangword.h"
using namespace std;
void pause();
void cursorpos(int x, int y);
void centerline(string input, int linenum);
void writeline(string input);
void writeline(int num);
void drawseperator();
void doseed();
void cls();
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hangman", "Hangman\Hangman.vcxproj", "{7310FC30-2591-4B40-9580-33268702093E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7310FC30-2591-4B40-9580-33268702093E}.Debug|Win32.ActiveCfg = Debug|Win32
{7310FC30-2591-4B40-9580-33268702093E}.Debug|Win32.Build.0 = Debug|Win32
{7310FC30-2591-4B40-9580-33268702093E}.Release|Win32.ActiveCfg = Release|Win32
{7310FC30-2591-4B40-9580-33268702093E}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,456 @@
#include "stdhangman.h"
Hangman::Hangman()
{
attempts = 0;
wordLength = 0;
secretWord = "";
wordList = vector<hangword>();
adminList = vector<string>();
//readdmins();
readFromFile();
blankguesses();
doseed();
}
void Hangman::blankguesses()
{
attempts = 0;
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (unsigned int i = 0; i < alpha.length(); i++)
{
alphabet[i] = alpha[i];
}
}
void Hangman::displayMenu()
{
while (true)
{
cls();
fflush(stdout);
centerline("Main Menu",1);
centerline("==========================",2);
centerline("1. Game Administration",3);
centerline("2. Begin a game",4);
centerline("3. Exit",5);
centerline("==========================",6);
cursorpos(1,7);
cout << "Please make a selection" << endl << ":";
string input;
cin >> input;
switch (input[0])
{
case '1':
while(doadmin());
break;
case '2':
while(playGame());
break;
case '3':
break;
default:
writeline("Please make a valid selection [1-3]");
writeline(2);
}
if ( input[0] == '3' )
{
break;
}
}
}
bool Hangman::playGame()
{
chooseword();
blankguesses();
while (attempts <= 6)
{
while(!handleinput());
if (revealedword == secretWord)
{
break;
}
}
cls();
if (attempts >= 6)
{
centerline("Hangman - Loss", 1);
centerline(secretWord, 4);
centerline("Sorry! You loose this round", 8);
}
else
{
centerline("Hangman - Winner", 1);
centerline(secretWord, 4);
centerline("Congratulations! You guessed correctly",8);
}
writeline(2);
string input;
while (true)
{
cout << "Play again?" << endl << "[Y/n]";
cin >> input;
if (toupper(input[0]) == 'Y')
{
return true;
}
else if (toupper(input[0]) == 'N')
{
return false;
}
else
{
cout << "Please enter either Yes or No" << endl;
}
}
return true;
}
bool Hangman::notguessed(char inguess)
{
for (int j = 0; j < 26; j++)
{
if (alphabet[j] == inguess)
{
alphabet[j] = ' ';
return true;
}
}
return false;
}
bool Hangman::doadmin()
{
cls();
centerline("Hangman - Administration",1);
centerline("Hangman Administrator Login",4);
cursorpos(1,10);
cout << "Please enter your password" << endl << ":";
return false;
}
bool Hangman::isinword(char inguess)
{
string secret = getSecretWord();
for (unsigned int i = 0; i < secret.length(); i++)
{
if (secret[i] == toupper(inguess))
{
return true;
}
}
return false;
}
void Hangman::drawletters()
{
for (int i = 0; i < 26; i++)
{
if (i == 0)
{
cursorpos (4,6);
}
if (i == 8)
{
cursorpos (4,8);
}
if (i == 16)
{
cursorpos (4,10);
}
if ( i == 24 )
{
cursorpos(4, 12);
}
cout << alphabet[i] << " ";
}
cursorpos(4, 18);
cout << revealedword;
}
bool Hangman::handleinput()
{
cls(); // clear screen
drawseperator(); // do the separator thing
centerline("Hangman",1); // screen title
drawhangman();
drawletters();
fflush(stdout);
cursorpos(0, 20);
writeline("Please enter a letter");
cout << ":";
string input;
cin >> input;
char guess = input[0];
guess = toupper(guess);
if (isalpha(guess) && notguessed(guess))
{
if (isinword(guess))
{
revealchar(guess);
}
else
{
attempts++;
}
return true;
}
else
{
cout << guess << " is an invalid input, please try again";
pause();
return false;
}
}
void Hangman::revealchar(char input)
{
string secret = getSecretWord();
for (unsigned int i = 0; i < secret.length(); i++)
{
if (secret[i] == input)
{
revealedword[i] = secret[i];
}
}
}
void Hangman::readFromFile()
{
/*
hangword holdword;
ifstream hangmanfile ("wordlist.bin", ios::in|ios::binary|ios::ate);
if (hangmanfile.is_open())
{
while(!hangmanfile.eof())
{
holdword.Read(hangmanfile);
wordList.push_back(holdword);
}
}
else
{
cout << "Unable to open wordlist.bin for reading. Trying to create it.." << endl;
*/
initFile();
// }
}
void Hangman::initFile()
{
hangword holdword;
ifstream hangwordtxt ("hangmanwordlist.txt", ios::in);
int id = 1;
if (hangwordtxt.is_open())
{
while (!hangwordtxt.eof())
{
string word = "";
getline(hangwordtxt,word);
for (unsigned int j = 0; j < word.length(); j++)
{
word[j] = toupper(word[j]);
}
holdword.setword(word);
holdword.setid(id);
wordList.push_back(holdword);
id++;
}
}
else
{
cout << "Error unable to open hangmanwordlist.txt for reading" << endl;
pause();
}
hangwordtxt.close();
if (wordList.size() != 0)
{
ofstream hangmanbin ("wordlist.bin", ios::out|ios::binary|ios::app);
if (hangmanbin.is_open())
{
for (unsigned int i = 0; i < wordList.size(); i++)
{
wordList[i].Write(hangmanbin);
}
}
else
{
cout << "Error unable to open wordlist.bin for writing" << endl;
pause();
}
}
else
{
cout << "No words in the wordlist. Not creating file." << endl;
pause();
}
}
void Hangman::chooseword()
{
if (wordList.size() == 0)
{
hangword hang;
hang.setid(0);
hang.setword("TEST");
wordList.push_back(hang);
}
int wordindex = rand()%wordList.size();
setSecretWord(wordList[wordindex].getword());
string rev = string(getSecretWord().length(),'_');
revealedword = rev;
}
void Hangman::drawhangman()
{
cursorpos(55, 10);
switch (attempts)
{
case 0:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" |" << endl;
cursorpos(55, 13);
cout <<" |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 1:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 2:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" | |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 3:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /| |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 4:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 5:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" |" << endl;
break;
case 6:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" / |" << endl;
break;
case 7:
cout <<" ___ " << endl;
cursorpos(55, 11);
cout <<" | |" << endl;
cursorpos(55, 12);
cout <<" @ |" << endl;
cursorpos(55, 13);
cout <<" /|\\ |" << endl;
cursorpos(55, 14);
cout <<" | |" << endl;
cursorpos(55, 15);
cout <<" / \\ |" << endl;
break;
}
cursorpos(55, 16);
cout <<" ________|________" << endl;
cursorpos(55, 17);
cout <<" / | /|" << endl;
cursorpos(55, 18);
cout <<"/________________/ /" << endl;
cursorpos(55, 19);
cout <<"|________________|/" << endl;
}
void Hangman::setSecretWord(string word)
{
secretWord = word;
}
string Hangman::getSecretWord()
{
return secretWord;
}
void Hangman::setWordLength(int length)
{
wordLength = length;
}
int Hangman::getWordLength()
{
return wordLength;
}
/***********************************
___
| |
@ |
/|\ |
| |
/ \ |
________|________
/ | /|
/________________/ /
|________________|/
************************************/
@@ -0,0 +1,45 @@
#ifndef HANGMAN_H
#define HANGMAN_H
#include "stdhangman.h"
class Hangman
{
private:
int attempts;
vector<hangword> wordList;
vector<string> adminList;
string secretWord;
string revealedword;
int wordLength;
char alphabet[26];
bool emessage;
string message;
public:
Hangman();
bool playGame();
void enterNewWords();
bool isWin();
void convertToUpper();
void readFromFile();
void setSecretWord(string word);
string getSecretWord();
void setWordLength(int length);
int getWordLength();
void initFile();
bool notguessed(char guess);
bool isinword(char guess);
bool doadmin();
void displayMenu();
void drawhangman();
bool handleinput();
void blankguesses();
void revealchar(char reveal);
void chooseword();
void drawletters();
};
#endif
@@ -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>{7310FC30-2591-4B40-9580-33268702093E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Hangman</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Hangman.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="md5.cpp" />
<ClCompile Include="Hangword.cpp" />
<ClCompile Include="stdhangman.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Hangman.h" />
<ClInclude Include="md5.h" />
<ClInclude Include="stdhangman.h" />
<ClInclude Include="hangword.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Hangman.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="md5.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdhangman.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdhangman.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Hangman.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="md5.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hangword.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,76 @@
#include "stdhangman.h"
int hangword::getid()
{
return id;
}
void hangword::setid(int id)
{
this->id = id;
}
void hangword::setword(string word)
{
this->word = word;
}
string hangword::getword()
{
return word;
}
void hangword::Read(ifstream& file)
{
setid(readid(file));
setword(readword(file));
}
void hangword::Write(ofstream& file)
{
int id = getid();
writeid(file, id);
writeword(file, getword());
}
void hangword::writeword(ofstream& file,const string& str)
{
// get the length of the string data
unsigned int len = str.size();
// write the size:
file.write( reinterpret_cast<const char*>( &len ), sizeof(len) );
// write the actual string data:
file.write( str.c_str(), len );
}
string hangword::readword(ifstream& file)
{
// this probably isn't the optimal way to do it, but whatever
string str;
// get the length
unsigned int len;
file.read( reinterpret_cast<char*>( &len ), sizeof(len) );
// we can't read to string directly, so instead, create a temporary buffer
if(len > 0)
{
char* buf = new char[len];
file.read( buf, len );
str.append( buf, len );
delete[] buf;
}
return str;
}
inline void hangword::writeid(ofstream& file, int& num)
{
file.write(reinterpret_cast<char *>(&num),sizeof(int));
}
int hangword::readid(ifstream& file)
{
int num;
file.read(reinterpret_cast<char *>(&num),sizeof(int));
return num;
}
@@ -0,0 +1,100 @@
fluorine
steapsin
gadoid
optics
master
uninvasive
nettable
preintend
scourge
clinah
planking
autogenetic
inweaved
peipus
corneal
descendant
premonopolizing
wadmoll
grimily
anatolic
uniced
unendeared
geothermic
tarsier
hartmann
actuarially
caffein
antiexpressive
refasten
hostelling
sacculus
teazeling
resolution
demoralised
fletcherizing
decently
mitrephorus
reverser
eudora
comestible
kilpatrick
peroneal
corporate
provisional
plaice
atheneum
juicing
wintery
ellipsoid
avigation
republicanism
bocage
frederika
cleruch
counterbracing
uninstigated
undocumented
voyeurism
catchfly
scatomas
overwore
radiably
rhoecus
eighteenmo
imperfectness
siziness
curable
gradin
breadroot
heresy
ophytic
cosmopolitanizing
cannoneer
haverhill
abingdon
mentor
dissimulator
fazenda
syrphid
rockier
inobservance
hipbone
duckiest
interclub
mollendo
touche
dionysius
impedible
intoner
cichoriaceous
nondrinkable
nevada
pithecanthropus
upswinging
humectant
diakinesis
capacitively
nonaccord
cilice
exuviate
@@ -0,0 +1,28 @@
#ifndef WORD_H
#define WORD_H
#include "stdhangman.h"
class hangword
{
private:
int id;
string word;
public:
void setid(int in);
int getid();
void setword(string in);
string getword();
void Read(ifstream& file);
void Write(ofstream& file);
void writeword(ofstream& file,const string& str);
string readword(ifstream& file);
void writeid(ofstream& file, int& num);
int readid(ifstream& file);
};
#endif
@@ -0,0 +1,10 @@
#include "stdhangman.h"
int main()
{
Hangman game;
game.displayMenu();
pause();
return 0;
}
@@ -0,0 +1,363 @@
/* MD5
converted to C++ class by Frank Thilo (thilo@unix-ag.org)
for bzflag (http://www.bzflag.org)
based on:
md5.h and md5.c
reference implemantion of RFC 1321
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#define _CRT_SECURE_NO_WARNINGS
/* interface header */
#include "md5.h"
/* system implementation headers */
#include <stdio.h>
// Constants for MD5Transform routine.
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
///////////////////////////////////////////////
// F, G, H and I are basic MD5 functions.
inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {
return x&y | ~x&z;
}
inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {
return x&z | y&~z;
}
inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {
return x^y^z;
}
inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {
return y ^ (x | ~z);
}
// rotate_left rotates x left n bits.
inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {
return (x << n) | (x >> (32-n));
}
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;
}
inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + G(b,c,d) + x + ac, s) + b;
}
inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + H(b,c,d) + x + ac, s) + b;
}
inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + I(b,c,d) + x + ac, s) + b;
}
//////////////////////////////////////////////
// default ctor, just initailize
MD5::MD5()
{
init();
}
//////////////////////////////////////////////
// nifty shortcut ctor, compute MD5 for string and finalize it right away
MD5::MD5(const std::string &text)
{
init();
update(text.c_str(), text.length());
finalize();
}
//////////////////////////////
void MD5::init()
{
finalized=false;
count[0] = 0;
count[1] = 0;
// load magic initialization constants.
state[0] = 0x67452301;
state[1] = 0xefcdab89;
state[2] = 0x98badcfe;
state[3] = 0x10325476;
}
//////////////////////////////
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
void MD5::decode(uint4 output[], const uint1 input[], size_type len)
{
for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
(((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
}
//////////////////////////////
// encodes input (uint4) into output (unsigned char). Assumes len is
// a multiple of 4.
void MD5::encode(uint1 output[], const uint4 input[], size_type len)
{
for (size_type i = 0, j = 0; j < len; i++, j += 4) {
output[j] = input[i] & 0xff;
output[j+1] = (input[i] >> 8) & 0xff;
output[j+2] = (input[i] >> 16) & 0xff;
output[j+3] = (input[i] >> 24) & 0xff;
}
}
//////////////////////////////
// apply MD5 algo on a block
void MD5::transform(const uint1 block[blocksize])
{
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
decode (x, block, blocksize);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
// Zeroize sensitive information.
memset(x, 0, sizeof x);
}
//////////////////////////////
// MD5 block update operation. Continues an MD5 message-digest
// operation, processing another message block
void MD5::update(const unsigned char input[], size_type length)
{
// compute number of bytes mod 64
size_type index = count[0] / 8 % blocksize;
// Update number of bits
if ((count[0] += (length << 3)) < (length << 3))
count[1]++;
count[1] += (length >> 29);
// number of bytes we need to fill in buffer
size_type firstpart = 64 - index;
size_type i;
// transform as many times as possible.
if (length >= firstpart)
{
// fill buffer first, transform
memcpy(&buffer[index], input, firstpart);
transform(buffer);
// transform chunks of blocksize (64 bytes)
for (i = firstpart; i + blocksize <= length; i += blocksize)
transform(&input[i]);
index = 0;
}
else
i = 0;
// buffer remaining input
memcpy(&buffer[index], &input[i], length-i);
}
//////////////////////////////
// for convenience provide a verson with signed char
void MD5::update(const char input[], size_type length)
{
update((const unsigned char*)input, length);
}
//////////////////////////////
// MD5 finalization. Ends an MD5 message-digest operation, writing the
// the message digest and zeroizing the context.
MD5& MD5::finalize()
{
static unsigned char padding[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
if (!finalized) {
// Save number of bits
unsigned char bits[8];
encode(bits, count, 8);
// pad out to 56 mod 64.
size_type index = count[0] / 8 % 64;
size_type padLen = (index < 56) ? (56 - index) : (120 - index);
update(padding, padLen);
// Append length (before padding)
update(bits, 8);
// Store state in digest
encode(digest, state, 16);
// Zeroize sensitive information.
memset(buffer, 0, sizeof buffer);
memset(count, 0, sizeof count);
finalized=true;
}
return *this;
}
//////////////////////////////
// return hex representation of digest as string
std::string MD5::hexdigest() const
{
if (!finalized)
return "";
char buf[33];
for (int i=0; i<16; i++)
sprintf(buf+i*2, "%02x", digest[i]);
buf[32]=0;
return std::string(buf);
}
//////////////////////////////
std::ostream& operator<<(std::ostream& out, MD5 md5)
{
return out << md5.hexdigest();
}
//////////////////////////////
std::string md5(const std::string str)
{
MD5 md5 = MD5(str);
return md5.hexdigest();
}
@@ -0,0 +1,93 @@
/* MD5
converted to C++ class by Frank Thilo (thilo@unix-ag.org)
for bzflag (http://www.bzflag.org)
based on:
md5.h and md5.c
reference implementation of RFC 1321
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#ifndef BZF_MD5_H
#define BZF_MD5_H
#include <string>
#include <iostream>
// a small class for calculating MD5 hashes of strings or byte arrays
// it is not meant to be fast or secure
//
// usage: 1) feed it blocks of uchars with update()
// 2) finalize()
// 3) get hexdigest() string
// or
// MD5(std::string).hexdigest()
//
// assumes that char is 8 bit and int is 32 bit
class MD5
{
public:
typedef unsigned int size_type; // must be 32bit
MD5();
MD5(const std::string& text);
void update(const unsigned char *buf, size_type length);
void update(const char *buf, size_type length);
MD5& finalize();
std::string hexdigest() const;
friend std::ostream& operator<<(std::ostream&, MD5 md5);
private:
void init();
typedef unsigned char uint1; // 8bit
typedef unsigned int uint4; // 32bit
enum {blocksize = 64}; // VC6 won't eat a const static int here
void transform(const uint1 block[blocksize]);
static void decode(uint4 output[], const uint1 input[], size_type len);
static void encode(uint1 output[], const uint4 input[], size_type len);
bool finalized;
uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
uint4 count[2]; // 64bit counter for number of bits (lo, hi)
uint4 state[4]; // digest so far
uint1 digest[16]; // the result
// low level logic operations
static inline uint4 F(uint4 x, uint4 y, uint4 z);
static inline uint4 G(uint4 x, uint4 y, uint4 z);
static inline uint4 H(uint4 x, uint4 y, uint4 z);
static inline uint4 I(uint4 x, uint4 y, uint4 z);
static inline uint4 rotate_left(uint4 x, int n);
static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
};
std::string md5(const std::string str);
#endif
@@ -0,0 +1,94 @@
#include "stdhangman.h"
// Pause() use conio.h's get character to pause the program
void pause()
{
int c;
cout << endl << "Press any key to continue . . ." << endl;
c = _getch();
if (c == 0 || c == 224) // getch will return a 0 or 244 on error
{
_getch(); // try again
}
}
// cursorpos(X,Y) use ConsoleAPI to place the cursor at a particular position
void cursorpos(int X, int Y)
{
if ( X < 0 ) // off the screen
{
X = 0;
}
if ( Y < 0 )
{
Y = 0;
}
HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); //grab the stdout handle
COORD newpos = { X, Y }; // use the Coord struct to stage the new position
SetConsoleCursorPosition( hStdOut, newpos ); // set the new cursor position
}
// take the input modulus the length by 80, set the cursor position there
void centerline(string input, int linenum)
{
if (input.length() > 80) // over 80 characters? must be centred already
{
cursorpos(0,linenum);
}
int mod = (80-input.length())/2; // formula: input length subtracted from console line length divided by 2
cursorpos(mod,linenum); // set where to write
cout << input << endl; // write it
}
// write a line
void writeline(string input)
{
cout << ' ' << input << endl; // simple function to begin a line with a ' '
}
// write a blank line
void writeline(int num)
{
for (int i = 0; i <= num; i++) // easy function for multiple blank lines
{
cout << endl;
}
}
// do the separator thing
void drawseperator()
{
for (int i = 2; i < 24; i++) // separates the hangman from the words
{
cursorpos(50,i);
cout << "|";
}
}
// seed using micro time. much better than grabbing a random pointer.
void doseed()
{
unsigned __int64 freq;
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
double timerFrequency = (1.0/freq);
unsigned __int64 startTime;
QueryPerformanceCounter((LARGE_INTEGER *)&startTime);
srand(startTime*freq);
}
// use the console api to fill the screen with spaces
void cls() {
HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {0, 0};
DWORD written;
CONSOLE_SCREEN_BUFFER_INFO screen_attr;
unsigned size;
GetConsoleScreenBufferInfo(screen, &screen_attr);
size = screen_attr.dwSize.X * screen_attr.dwSize.Y;
FillConsoleOutputCharacterW(screen, ' ', size, pos, &written);
SetConsoleCursorPosition(screen, pos);
}
@@ -0,0 +1,24 @@
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <ctime>
#include <ctype.h>
#include <Windows.h>
#include <conio.h>
#include "md5.h"
#include "Hangman.h"
#include "hangword.h"
using namespace std;
void pause();
void cursorpos(int x, int y);
void centerline(string input, int linenum);
void writeline(string input);
void writeline(int num);
void drawseperator();
void doseed();
void cls();
@@ -0,0 +1,9 @@
Code change needed from the handout.
Use the following code to instantiate your root object in the Pong constructor:
#ifdef _DEBUG
rootPtr = new Root("Plugins_d.cfg"); // initialize Root object
#else
rootPtr = new Root("Plugins.cfg"); // initialize Root object
#endif
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ogre Project", "Ogre Project\Ogre Project.vcxproj", "{220D5644-C06B-4022-A9D7-7B43CEBC46D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Debug|Win32.ActiveCfg = Debug|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Debug|Win32.Build.0 = Debug|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Release|Win32.ActiveCfg = Release|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ogre Project", "Ogre Project\Ogre Project.vcproj", "{220D5644-C06B-4022-A9D7-7B43CEBC46D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Debug|Win32.ActiveCfg = Debug|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Debug|Win32.Build.0 = Debug|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Release|Win32.ActiveCfg = Release|Win32
{220D5644-C06B-4022-A9D7-7B43CEBC46D8}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,174 @@
// Ball.cpp
// Ball class member-function definitions.
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
#include <OgreAL.h> // OgreAL class definition
#include "Ball.h" // Ball class definition
#include "Paddle.h" // Paddle class definition
#include "Pong.h" // Pong class definition
// Ball constructor
Ball::Ball( SceneManager *ptr )
{
sceneManagerPtr = ptr; // set pointer to the SceneManager
soundManagerPtr = new OgreAL::SoundManager(); // create SoundManager
speed = 100; // speed of the Ball
direction = Vector3( 1, -1, 0 ); // direction of the Ball
} // end Ball constructor
// Ball destructor
Ball::~Ball()
{
// empty body
} // end Ball destructor
// add the Ball to the scene
void Ball::addToScene()
{
// create Entity and attach it to a node in the scene
Entity *entityPtr =
sceneManagerPtr->createEntity( "Ball", "sphere.mesh" );
entityPtr->setMaterialName( "ball" ); // set material for the Ball
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "Ball" ); // create a SceneNode
nodePtr->attachObject( entityPtr ); // attach the Entity to SceneNode
nodePtr->setScale( .05, .05, .05 ); // scale SceneNode
// attach sounds to Ball so they will play from where Ball is
wallSoundPtr = soundManagerPtr->
createSound( "wallSound", "wallSound.wav", false );
nodePtr->attachObject( wallSoundPtr ); // attach a sound to SceneNode
paddleSoundPtr = soundManagerPtr->
createSound( "paddleSound", "paddleSound.wav", false );
nodePtr->attachObject( paddleSoundPtr ); // attach sound to SceneNode
scoreSoundPtr = soundManagerPtr->
createSound( "cheer", "cheer.wav", false ); // create a Sound
// attach the score sound to its own node centered at ( 0, 0, 0 )
sceneManagerPtr->getRootSceneNode()->createChildSceneNode( "score" )->
attachObject( scoreSoundPtr );
} // end function addToScene
// move the Ball across the screen
void Ball::moveBall( Real time )
{
nodePtr->translate( ( direction * ( speed * time ) ) ); // move Ball
Vector3 position = nodePtr->getPosition(); // get Ball's new position
// get the positions of the four walls
Vector3 topPosition = sceneManagerPtr->
getSceneNode( "WallTop" )->getPosition();
Vector3 bottomPosition = sceneManagerPtr->
getSceneNode( "WallBottom" )->getPosition();
Vector3 leftPosition = sceneManagerPtr->
getSceneNode( "WallLeft" )->getPosition();
Vector3 rightPosition = sceneManagerPtr->
getSceneNode( "WallRight" )->getPosition();
const int WALL_WIDTH = 5; // the width of the walls
// check if the Ball hit the left side
if ( ( position.x - RADIUS ) <= leftPosition.x + ( WALL_WIDTH / 2 ) )
{
nodePtr->setPosition( 0, 0, 0 ); // place Ball in center of screen
Pong::updateScore( Players::PLAYER2 ); // update the score
scoreSoundPtr->play(); // play a sound when player 2 scores
} // end if
// check if the Ball hit the right side
else if (
( position.x + RADIUS ) >= rightPosition.x - ( WALL_WIDTH / 2 ) )
{
nodePtr->setPosition( 0, 0, 0 ); // place Ball in center of screen
Pong::updateScore( Players::PLAYER1 ); // update the score
scoreSoundPtr->play(); // play a sound when player 1 scores
} // end else
// check if the Ball hit the bottom wall
else if (
( position.y - RADIUS ) <= bottomPosition.y + ( WALL_WIDTH / 2 ) &&
direction.y < 0 )
{
// place the Ball on the bottom wall
nodePtr->setPosition( position.x,
( bottomPosition.y + ( WALL_WIDTH / 2 ) + RADIUS ), position.z );
reverseVerticalDirection(); // make the Ball start moving up
} // end else
// check if the Ball hit the top wall
else if (
( position.y + RADIUS ) >= topPosition.y - ( WALL_WIDTH / 2 ) &&
direction.y > 0 )
{
// place the Ball on the top wall
nodePtr->setPosition( position.x,
( topPosition.y - ( WALL_WIDTH / 2 ) - RADIUS ), position.z );
reverseVerticalDirection(); // make the Ball start moving down
} // end else
hitPaddle(); // check if the Ball hit a Paddle
} // end function moveBall
// reverse the Ball's horizontal direction
void Ball::reverseHorizontalDirection()
{
direction *= Vector3( -1, 1, 1 ); // reverse the horizontal direction
paddleSoundPtr->play(); // play the "paddleSound" sound effect
} // end function reverseHorizontalDirection
// reverse the Ball's vertical direction
void Ball::reverseVerticalDirection()
{
direction *= Vector3( 1, -1, 1 ); // reverse the vertical direction
wallSoundPtr->play(); // play the "wallSound" sound effect
} // end function reverseVerticalDirection
// control the Ball colliding with the Paddle
void Ball::hitPaddle()
{
// get the position of the Paddles and the Ball
Vector3 leftPaddlePosition = sceneManagerPtr->
getSceneNode( "LeftPaddle" )->getPosition(); // left Paddle
Vector3 rightPaddlePosition = sceneManagerPtr->
getSceneNode( "RightPaddle" )->getPosition(); // right Paddle
Vector3 ballPosition = nodePtr->getPosition(); // the Ball's position
const int PADDLE_WIDTH = 2; // width of the Paddle
const int PADDLE_HEIGHT = 30; // height of the Paddle
// is the Ball in range of the left Paddle?
if ( ( ballPosition.x - RADIUS ) <
( leftPaddlePosition.x + ( PADDLE_WIDTH / 2 ) ) )
{
// check for collision with left Paddle
if ( ( ballPosition.y - RADIUS ) <
( leftPaddlePosition.y + ( PADDLE_HEIGHT / 2 ) ) &&
( ballPosition.y + RADIUS ) >
( leftPaddlePosition.y - ( PADDLE_HEIGHT / 2 ) ) )
{
reverseHorizontalDirection(); // reverse the Ball's direction
// place the Ball at the edge of the Paddle
nodePtr->setPosition(
( leftPaddlePosition.x + ( PADDLE_WIDTH / 2 ) + RADIUS ),
ballPosition.y, ballPosition.z );
} // end if
} // end if
// is the Ball in range of the right Paddle?
else if ( ( ballPosition.x + RADIUS ) >
( rightPaddlePosition.x - ( PADDLE_WIDTH / 2 ) ) )
{
// check for collision with right Paddle
if ( ( ballPosition.y - RADIUS ) <
( rightPaddlePosition.y + ( PADDLE_HEIGHT / 2 ) ) &&
( ballPosition.y + RADIUS ) >
( rightPaddlePosition.y - ( PADDLE_HEIGHT / 2 ) ) )
{
reverseHorizontalDirection(); // reverse the Ball's direction
// place the Ball at the edge of the Paddle
nodePtr->setPosition(
( rightPaddlePosition.x - ( PADDLE_WIDTH / 2 ) - RADIUS ),
ballPosition.y, ballPosition.z );
} // end if
} // end else
} // end function hitPaddle
@@ -0,0 +1,40 @@
// Ball.h
// Ball class definition (represents a bouncing ball).
#ifndef BALL_H
#define BALL_H
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
#include <OgreAL.h> // OgreAL class definition
class Paddle; // forward declaration of class Paddle
const int RADIUS = 5; // the radius of the Ball
class Ball
{
public:
Ball( SceneManager *sceneManagerPtr ); // constructor
~Ball(); // destructor
void addToScene(); // add the Ball to the scene
void moveBall( Real time ); // move the Ball across the screen
private:
SceneManager *sceneManagerPtr; // pointer to the SceneManager
SceneNode *nodePtr; // pointer to the SceneNode
OgreAL::SoundManager *soundManagerPtr; // pointer to the SoundManager
OgreAL::Sound *wallSoundPtr; // sound played when Ball hits a wall
OgreAL::Sound *paddleSoundPtr; // sound played when Ball hits a Paddle
OgreAL::Sound *scoreSoundPtr; // sound played when someone scores
int speed; // speed of the Ball
Vector3 direction; // direction of the Ball
// private utility functions
void reverseHorizontalDirection(); // change horizontal direction
void reverseVerticalDirection(); // change vertical direction
void hitPaddle(); // control the Ball hitting the Paddles
}; // end class Ball
#endif // BALL_H
@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Ogre Project"
ProjectGUID="{220D5644-C06B-4022-A9D7-7B43CEBC46D8}"
RootNamespace="OgreProject"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(GDD_OGRE_HOME)\Ogre3D\include&quot;;&quot;$(GDD_OGRE_HOME)\OpenAL\include&quot;;&quot;$(GDD_OGRE_HOME)\OgreAL\include&quot;;&quot;$(GDD_OGRE_HOME)\ogg\include&quot;;&quot;$(GDD_OGRE_HOME)\vorbis\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="OgreMain_d.lib OIS_d.lib OgreAL_d.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(GDD_OGRE_HOME)\Ogre3D\lib\$(ConfigurationName)&quot;;&quot;$(GDD_OGRE_HOME)\OgreAL\lib\$(ConfigurationName)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
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="1"
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;$(GDD_OGRE_HOME)\Ogre3D\include&quot;;&quot;$(GDD_OGRE_HOME)\OpenAL\include&quot;;&quot;$(GDD_OGRE_HOME)\OgreAL\include&quot;;&quot;$(GDD_OGRE_HOME)\ogg\include&quot;;&quot;$(GDD_OGRE_HOME)\vorbis\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="OgreMain.lib OIS.lib OgreAL.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(GDD_OGRE_HOME)\Ogre3D\lib\$(ConfigurationName)&quot;;&quot;$(GDD_OGRE_HOME)\OgreAL\lib\$(ConfigurationName)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
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=".\Ball.cpp"
>
</File>
<File
RelativePath=".\Paddle.cpp"
>
</File>
<File
RelativePath=".\Pong.cpp"
>
</File>
<File
RelativePath=".\PongMain.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Ball.h"
>
</File>
<File
RelativePath=".\Paddle.h"
>
</File>
<File
RelativePath=".\Pong.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>
@@ -0,0 +1,111 @@
<?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>{220D5644-C06B-4022-A9D7-7B43CEBC46D8}</ProjectGuid>
<RootNamespace>OgreProject</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</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.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(GDD_OGRE_HOME)\Ogre3D\include;$(GDD_OGRE_HOME)\OpenAL\include;$(GDD_OGRE_HOME)\OgreAL\include;$(GDD_OGRE_HOME)\ogg\include;$(GDD_OGRE_HOME)\vorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>OgreMain_d.lib;OIS_d.lib;OgreAL_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(GDD_OGRE_HOME)\Ogre3D\lib\$(Configuration);$(GDD_OGRE_HOME)\OgreAL\lib\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(GDD_OGRE_HOME)\Ogre3D\include;$(GDD_OGRE_HOME)\OpenAL\include;$(GDD_OGRE_HOME)\OgreAL\include;$(GDD_OGRE_HOME)\ogg\include;$(GDD_OGRE_HOME)\vorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>OgreMain.lib;OIS.lib;OgreAL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(GDD_OGRE_HOME)\Ogre3D\lib\$(Configuration);$(GDD_OGRE_HOME)\OgreAL\lib\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Ball.cpp" />
<ClCompile Include="Paddle.cpp" />
<ClCompile Include="Pong.cpp" />
<ClCompile Include="PongMain.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Ball.h" />
<ClInclude Include="Paddle.h" />
<ClInclude Include="Pong.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Ball.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Paddle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Pong.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PongMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Ball.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Paddle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Pong.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,48 @@
// Paddle.cpp
// Paddle class member-function definitions.
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
#include "Paddle.h" // Paddle class definition
// constructor
Paddle::Paddle( SceneManager *ptr, String paddleName,
int positionX )
{
sceneManagerPtr = ptr; // set the pointer to the SceneManager
name = paddleName; // set the Paddle's name
x = positionX; // set the Paddle's x coordinate
} // end Paddle constructor
// destructor
Paddle::~Paddle()
{
// empty body
} // end Paddle default destructor
// add the Paddle to the scene
void Paddle::addToScene()
{
Entity *entityPtr = sceneManagerPtr->
createEntity( name, "cube.mesh" ); // create an Entity
entityPtr->setMaterialName( "paddle" ); // set the Paddle's material
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( name ); // create a SceneNode for the Paddle
nodePtr->attachObject( entityPtr ); // attach Paddle to the SceneNode
nodePtr->setScale( .02, .3, .1 ); // set the Paddle's size
nodePtr->setPosition( x, 0, 0 ); // set the Paddle's position
} // end function addToScene
// move the Paddle up and down the screen
void Paddle::movePaddle( const Vector3 &direction )
{
nodePtr->translate( direction ); // move the Paddle
if ( nodePtr->getPosition().y > 52.5 ) // top of the box
nodePtr->setPosition( x, 52.5, 0 ); // place Paddle at top of box
else if ( nodePtr->getPosition().y < -52.5 ) // bottom of the box
// place the Paddle at the bottom of the box
nodePtr->setPosition( x, -52.5, 0 );
} // end function movePaddle
@@ -0,0 +1,27 @@
// Paddle.h
// Paddle class definition (represents a paddle in the game).
#ifndef PADDLE_H
#define PADDLE_H
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
class Paddle
{
public:
// constructor
Paddle( SceneManager *sceneManagerPtr, String paddleName,
int positionX);
~Paddle(); // destructor
void addToScene(); // add a Paddle to the scene
void movePaddle( const Vector3 &direction ); // move a Paddle
private:
SceneManager* sceneManagerPtr; // pointer to the SceneManager
SceneNode *nodePtr; // pointer to a SceneNode
String name; // name of the Paddle
int x; // x coordinate of the Paddle
}; // end of class Paddle
#endif // PADDLE_H
@@ -0,0 +1,14 @@
# Defines plugins to load
# Define plugin folder
PluginFolder=.
# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_CgProgramManager
@@ -0,0 +1,14 @@
# Defines plugins to load
# Define plugin folder
PluginFolder=.
# Define plugins
Plugin=RenderSystem_Direct3D9_d
Plugin=RenderSystem_GL_d
Plugin=Plugin_ParticleFX_d
Plugin=Plugin_BSPSceneManager_d
Plugin=Plugin_OctreeSceneManager_d
Plugin=Plugin_CgProgramManager_d
@@ -0,0 +1,303 @@
// Pong.cpp
// Pong class member-function definitions.
#include <sstream>
#include <stdexcept>
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
using namespace std; // use the Standard C namespace
#include <OgreAL.h> // OgreAL class definition
#include <OgreStringConverter.h> // OgreStringConverter class definition
#include <OIS/OISEvents.h> // OISEvents class definition
#include <OIS/OISInputManager.h> // OISInputManager class definition
#include <OIS/OISKeyboard.h> // OISKeyboard class definition
#include "Ball.h" // Ball class definition
#include "Paddle.h" // Paddle class definition
#include "Pong.h" // Pong class definition
int Pong::player1Score = 0; // initialize player 1's score to 0
int Pong::player2Score = 0; // initialize player 2's score to 0
bool Pong::wait = false; // initialize wait to false
// directions to move the Paddles
const Vector3 PADDLE_DOWN = Vector3( 0, -15, 0 );
const Vector3 PADDLE_UP = Vector3( 0, 15, 0 );
// constructor
Pong::Pong()
{
#ifdef _DEBUG
rootPtr = new Root("Plugins_d.cfg"); // initialize Root object
#else
rootPtr = new Root("Plugins.cfg"); // initialize Root object
#endif
// use the Ogre Config Dialog Box to choose the settings
if ( !( rootPtr->showConfigDialog() ) ) // user canceled the dialog box
throw runtime_error( "User Canceled Ogre Setup Dialog Box." );
// get a pointer to the RenderWindow
windowPtr = rootPtr->initialise( true, "Pong" );
// create the SceneManager
sceneManagerPtr = rootPtr->createSceneManager( ST_GENERIC );
// create the Camera
cameraPtr = sceneManagerPtr->createCamera( "PongCamera" );
cameraPtr->setPosition( Vector3( 0, 0, 200 ) ); // set Camera position
cameraPtr->lookAt( Vector3( 0, 0, 0 ) ); // set where Camera looks
cameraPtr->setNearClipDistance( 5 ); // near distance Camera can see
cameraPtr->setFarClipDistance( 1000 ); // far distance Camera can see
// create the Viewport
viewportPtr = windowPtr->addViewport( cameraPtr );
viewportPtr->setBackgroundColour( ColourValue( 0, 0, 0 ) );
// set the Camera's aspect ratio
cameraPtr->setAspectRatio( Real( viewportPtr->getActualWidth() ) /
( viewportPtr->getActualHeight() ) );
// set the scene's ambient light
sceneManagerPtr->setAmbientLight( ColourValue( 0.75, 0.75, 0.75 ) );
// create the Light
Light *lightPtr = sceneManagerPtr->createLight( "Light" ); // a Light
lightPtr->setPosition( 0, 0, 50 ); // set the Light's position
unsigned long hWnd; // variable to hold the window handle
windowPtr->getCustomAttribute( "WINDOW", &hWnd ); // get window handle
OIS::ParamList paramList; // create an OIS ParamList
// add the window to the ParamList
paramList.insert( OIS::ParamList::value_type( "WINDOW",
Ogre::StringConverter::toString( hWnd ) ) );
// create the InputManager
inputManagerPtr = OIS::InputManager::createInputSystem( paramList );
keyboardPtr = static_cast< OIS::Keyboard* >( inputManagerPtr->
createInputObject( OIS::OISKeyboard, true ) ); // create a Keyboard
keyboardPtr->setEventCallback( this ); // add a KeyListener
rootPtr->addFrameListener( this ); // add this Pong as a FrameListener
// load resources for Pong
ResourceGroupManager::getSingleton().addResourceLocation(
"resources", "FileSystem", "Pong" );
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
quit = pause = false; // player has not quit or paused the game
time = 0; // initialize the time since Ball was reset to 0
} // end Pong constructor
// Pong destructor erases objects contained in a Pong object
Pong::~Pong()
{
// free dynamically allocated memory for Keyboard
inputManagerPtr->destroyInputObject( keyboardPtr );
OIS::InputManager::destroyInputSystem( inputManagerPtr );
// free dynamically allocated memory for Root
delete rootPtr; // release memory pointer points to
rootPtr = 0; // point pointer at 0
// free dynamically allocated memory for Ball
delete ballPtr; // release memory pointer points to
ballPtr = 0; // point pointer at 0
// free dynamically allocated memory for Paddle
delete leftPaddlePtr; // release memory pointer points to
leftPaddlePtr = 0; // point pointer at 0
// free dynamically allocated memory for Paddle
delete rightPaddlePtr; // release memory pointer points to
rightPaddlePtr = 0; // point pointer at 0
} // end Pong destructor
// create the scene to be displayed
void Pong::createScene()
{
// get a pointer to the Score Overlay
Overlay *scoreOverlayPtr =
OverlayManager::getSingleton().getByName( "Score" );
scoreOverlayPtr->show(); // show the Overlay
// make the game objects
ballPtr = new Ball( sceneManagerPtr ); // make the Ball
ballPtr->addToScene(); // add the Ball to the scene
rightPaddlePtr = new Paddle( sceneManagerPtr, "RightPaddle", 90 );
rightPaddlePtr->addToScene(); // add a Paddle to the scene
leftPaddlePtr = new Paddle( sceneManagerPtr, "LeftPaddle", -90 );
leftPaddlePtr->addToScene(); // add a Paddle to the scene
// create the walls
Entity *entityPtr = sceneManagerPtr->
createEntity( "WallLeft", "cube.mesh" ); // create the left wall
entityPtr->setMaterialName( "wall" ); // set material for left wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the left wall
SceneNode *nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallLeft" );
nodePtr->attachObject( entityPtr ); // attach left wall to SceneNode
nodePtr->setPosition( -95, 0, 0 ); // set the left wall's position
nodePtr->setScale( .05, 1.45, .1 ); // set the left wall's size
entityPtr = sceneManagerPtr->createEntity( "WallRight", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set material for right wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the right wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallRight" );
nodePtr->attachObject( entityPtr ); // attach right wall to SceneNode
nodePtr->setPosition( 95, 0, 0 ); // set the right wall's position
nodePtr->setScale( .05, 1.45, .1 ); // set the right wall's size
entityPtr = sceneManagerPtr->createEntity( "WallBottom", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set material for bottom wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the bottom wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallBottom" );
nodePtr->attachObject( entityPtr ); // attach bottom wall to SceneNode
nodePtr->setPosition( 0, -70, 0 ); // set the bottom wall's position
nodePtr->setScale( 1.95, .05, .1 ); // set bottom wall's size
entityPtr = sceneManagerPtr->createEntity( "WallTop", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set the material for wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the top wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallTop" );
nodePtr->attachObject( entityPtr ); // attach top wall to SceneNode
nodePtr->setPosition( 0, 70, 0 ); // set the top wall's position
nodePtr->setScale( 1.95, .05, .1 ); // set the top wall's size
} // end function createScene
// start a game of Pong
void Pong::run()
{
createScene(); // create the scene
rootPtr->startRendering(); // start rendering frames
} // end function run
// update the score
void Pong::updateScore( Players player )
{
// increase the correct player's score
if ( player == Players::PLAYER1 )
player1Score++;
else
player2Score++;
wait = true; // the game should wait to restart the Ball
updateScoreText(); // update the score text on the screen
} // end function updateScore
// update the score text
void Pong::updateScoreText()
{
ostringstream scoreText; // text to be displayed
scoreText << "P2: " << player2Score; // make the text
// get the right player's TextArea
OverlayElement *textElementPtr =
OverlayManager::getSingletonPtr()->getOverlayElement( "right" );
textElementPtr->setCaption( scoreText.str() ); // set the text
scoreText.str( "" ); // reset the text in scoreText
scoreText << "P1: " << player1Score; // make the text
// get the left player's TextArea
textElementPtr =
OverlayManager::getSingletonPtr()->getOverlayElement( "left" );
textElementPtr->setCaption( scoreText.str() ); // set the text
} // end function updateScoreText
// respond to user keyboard input
bool Pong::keyPressed( const OIS::KeyEvent &keyEventRef )
{
// if the game is not paused
if ( !pause )
{
// process KeyEvents that apply when the game is not paused
switch ( keyEventRef.key )
{
case OIS::KC_ESCAPE: // escape key hit: quit
quit = true;
break;
case OIS::KC_UP: // up-arrow key hit: move the right Paddle up
rightPaddlePtr->movePaddle( PADDLE_UP );
break;
case OIS::KC_DOWN: // down-arrow key hit: move the right Paddle down
rightPaddlePtr->movePaddle( PADDLE_DOWN );
break;
case OIS::KC_A: // A key hit: move left Paddle up
leftPaddlePtr->movePaddle( PADDLE_UP );
break;
case OIS::KC_Z: // Z key hit: move left Paddle down
leftPaddlePtr->movePaddle( PADDLE_DOWN );
break;
case OIS::KC_P: // P key hit: pause the game
pause = true; // set pause to true when the user pauses the game
Overlay *pauseOverlayPtr =
OverlayManager::getSingleton().getByName( "PauseOverlay" );
pauseOverlayPtr->show(); // show the pause Overlay
break;
} // end switch
} // end if
else // game is paused
{
// user hit 'R' on the keyboard
if ( keyEventRef.key == OIS::KC_R )
{
pause = false; // set pause to false when user resumes the game
Overlay *pauseOverlayPtr =
OverlayManager::getSingleton().getByName( "PauseOverlay" );
pauseOverlayPtr->hide(); // hide the pause Overlay
} // end if
} // end else
return true;
} // end function keyPressed
// process key released events
bool Pong::keyReleased( const OIS::KeyEvent &keyEventRef )
{
return true;
} // end function keyReleased
// return true if the program should render the next frame
bool Pong::frameEnded( const FrameEvent &frameEvent )
{
return !quit; // quit = false if the user hasn't quit yet
} // end function frameEnded
// process game logic, return true if the next frame should be rendered
bool Pong::frameStarted( const FrameEvent &frameEvent )
{
keyboardPtr->capture(); // get keyboard events
// the game is not paused and the Ball should move
if ( !wait && !pause )
{
// move the Ball
ballPtr->moveBall( frameEvent.timeSinceLastFrame );
} // end if
// don't move the Ball if wait is true
else if ( wait )
{
// increase time if it is less than 4 seconds
if ( time < 4 )
// add the seconds since the last frame
time += frameEvent.timeSinceLastFrame;
else
{
wait = false; // shouldn't wait to move the Ball any more
time = 0; // reset the control variable to 0
} // end else
} // end else
return !quit; // quit = false if the user hasn't quit yet
} // end function frameStarted
@@ -0,0 +1,65 @@
// Pong.h
// Pong class definition (represents a game of Pong).
#ifndef PONG_H
#define PONG_H
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
#include <OIS\OISEvents.h> // OISEvents class definition
#include <OIS\OISInputManager.h> // OISInputManager class definition
#include <OIS\OISKeyboard.h> // OISKeyboard class definition
class Ball; // forward declaration of class Ball
class Paddle; // forward declaration of class Paddle
enum Players { PLAYER1, PLAYER2 };
class Pong : public FrameListener, public OIS::KeyListener
{
public:
Pong(); // constructor
~Pong(); // destructor
void run(); // run a game of Pong
// handle keyPressed and keyReleased events
bool keyPressed( const OIS::KeyEvent &keyEventRef );
bool keyReleased( const OIS::KeyEvent &keyEventRef );
// move the game objects and control interactions between frames
virtual bool frameStarted( const FrameEvent &frameEvent );
virtual bool frameEnded( const FrameEvent &frameEvent );
static void updateScore( Players player); // update the score
private:
void createScene(); // create the scene to be rendered
static void updateScoreText(); // update the score on the screen
// Ogre objects
Root *rootPtr; // pointer to Ogre's Root object
SceneManager *sceneManagerPtr; // pointer to the SceneManager
RenderWindow *windowPtr; // pointer to RenderWindow to render scene in
Viewport *viewportPtr; // pointer to Viewport, area that a camera sees
Camera *cameraPtr; // pointer to a Camera in the scene
// OIS input objects
OIS::InputManager *inputManagerPtr; // pointer to the InputManager
OIS::Keyboard *keyboardPtr; // pointer to the Keyboard
// game objects
Ball *ballPtr; // pointer to the Ball
Paddle *leftPaddlePtr; // pointer to player 1's Paddle
Paddle *rightPaddlePtr; // pointer to player 2's Paddle
// variables to control game states
bool quit, pause; // did user quit or pause the game?
Real time; // used to delay the motion of a new Ball
static bool wait; // should the Ball's movement be delayed?
static int player1Score; // player 1's score
static int player2Score; // player 2's score
}; // end class Pong
#endif // PONG_H
@@ -0,0 +1,37 @@
// PongMain.cpp
// Driver program for the game of Pong
#include <iostream>
#include "Pong.h" // Pong class definition
// If running on Windows, include windows.h and define WinMain function
#if OGRE_PLATFORM==PLATFORM_WIN32 || OGRE_PLATFORM==OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
// If not, define normal main function
#else
int main( int argc, char **argv )
#endif
{
try
{
Pong game; // create a Pong object
game.run(); // start the Pong game
} // end try
catch ( std::runtime_error &error )
{
#if OGRE_PLATFORM==PLATFORM_WIN32 || OGRE_PLATFORM==OGRE_PLATFORM_WIN32
MessageBoxA( NULL, error.what(), "Exception Thrown!",
MB_OK | MB_ICONERROR | MB_TASKMODAL );
#else
std::cerr << "Exception Thrown: " << error.what() << std::endl;
#endif
} // end catch
return 0;
} // end main
@@ -0,0 +1,19 @@
Render System=OpenGL Rendering Subsystem
[Direct3D9 Rendering Subsystem]
Allow NVPerfHUD=No
Anti aliasing=None
Floating-point mode=Fastest
Full Screen=Yes
Rendering Device=NVIDIA GeForce GTX 460
VSync=No
Video Mode=1280 x 1024 @ 32-bit colour
[OpenGL Rendering Subsystem]
Colour Depth=32
Display Frequency=N/A
FSAA=16
Full Screen=No
RTT Preferred Mode=PBuffer
VSync=Yes
Video Mode=1024 x 768
@@ -0,0 +1,24 @@
# Resource locations to be added to the 'boostrap' path
# This also contains the minimum you need to use the Ogre example framework
[Bootstrap]
FileSystem=resources
Zip=../../media/packs/OgreCore.zip
# Resource locations to be added to the default path
[General]
FileSystem=../../media
FileSystem=../../media/fonts
FileSystem=../../media/materials/programs
FileSystem=../../media/materials/scripts
FileSystem=../../media/materials/textures
FileSystem=../../media/models
FileSystem=../../media/overlays
FileSystem=../../media/particle
FileSystem=../../media/gui
FileSystem=../../media/DeferredShadingMedia
Zip=../../media/packs/cubemap.zip
Zip=../../media/packs/cubemapsJS.zip
Zip=../../media/packs/dragon.zip
Zip=../../media/packs/fresneldemo.zip
Zip=../../media/packs/ogretestmap.zip
Zip=../../media/packs/skybox.zip
@@ -0,0 +1,15 @@
// define the BlueBold font
BlueBold
{
// define the font type
type truetype
// set the source file for the font
source bluebold.ttf
// set the font size
size 16
// set the font resolution (96 is standard)
resolution 96
}
@@ -0,0 +1,12 @@
// menu material definition
material menu
{
technique
{
pass
{
ambient 1.0 1.0 1.0
diffuse 1.0 1.0 1.0
}
}
}
@@ -0,0 +1,167 @@
// An Overlay to display an options menu
MenuOverlay
{
// set a high z-order to display on top of everything
zorder 600
// the root container for the menu items
container Panel(rootPanel)
{
material menu
// text for the root Panel
element TextArea(instructionsText)
{
// position the text toward the bottom center of the screen
top 0.8
left 0.2
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Press Enter to start or Esc to exit
}
// end of instructionsText
// container for the Ball options
container Panel(ballPanel)
{
// position the container toward the left side of the screen
top 0.1
left 0.1
width 0.3
height 0.5
// TextAreas to display Ball options
element TextArea(ballOptionsTitle)
{
// position and size the TextArea
height 0.1
left 0.05
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Ball Options
}
// end of ballOptionsTitle
element TextArea(ballSlow)
{
// position and size the text
top 0.2
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Slow Ball (Press A)
}
// end of ballSlow
element TextArea(ballMedium)
{
// position and size the text
top 0.3
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 1.0 0 0
caption Medium Ball (Press B)
}
// end of ballMedium
element TextArea(ballFast)
{
// position and size the text
top 0.4
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Fast Ball (Press C)
}
// end of ballFast
}
// end of ballPanel
// container for the Paddle options
container Panel(paddlePanel)
{
// position the container toward the right side of the screen
top 0.1
left 0.5
width 0.3
height 0.5
// TextAreas to display Paddle options
element TextArea(paddleOptionsTitle)
{
// position and size the text
height 0.1
left 0.05
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Paddle Options
}
// end of paddleOptionsTitle
element TextArea(paddleSlow)
{
// position and size the text
top 0.2
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Slow Paddles (Press 1)
}
// end of paddleSlow
element TextArea(paddleMedium)
{
// position and size the text
top 0.3
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 1.0
caption Medium Paddles (Press 2)
}
// end of paddleMedium
element TextArea(paddleFast)
{
// position and size the text
top 0.4
height 0.1
// set font use for caption and set the size and color
font_name BlueBold
char_height .05
colour 0 0 0
caption Fast Paddles (Press 3)
}
// end of paddleFast
}
// end of paddlePanel
}
// end of rootPanel
}
// end of MenuOverlay
@@ -0,0 +1,51 @@
// ball material definition
material ball
{
// define one technique for rendering the Ball
technique
{
// render the Ball in one pass
pass
{
// color the Ball violet
ambient 0.58 0 0.827
diffuse 0.58 0 0.827
specular 0.58 0 0.827 120
}
}
}
// paddle material definition
material paddle
{
// define one technique for rendering a Paddle
technique
{
// render a Paddle in one pass
pass
{
// color the Paddle dark orange
ambient 1 0.549 0
diffuse 1 0.549 0
specular 1 0.549 0 120
}
}
}
// wall material definition
material wall
{
// define one technique for rendering a wall
technique
{
// render a wall in one pass
pass
{
// color the wall cyan
ambient 0 0 0
diffuse 0 0 0
specular 0 0 0 120
}
}
}
@@ -0,0 +1,146 @@
// An Overlay to display the score
Score
{
// set a high z-order, displays on top of anything with lower z-order
zorder 500
// create a PanelOverlayElement container to hold the text areas
container Panel(ScorePanel)
{
// use relative metrics mode to position this container at the
// top-left corner of the screen
metrics_mode relative
left 0.0
top 0.0
// make it 1/10 the height and the full width of the screen
width 1.0
height .1
// create a TextAreaOverlayElement to display player 1's score
element TextArea(left)
{
// position and size the element relative to the container
metrics_mode relative
// position it at the top of the container 5% from the left and
// make it the same height and half as long as the container
left 0.05
top 0.0
width 0.5
height 1.0
// set font use for caption and set the size and color
font_name PongScore
char_height .05
colour 1.0 0 0
caption P1: 0
}
// create a TextAreaOverlayElement to display player 2's score
element TextArea(right)
{
// position and size the element relative to the container
metrics_mode relative
// position it at the top of the container 69% from the left and
// make it the same height as the container, stretch to the end
left 0.69
top 0.0
width 0.5
height 1.0
// set font use for caption and set the size and color
font_name PongScore
char_height 0.05
colour 1.0 0 0
caption P2: 0
}
}
}
// An Overlay to display "Game Paused" when the player pauses the game
PauseOverlay
{
// set a high z-order, displays on top of anything with lower z-order
zorder 500
// create a PanelOverlayElement container to hold the text area
container Panel(Pause)
{
// use relative metrics mode to position and size this container
metrics_mode relative
// place the container at the top-left corner of the window
left 0.0
top 0.0
// make the container the same size as the window
width 1.0
height 1.0
// create a TextAreaOverlayElement to display the text
element TextArea(pauseText)
{
// position and size the element relative to its container
metrics_mode relative
// center it vertically in the container
vert_align center
// put the left corner 4/10 from the left of the container and
// make it 2/10 the width of the container and 1/10 the height
left 0.4
width 0.2
height 0.1
// set font use for caption and set the size and color
font_name PongText
char_height 0.05
colour 0 0 0
caption Game Paused
}
}
}
// An Overlay to display which player won the game
WinnerOverlay
{
// set a high z-order, displays on top of anything with lower z-order
zorder 500
// create a PanelOverlayElement container to hold the text area
container Panel(Winner)
{
// use relative metrics mode to position and size this container
metrics_mode relative
// place the container at the top-left corner of the window
left 0.0
top 0.0
// make the container the same size as the window
width 1.0
height 1.0
// create a TextAreaOverlayElement to display the text
element TextArea(winnerText)
{
// position and size the element relative to its container
metrics_mode relative
// put the left corner 4/10 from the left of the container and
// make it 2/10 the width of the container and 1/10 the height
left 0.4
top 0.3
width 0.2
height 0.1
// set font use for caption and set the size and color
font_name PongText
char_height 0.05
colour 0 0 0
}
}
}
@@ -0,0 +1,15 @@
// define the PongScore font
PongScore
{
// define the font type
type truetype
// set the source file for the font
source PongScore.ttf
// set the font size
size 16
// set the font resolution (96 is standard)
resolution 96
}
@@ -0,0 +1,15 @@
// define the PongText font
PongText
{
// define the font type
type truetype
// set the source file for the font
source PongText.ttf
// set the font size
size 16
// set the font resolution (96 is standard)
resolution 96
}
@@ -0,0 +1,15 @@
// define the BlueBold font
BlueBold
{
// define the font type
type truetype
// set the source file for the font
source bluebold.ttf
// set the font size
size 16
// set the font resolution (96 is standard)
resolution 96
}
Loaded 100 of 606 files, more files were not shown because too many files have changed in this diff. Show more