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,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
}
@@ -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.545 0.545
diffuse 0 0.545 0.545
specular 0 0.545 0.545 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 BlueBold
char_height .05
colour 1.0 0 0
caption Player 1 Score: 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 BlueBold
char_height 0.05
colour 1.0 0 0
caption Player 2 Score: 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 BlueBold
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 BlueBold
char_height 0.05
colour 0 0 0
}
}
}