├── Assets
├── Actors
│ ├── afternoon_sky.xml
│ ├── ai_teapot.xml
│ ├── grid.xml
│ ├── light.xml
│ ├── music.xml
│ ├── player_teapot.xml
│ ├── remote_teapot.xml
│ └── sphere.xml
├── Art
│ ├── Grid.bmp
│ ├── Gridalpha.bmp
│ ├── Sky2_E.JPG
│ ├── Sky2_N.JPG
│ ├── Sky2_S.JPG
│ ├── Sky2_U.JPG
│ ├── Sky2_W.JPG
│ ├── Teapot.sdkmesh
│ ├── grid.dds
│ ├── grid_nomips.dds
│ ├── sphere.blend
│ ├── sphere.sdkmesh
│ ├── sphere.x
│ └── texture.dds
├── Audio
│ ├── Sources.txt
│ ├── SpaceGod7-Level2.ogg
│ ├── blip.ogg
│ ├── blip.wav
│ ├── blip16.wav
│ ├── computerbeep3.ogg
│ └── computerbeep3.wav
├── Config
│ └── physics.xml
├── Editor
│ └── components.xml
├── Effects
│ ├── GameCode4.fx
│ ├── GameCode4_PS.hlsl
│ ├── GameCode4_VS.hlsl
│ └── LineDraw.hlsl
├── Scripts
│ ├── ActorManager.lua
│ ├── DebugBrain.lua
│ ├── DecisionTreeBrain.lua
│ ├── Events.lua
│ ├── HardCodedBrain.lua
│ ├── LevelInit.lua
│ ├── LevelPostInit.lua
│ ├── PreInit.lua
│ ├── TeapotAi.lua
│ ├── TeapotBrains.lua
│ ├── TeapotStates.lua
│ ├── TeapotWars.deproj
│ └── test.lua
├── Strings
│ └── English.xml
└── World
│ ├── World.xml
│ └── WorldInstances.xml
├── COPYING.txt
├── Extra
└── UtilityDemo
│ ├── PreInit.lua
│ ├── UtilityDemo.deproj
│ ├── UtilityDemo.exe
│ └── utility.lua
├── Game
├── Assets.zip
├── EditorOptions.xml
├── Logging.xml
├── PlayerOptions.xml
└── UI
│ ├── DXUTShared.fx
│ ├── Font.dds
│ ├── arrow.x
│ └── dxutcontrols.dds
├── README.txt
└── Source
├── GCC4
├── AI
│ ├── Pathing.cpp
│ └── Pathing.h
├── Actors
│ ├── Actor.cpp
│ ├── Actor.h
│ ├── ActorComponent.h
│ ├── ActorFactory.cpp
│ ├── ActorFactory.h
│ ├── AmmoPickup.cpp
│ ├── AmmoPickup.h
│ ├── AudioComponent.cpp
│ ├── AudioComponent.h
│ ├── BaseScriptComponent.cpp
│ ├── BaseScriptComponent.h
│ ├── HealthPickup.cpp
│ ├── HealthPickup.h
│ ├── PhysicsComponent.cpp
│ ├── PhysicsComponent.h
│ ├── PickupInterface.h
│ ├── RenderComponent.cpp
│ ├── RenderComponent.h
│ ├── RenderComponentInterface.h
│ ├── ScriptComponentInterface.h
│ ├── TransformComponent.cpp
│ └── TransformComponent.h
├── Audio
│ ├── Audio.cpp
│ ├── Audio.h
│ ├── DirectSoundAudio.cpp
│ ├── DirectSoundAudio.h
│ ├── SoundProcess.cpp
│ ├── SoundProcess.h
│ ├── SoundResource.cpp
│ └── SoundResource.h
├── Debugging
│ ├── Debugging.cpp
│ ├── Logger.cpp
│ ├── Logger.h
│ ├── MemoryWatcher.h
│ ├── MiniDump.cpp
│ └── MiniDump.h
├── EventManager
│ ├── EventManager.cpp
│ ├── EventManager.h
│ ├── EventManagerImpl.cpp
│ ├── EventManagerImpl.h
│ ├── Events.cpp
│ └── Events.h
├── GameCode4
│ ├── BaseGameLogic.cpp
│ ├── BaseGameLogic.h
│ ├── GameCode.cpp
│ ├── GameCode.h
│ ├── GameCode4.cpp
│ └── interfaces.h
├── Graphics2D
│ ├── Font.cpp
│ ├── Font.h
│ ├── Sprite.cpp
│ └── Sprite.h
├── Graphics3D
│ ├── D3DRenderer.cpp
│ ├── D3DRenderer.h
│ ├── Geometry.cpp
│ ├── Geometry.h
│ ├── Lights.cpp
│ ├── Lights.h
│ ├── Material.cpp
│ ├── Material.h
│ ├── Mesh.cpp
│ ├── Mesh.h
│ ├── MovementController.cpp
│ ├── MovementController.h
│ ├── Raycast.cpp
│ ├── Raycast.h
│ ├── Scene.cpp
│ ├── Scene.h
│ ├── SceneNodes.cpp
│ ├── SceneNodes.h
│ ├── Shaders.cpp
│ ├── Shaders.h
│ ├── Sky.cpp
│ └── Sky.h
├── LUAScripting
│ ├── LuaStateManager.cpp
│ ├── LuaStateManager.h
│ ├── ScriptEvent.cpp
│ ├── ScriptEvent.h
│ ├── ScriptEventListener.cpp
│ ├── ScriptEventListener.h
│ ├── ScriptExports.cpp
│ ├── ScriptExports.h
│ ├── ScriptProcess.cpp
│ ├── ScriptProcess.h
│ ├── ScriptResource.cpp
│ └── ScriptResource.h
├── Mainloop
│ ├── Initialization.cpp
│ ├── Initialization.h
│ ├── Process.cpp
│ ├── Process.h
│ ├── ProcessManager.cpp
│ └── ProcessManager.h
├── Memory
│ ├── MemoryMacros.h
│ ├── MemoryPool.cpp
│ └── MemoryPool.h
├── Msvc
│ ├── GameCode.ico
│ ├── GameCode4_2015.cpp
│ ├── GameCode4_2015.h
│ ├── GameCode4_2015.ico
│ ├── GameCode4_2015.rc
│ ├── GameCode4_2015.sln
│ ├── GameCode4_2015.vcxproj
│ ├── GameCode4_2015.vcxproj.filters
│ ├── GameCode4_2015.vcxproj.user
│ ├── GameCodeStd.cpp
│ ├── GameCodeStd.h
│ ├── ReadMe.txt
│ ├── Resource.h
│ ├── small.ico
│ └── targetver.h
├── Multicore
│ ├── CriticalSection.h
│ ├── RealtimeProcess.cpp
│ ├── RealtimeProcess.h
│ └── SafeStream.h
├── Network
│ ├── Network.cpp
│ └── Network.h
├── Physics
│ ├── Physics.cpp
│ ├── Physics.h
│ ├── PhysicsDebugDrawer.cpp
│ ├── PhysicsDebugDrawer.h
│ ├── PhysicsEventListener.cpp
│ └── PhysicsEventListener.h
├── ResourceCache
│ ├── ResCache.cpp
│ ├── ResCache.h
│ ├── XmlResource.cpp
│ ├── XmlResource.h
│ ├── ZipFile.cpp
│ └── ZipFile.h
├── UserInterface
│ ├── HumanView.cpp
│ ├── HumanView.h
│ ├── MessageBox.cpp
│ ├── MessageBox.h
│ └── UserInterface.h
└── Utilities
│ ├── Math.cpp
│ ├── Math.h
│ ├── Math_Random.cpp
│ ├── PrimeSearch.cpp
│ ├── PrimeSearch.h
│ ├── String.cpp
│ ├── String.h
│ ├── templates.h
│ └── types.h
├── GCC4Editor
├── EditorApp
│ ├── ActorComponentEditor.cs
│ ├── ActorCreationForm.Designer.cs
│ ├── ActorCreationForm.cs
│ ├── ActorCreationForm.resx
│ ├── ActorPropertiesForm.Designer.cs
│ ├── ActorPropertiesForm.cs
│ ├── ActorPropertiesForm.resx
│ ├── EditorForm.Designer.cs
│ ├── EditorForm.cs
│ ├── EditorForm.resx
│ ├── EngineDisplayForm.Designer.cs
│ ├── EngineDisplayForm.cs
│ ├── EngineDisplayForm.resx
│ ├── GCC4EditorDLL_2015.dll
│ ├── MessageHandler.cs
│ ├── NativeMethods.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── TeapotWarsEditorApp_2015.csproj
│ ├── TeapotWarsEditorApp_2015.csproj.user
│ ├── XPathUtility.cs
│ ├── ZipFileUtility.cs
│ └── app.config
├── GCC4EditorDLL
│ ├── Editor.aps
│ ├── Editor.cpp
│ ├── Editor.h
│ ├── Editor.ico
│ ├── Editor.rc
│ ├── EditorGlobalFunctions.cpp
│ ├── EditorGlobalFunctions.h
│ ├── EditorHumanView.cpp
│ ├── EditorHumanView.h
│ └── resource.h
└── Msvc
│ ├── GCC4EditorDLL.cpp
│ ├── GCC4EditorDLL_2015.vcxproj
│ ├── GCC4EditorDLL_2015.vcxproj.filters
│ ├── GCC4EditorDLL_2015.vcxproj.user
│ ├── GCC4EditorStd.cpp
│ └── GCC4EditorStd.h
└── TeapotWars
├── Msvc
├── ReadMe.txt
├── Resource.h
├── TeapotResources.h
├── TeapotWars.h
├── TeapotWars.rc
├── TeapotWarsStd.cpp
├── TeapotWarsStd.h
├── TeapotWars_2015.cpp
├── TeapotWars_2015.h
├── TeapotWars_2015.ico
├── TeapotWars_2015.rc
├── TeapotWars_2015.sln
├── TeapotWars_2015.vcxproj
├── TeapotWars_2015.vcxproj.filters
├── TeapotWars_2015.vcxproj.user
├── small.ico
├── stdafx.cpp
├── stdafx.h
├── targetver.h
└── teapot.ico
├── TeapotController.cpp
├── TeapotController.h
├── TeapotEvents.cpp
├── TeapotEvents.h
├── TeapotWars.cpp
├── TeapotWarsNetwork.h
├── TeapotWarsView.cpp
└── TeapotWarsView.h
/Assets/Actors/afternoon_sky.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | art\sky2_n.JPG
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Assets/Actors/ai_teapot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Box
11 | glass
12 | Normal
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Assets/Actors/grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Box
10 | Infinite
11 | Normal
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | art\grid.dds
20 | 100
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Assets/Actors/light.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Assets/Actors/music.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | audio\spacegod7-level2.ogg
4 | 1
5 | 5.0
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Assets/Actors/player_teapot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Box
10 | glass
11 | Normal
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Assets/Actors/remote_teapot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Box
10 | glass
11 | Normal
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/Assets/Actors/sphere.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Sphere
9 | pine
10 | Bouncy
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Assets/Art/Grid.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Grid.bmp
--------------------------------------------------------------------------------
/Assets/Art/Sky2_E.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Sky2_E.JPG
--------------------------------------------------------------------------------
/Assets/Art/Sky2_N.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Sky2_N.JPG
--------------------------------------------------------------------------------
/Assets/Art/Sky2_S.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Sky2_S.JPG
--------------------------------------------------------------------------------
/Assets/Art/Sky2_U.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Sky2_U.JPG
--------------------------------------------------------------------------------
/Assets/Art/Sky2_W.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Sky2_W.JPG
--------------------------------------------------------------------------------
/Assets/Art/Teapot.sdkmesh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/Teapot.sdkmesh
--------------------------------------------------------------------------------
/Assets/Art/grid.dds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/grid.dds
--------------------------------------------------------------------------------
/Assets/Art/grid_nomips.dds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/grid_nomips.dds
--------------------------------------------------------------------------------
/Assets/Art/sphere.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/sphere.blend
--------------------------------------------------------------------------------
/Assets/Art/sphere.sdkmesh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/sphere.sdkmesh
--------------------------------------------------------------------------------
/Assets/Art/texture.dds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Art/texture.dds
--------------------------------------------------------------------------------
/Assets/Audio/Sources.txt:
--------------------------------------------------------------------------------
1 | blip.wav http://www.a1freesoundeffects.com/ Downloaded Wed, June 23, 2004
2 | computerbeep3.wav http://www.a1freesoundeffects.com/ Downloaded Wed, June 23, 2004
3 | SpaceGod7-Level2.mp3 http://www.themysterioush.net/ Submitted by the Artist known as 'the mysterious h'
--------------------------------------------------------------------------------
/Assets/Audio/SpaceGod7-Level2.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/SpaceGod7-Level2.ogg
--------------------------------------------------------------------------------
/Assets/Audio/blip.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/blip.ogg
--------------------------------------------------------------------------------
/Assets/Audio/blip.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/blip.wav
--------------------------------------------------------------------------------
/Assets/Audio/blip16.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/blip16.wav
--------------------------------------------------------------------------------
/Assets/Audio/computerbeep3.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/computerbeep3.ogg
--------------------------------------------------------------------------------
/Assets/Audio/computerbeep3.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Assets/Audio/computerbeep3.wav
--------------------------------------------------------------------------------
/Assets/Config/physics.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
17 | 0.0013
18 | 1.000
19 |
20 |
21 | 0.0100
22 |
23 |
24 | 0.0170
25 | 0.3500
26 | 0.5000
27 | 0.8300
28 | 1.100
29 |
30 |
31 | 1.060
32 | 1.800
33 |
34 |
35 | 2.400
36 | 2.650
37 | 2.450
38 | 4.500
39 | 3.350
40 | 9.800
41 | 1.750
42 | 2.320
43 | 8.550
44 | 8.640
45 | 8.400
46 | 4.580
47 | 1.950
48 | 7.100
49 | 2.200
50 | 0.800
51 | 8.900
52 | 8.750
53 | 3.510
54 | 2.900
55 | 1.800
56 | 2.600
57 | 2.950
58 | 2.550
59 | 19.30
60 | 5.200
61 | 21.60
62 | 7.200
63 | 7.750
64 | 2.400
65 | 11.34
66 | 3.200
67 | 7.420
68 | 1.740
69 | 2.720
70 | 13.54
71 | 10.20
72 | 8.900
73 | 21.45
74 | 0.860
75 | 2.650
76 | 2.300
77 | 2.750
78 | 10.50
79 | 0.970
80 | 7.800
81 | 2.700
82 | 1.200
83 | 6.120
84 | 7.350
85 | 4.500
86 | 19.22
87 | 18.70
88 | 5.960
89 | 1.800
90 | 1.320
91 | 7.050
92 |
93 | 0.000
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Assets/Editor/components.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Assets/Effects/GameCode4_PS.hlsl:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: GameCode4_PS.hlsl - the pixel shader for GameCode4 (D3D11 renderer)
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //--------------------------------------------------------------------------------------
38 |
39 | //--------------------------------------------------------------------------------------
40 | // Globals
41 | //--------------------------------------------------------------------------------------
42 | cbuffer cbObjectColors : register( b0 )
43 | {
44 | float4 g_vDiffuseObjectColor : packoffset( c0 );
45 | float4 g_vAmbientObjectColor : packoffset( c1 );
46 | bool g_bHasTexture : packoffset( c2.x );
47 | };
48 |
49 |
50 |
51 | //--------------------------------------------------------------------------------------
52 | // Textures and Samplers
53 | //--------------------------------------------------------------------------------------
54 | Texture2D g_txDiffuse : register( t0 );
55 | SamplerState g_samLinear : register( s0 );
56 |
57 | //--------------------------------------------------------------------------------------
58 | // Input / Output structures
59 | //--------------------------------------------------------------------------------------
60 | struct PS_INPUT
61 | {
62 | float4 vDiffuse : COLOR0;
63 | float2 vTexcoord : TEXCOORD0;
64 | };
65 |
66 | //--------------------------------------------------------------------------------------
67 | // Pixel Shader
68 | //--------------------------------------------------------------------------------------
69 | float4 GameCode4_PSMain( PS_INPUT Input ) : SV_TARGET
70 | {
71 | float4 vOutputColor;
72 |
73 | if (g_bHasTexture)
74 | vOutputColor = g_txDiffuse.Sample( g_samLinear, Input.vTexcoord ) * Input.vDiffuse;
75 | else
76 | vOutputColor = Input.vDiffuse;
77 |
78 | return vOutputColor;
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/Assets/Scripts/DebugBrain.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- DebugBrain.lua : A brain for debugging the AI
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("Scripts\\TeapotBrains.lua");
40 | require("Scripts\\TeapotStates.lua");
41 |
42 | -----------------------------------------------------------------------------------------------------------------------
43 | -- DebugBrain
44 | -- This is a brain used for debugging. If you want to lock the teapot into doing just a single thing to debug some
45 | -- action or state, this is the brain to use.
46 | -----------------------------------------------------------------------------------------------------------------------
47 | DebugBrain = class(TeapotBrain,
48 | {
49 | --
50 | });
51 |
52 | function DebugBrain:Think()
53 | return WatchPlayerState;
54 | end
55 |
56 |
--------------------------------------------------------------------------------
/Assets/Scripts/Events.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- Events.lua : Defines event handler delegate functions for events
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | function OnPhysicsCollision(eventData)
40 | g_actorMgr:OnPhysicsCollision(eventData);
41 | end
42 |
43 | function OnFireWeapon(eventData)
44 | g_actorMgr:OnFireWeapon(eventData);
45 | end
46 |
47 | function RegisterListeners()
48 | if (EventType.EvtData_PhysCollision ~= nil) then
49 | RegisterEventListener(EventType.EvtData_PhysCollision, OnPhysicsCollision);
50 | end
51 |
52 | if (EventType.EvtData_Fire_Weapon ~= nil) then
53 | RegisterEventListener(EventType.EvtData_Fire_Weapon, OnFireWeapon);
54 | end
55 | end
56 |
57 |
--------------------------------------------------------------------------------
/Assets/Scripts/HardCodedBrain.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- HardCodedBrain.lua : Implements a brain using hard-coded logic
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("Scripts\\TeapotBrains.lua");
40 | require("Scripts\\TeapotStates.lua");
41 |
42 | -----------------------------------------------------------------------------------------------------------------------
43 | -- HardCodedBrain - Chapter 18, page 620
44 | -- This is the hard-coded brain. It just takes what it needs from the gamestate and does some simple hard-coded logic
45 | -- to find the appropriate state.
46 | -----------------------------------------------------------------------------------------------------------------------
47 | HardCodedBrain = class(TeapotBrain,
48 | {
49 | --
50 | });
51 |
52 | function HardCodedBrain:Think()
53 | local playerPos = Vec3:Create(g_actorMgr:GetPlayer():GetPos());
54 | local pos = Vec3:Create(self._teapot:GetPos());
55 | local diff = playerPos - pos;
56 |
57 | -- player close
58 | if (diff:Length() < 20) then
59 | -- hit points low, run
60 | if (self._teapot.hitPoints <= 1) then
61 | return RunAwayState;
62 | -- hit points not low, attack
63 | else
64 | return AttackState;
65 | end
66 |
67 | -- player not close, resume patrol
68 | else
69 | return PatrolState;
70 | end
71 |
72 | end
73 |
74 |
--------------------------------------------------------------------------------
/Assets/Scripts/LevelInit.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- LevelInit.lua : A script that's executed when the level is initializing
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("scripts\\ActorManager.lua");
40 |
41 | -----------------------------------------------------------------------------------------------------------------------
42 | -- Global actor manager - Chapter 21, page 738
43 | -----------------------------------------------------------------------------------------------------------------------
44 | g_actorMgr = ActorManager:Create();
45 |
46 |
47 | -----------------------------------------------------------------------------------------------------------------------
48 | -- constructor / destructor functions for actors
49 | -----------------------------------------------------------------------------------------------------------------------
50 | function AddPlayer(scriptObject)
51 | g_actorMgr:AddPlayer(scriptObject);
52 | end
53 |
54 | function RemovePlayer(scriptObject)
55 | g_actorMgr:RemovePlayer(scriptObject);
56 | end
57 |
58 | function AddEnemy(scriptObject)
59 | g_actorMgr:AddEnemy(scriptObject);
60 | end
61 |
62 | function RemoveEnemy(scriptObject)
63 | g_actorMgr:RemoveEnemy(scriptObject);
64 | end
65 |
66 | function AddSphere(scriptObject)
67 | g_actorMgr:AddSphere(scriptObject);
68 | end
69 |
70 | function RemoveSphere(scriptObject)
71 | g_actorMgr:RemoveSphere(scriptObject);
72 | end
73 |
74 |
75 | -----------------------------------------------------------------------------------------------------------------------
76 | -- Debug stuff
77 | -----------------------------------------------------------------------------------------------------------------------
78 | function ShowPlayerOrientation()
79 | print("Player Orientation: " .. g_actorMgr:GetPlayer():GetYOrientationRadians());
80 | end
81 |
82 | function SetPlayerOrientation(radians)
83 | g_actorMgr:GetPlayer():RotateY(radians);
84 | end
85 |
86 |
--------------------------------------------------------------------------------
/Assets/Scripts/LevelPostInit.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- ActorManager.lua : Executed after initializing the level
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("scripts\\Events.lua");
40 |
41 | RegisterListeners();
42 |
43 |
--------------------------------------------------------------------------------
/Assets/Scripts/TeapotAi.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- TeapotAi.lua : Defines the state machine for AI teapots
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("Scripts\\TeapotStates.lua");
40 | require("Scripts\\TeapotBrains.lua");
41 |
42 | -----------------------------------------------------------------------------------------------------------------------
43 | -- State machine - Chapter 18, page 616
44 | -----------------------------------------------------------------------------------------------------------------------
45 | TeapotStateMachine = class(nil,
46 | {
47 | _teapot = nil,
48 | _currentState = nil,
49 | _brain = nil,
50 | });
51 |
52 | function TeapotStateMachine:Destroy()
53 | self._currentState = nil;
54 | self._brain = nil;
55 | end
56 |
57 | function TeapotStateMachine:SetState(newState)
58 | if (self._currentState == nil or not self._currentState:IsInstance(newState)) then
59 | self:_InternalSetState(newState);
60 | end
61 | end
62 |
63 | function TeapotStateMachine:ChooseBestState()
64 | if (self._brain) then
65 | local newState = self._brain:Think();
66 |
67 | if (newState ~= nil) then
68 | print("Teapot chose " .. newState.name);
69 | else
70 | print("Teapot chose nil");
71 | end
72 |
73 | self:SetState(newState);
74 | end
75 | end
76 |
77 | function TeapotStateMachine:Update(deltaMs)
78 | if (self._currentState) then
79 | self._currentState:Update(deltaMs);
80 | end
81 | end
82 |
83 | function TeapotStateMachine:_InternalSetState(newState)
84 | self._currentState = newState:Create({_teapot = self._teapot});
85 | self._currentState:Init();
86 | end
87 |
88 |
--------------------------------------------------------------------------------
/Assets/Scripts/TeapotBrains.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- TeapotBrains.lua : Base class for teapot brains
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | require("Scripts\\TeapotStates.lua");
40 |
41 |
42 | -----------------------------------------------------------------------------------------------------------------------
43 | -- TeapotBrain base class
44 | -- This is the base class for teapot brains. It defines the interface for all decision making that teapots can do.
45 | -- the Think() function is called from the TeapotStateMachine.UpdateState() function whenever a decision needs to be
46 | -- made. It returns a new state for the teapot. Note how the base class throws an error. This is the closest we can
47 | -- get to a pure virtual function; it defines the interface and requires subclasses to define the implementation.
48 | -- It's not perfect, but it beats the generic "attempting to call nil value" error.
49 | -----------------------------------------------------------------------------------------------------------------------
50 | TeapotBrain = class(nil,
51 | {
52 | _teapot = nil,
53 | });
54 |
55 | function TeapotBrain:Init()
56 | return true;
57 | end
58 |
59 | function TeapotBrain:Think()
60 | error("Calling unimplemented base class version of TeapotBrain.Think()");
61 | end
62 |
63 |
--------------------------------------------------------------------------------
/Assets/Scripts/TeapotWars.deproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ActorManager.lua
5 |
6 |
7 | DebugBrain.lua
8 |
9 |
10 | DecisionTreeBrain.lua
11 |
12 |
13 | Events.lua
14 |
15 |
16 | HardCodedBrain.lua
17 |
18 |
19 | LevelInit.lua
20 |
21 |
22 | LevelPostInit.lua
23 |
24 |
25 | PreInit.lua
26 |
27 |
28 | TeapotAi.lua
29 |
30 |
31 | TeapotBrains.lua
32 |
33 |
34 | TeapotStates.lua
35 |
36 |
37 | test.lua
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Assets/Scripts/test.lua:
--------------------------------------------------------------------------------
1 | --========================================================================
2 | -- tests.lua : General testing & debugging functions
3 | --
4 | -- Part of the GameCode4 Application
5 | --
6 | -- GameCode4 is the sample application that encapsulates much of the source code
7 | -- discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | -- "Rez" Graham, published by Charles River Media.
9 | -- ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | --
11 | -- If this source code has found it's way to you, and you think it has helped you
12 | -- in any way, do the authors a favor and buy a new copy of the book - there are
13 | -- detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | -- by clicking here:
15 | -- http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | --
17 | -- There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | --
19 | -- The source code is managed and maintained through Google Code:
20 | -- http://code.google.com/p/gamecode4/
21 | --
22 | -- (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | --
24 | -- This program is free software; you can redistribute it and/or
25 | -- modify it under the terms of the GNU Lesser GPL v3
26 | -- as published by the Free Software Foundation.
27 | --
28 | -- This program is distributed in the hope that it will be useful,
29 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | -- http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | --
33 | -- You should have received a copy of the GNU Lesser GPL v3
34 | -- along with this program; if not, write to the Free Software
35 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | --
37 | --========================================================================
38 |
39 | print("Loading script");
40 |
41 | function TestEventHandler(eventData)
42 | print("Event Received in Lua: " .. eventData);
43 | eventData = eventData + 1;
44 | QueueEvent(EventType.EvtData_ScriptEventTest_FromLua, eventData);
45 | end
46 |
47 | function RegisterListener()
48 | RegisterEventListener(EventType.EvtData_ScriptEventTest_ToLua, TestEventHandler);
49 | end
50 |
51 |
52 |
53 | TestScriptProcess = class(ScriptProcess,
54 | {
55 | count = 0;
56 | });
57 |
58 | function TestScriptProcess:OnInit()
59 | print("OnInit()");
60 | end
61 |
62 | function TestScriptProcess:OnUpdate(deltaMs)
63 | self.count = self.count + 1;
64 | print("Count: " .. self.count);
65 |
66 | if self.count >= 5 then
67 | self:Succeed();
68 | end
69 | end
70 |
71 | function TestScriptProcess:OnSuccess()
72 | print("Success!!");
73 | end
74 |
75 | function TestScriptProcess:OnFail()
76 | print("Something failed");
77 | end
78 |
79 |
80 |
81 | function TestProcess()
82 | parent = TestScriptProcess:Create({frequency = 1000});
83 | child = TestScriptProcess:Create({frequency = 500});
84 | parent:AttachChild(child);
85 | AttachProcess(parent);
86 | end
87 |
88 | RegisterListener();
89 |
90 | print("Script loaded");
91 |
92 |
--------------------------------------------------------------------------------
/Assets/Strings/English.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Assets/World/World.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Assets/World/WorldInstances.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 | 100
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 10
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Extra/UtilityDemo/PreInit.lua:
--------------------------------------------------------------------------------
1 | -- PreInit.lua
2 | -- Note: This file only defines the class() function from assets\scripts\PreInit.lua. The other stuff isn't needed
3 | -- for this simple demo.
4 |
5 | -----------------------------------------------------------------------------------------------------------------------
6 | -- Classes & Inheritance
7 | -----------------------------------------------------------------------------------------------------------------------
8 | function class(baseClass, body)
9 | local ret = body or {};
10 |
11 | -- if there's a base class, attach our new class to it
12 | if (baseClass ~= nil) then
13 | setmetatable(ret, ret);
14 | ret.__index = baseClass;
15 | ret.base = baseClass;
16 | end
17 |
18 | -- Add the Create() function. This will end up being added to each subclass which isn't ideal. This
19 | -- function should probably be stored in a single place so we only have to create it once.
20 | -- -self: The self pointer that's calling this function.
21 | -- -constructionData: The table sent in as construction data. Think of it like a constructor.
22 | -- -originalSubClass: Used for recursion. Don't pass anything into this parameter, it's filled
23 | -- automatically. It's used in case the C++ side needs access to the leaf
24 | -- subclass that is being instantiated. For an example, see ScriptProcess
25 | -- in C++.
26 | ret.Create = function(self, constructionData, originalSubClass)
27 | local obj;
28 | if (self.__index ~= nil) then
29 | if (originalSubClass ~= nil) then
30 | obj = self.__index:Create(constructionData, originalSubClass);
31 | else
32 | obj = self.__index:Create(constructionData, self);
33 | end
34 | else
35 | obj = constructionData or {};
36 | end
37 |
38 | setmetatable(obj, obj);
39 | obj.__index = self;
40 |
41 | -- copy any operators over
42 | if (self.__operators ~= nil) then
43 | for key, val in pairs(self.__operators) do
44 | obj[key] = val;
45 | end
46 | end
47 |
48 | return obj;
49 | end
50 |
51 | -- Returns true if otherClass appears in this objects class hierarchy anywhere.
52 | ret.IsInstance = function(self, otherClass)
53 | local cls = self.__index;
54 | while cls do
55 | if cls == otherClass then
56 | return true
57 | end
58 | cls = cls.base
59 | end
60 | return false
61 | end
62 |
63 | return ret;
64 | end
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Extra/UtilityDemo/UtilityDemo.deproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PreInit.lua
5 |
6 |
7 | utility.lua
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Extra/UtilityDemo/UtilityDemo.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Extra/UtilityDemo/UtilityDemo.exe
--------------------------------------------------------------------------------
/Game/Assets.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Game/Assets.zip
--------------------------------------------------------------------------------
/Game/EditorOptions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Game/Logging.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Game/PlayerOptions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Game/UI/DXUTShared.fx:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------------------------
2 | // File: DXUTShared.fx
3 | //
4 | //
5 | //
6 | // Copyright (c) Microsoft Corporation. All rights reserved.
7 | //--------------------------------------------------------------------------------------
8 |
9 |
10 | //--------------------------------------------------------------------------------------
11 | // Global variables
12 | //--------------------------------------------------------------------------------------
13 | float4 g_MaterialDiffuseColor; // Material's diffuse color
14 | float3 g_LightDir; // Light's direction in world space
15 | float4x4 g_mWorld; // World matrix for object
16 | float4x4 g_mWorldViewProjection; // World * View * Projection matrix
17 |
18 |
19 |
20 | //--------------------------------------------------------------------------------------
21 | // Vertex shader output structure
22 | //--------------------------------------------------------------------------------------
23 | struct VS_OUTPUT
24 | {
25 | float4 Position : POSITION; // vertex position
26 | float4 Diffuse : COLOR0; // vertex diffuse color
27 | };
28 |
29 |
30 | //--------------------------------------------------------------------------------------
31 | // This shader computes standard transform and lighting
32 | //--------------------------------------------------------------------------------------
33 | VS_OUTPUT RenderWith1LightNoTextureVS( float4 vPos : POSITION,
34 | float3 vNormal : NORMAL )
35 | {
36 | VS_OUTPUT Output;
37 |
38 | // Transform the position from object space to homogeneous projection space
39 | Output.Position = mul(vPos, g_mWorldViewProjection);
40 |
41 | // Transform the normal from object space to world space
42 | float3 vNormalWorldSpace;
43 | vNormalWorldSpace = normalize(mul(vNormal, (float3x3)g_mWorld)); // normal (world space)
44 |
45 | // Compute simple directional lighting equation
46 | Output.Diffuse.rgb = g_MaterialDiffuseColor * max(0,dot(vNormalWorldSpace, g_LightDir));
47 | Output.Diffuse.a = 1.0f;
48 |
49 | return Output;
50 | }
51 |
52 |
53 | //--------------------------------------------------------------------------------------
54 | float4 RenderWith1LightNoTexturePS( float4 Diffuse : COLOR0 ) : COLOR0
55 | {
56 | return Diffuse;
57 | }
58 |
59 |
60 | //--------------------------------------------------------------------------------------
61 | technique RenderWith1LightNoTexture
62 | {
63 | pass P0
64 | {
65 | VertexShader = compile vs_1_1 RenderWith1LightNoTextureVS();
66 | PixelShader = compile ps_1_1 RenderWith1LightNoTexturePS();
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/Game/UI/Font.dds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Game/UI/Font.dds
--------------------------------------------------------------------------------
/Game/UI/dxutcontrols.dds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Game/UI/dxutcontrols.dds
--------------------------------------------------------------------------------
/Source/GCC4/Actors/ActorComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ActorComponent.h - Defines the base class for a component that can be attached to an actor
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "../Utilities/String.h"
41 |
42 | class TiXmlElement;
43 |
44 | //---------------------------------------------------------------------------------------------------------------------
45 | // ActorComponent class
46 | // Chapter 6, page 167
47 | //---------------------------------------------------------------------------------------------------------------------
48 | class ActorComponent
49 | {
50 | friend class ActorFactory;
51 |
52 | protected:
53 | StrongActorPtr m_pOwner;
54 |
55 | public:
56 | virtual ~ActorComponent(void) { m_pOwner.reset(); }
57 |
58 | // These functions are meant to be overridden by the implementation classes of the components.
59 | virtual bool VInit(TiXmlElement* pData) = 0;
60 | virtual void VPostInit(void) { }
61 | virtual void VUpdate(int deltaMs) { }
62 | virtual void VOnChanged(void) { } // [mrmike] - added post-press
63 |
64 | // for the editor
65 | virtual TiXmlElement* VGenerateXml(void) = 0;
66 |
67 | // This function should be overridden by the interface class.
68 | virtual ComponentId VGetId(void) const { return GetIdFromName(VGetName()); }
69 | virtual const char *VGetName() const = 0;
70 | static ComponentId GetIdFromName(const char* componentStr)
71 | {
72 | void* rawId = HashedString::hash_name(componentStr);
73 | return reinterpret_cast(rawId);
74 | }
75 |
76 | private:
77 | void SetOwner(StrongActorPtr pOwner) { m_pOwner = pOwner; }
78 |
79 | };
80 |
81 |
82 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/ActorFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ActorFactory.h - Defines a factory for creating actors & components
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | //---------------------------------------------------------------------------------------------------------------------
42 | // ActorFactory class
43 | // Chapter 6, page 161
44 | //---------------------------------------------------------------------------------------------------------------------
45 | class ActorFactory
46 | {
47 | ActorId m_lastActorId;
48 |
49 | protected:
50 | GenericObjectFactory m_componentFactory;
51 |
52 | public:
53 | ActorFactory(void);
54 |
55 | StrongActorPtr CreateActor(const char* actorResource, TiXmlElement* overrides, const Mat4x4* initialTransform, const ActorId serversActorId);
56 | void ModifyActor(StrongActorPtr pActor, TiXmlElement* overrides);
57 |
58 | //protected:
59 | // [rez] This function can be overridden by a subclass so you can create game-specific C++ components. If you do
60 | // this, make sure you call the base-class version first. If it returns NULL, you know it's not an engine component.
61 | virtual StrongActorComponentPtr VCreateComponent(TiXmlElement* pData);
62 |
63 | private:
64 | ActorId GetNextActorId(void) { ++m_lastActorId; return m_lastActorId; }
65 | };
66 |
67 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/AmmoPickup.cpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // AmmoPickup.cpp - An ammo pickup
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "GameCodeStd.h"
41 | #include "AmmoPickup.h"
42 | #include "../Utilities/String.h"
43 |
44 | const char* AmmoPickup::g_Name = "AmmoPickup";
45 |
46 | bool AmmoPickup::VInit(TiXmlElement* pData)
47 | {
48 | return true;
49 | }
50 |
51 | TiXmlElement* AmmoPickup::VGenerateXml(void)
52 | {
53 | TiXmlElement* pComponentElement = GCC_NEW TiXmlElement(VGetName());
54 | return pComponentElement;
55 | }
56 |
57 | void AmmoPickup::VApply(WeakActorPtr pActor)
58 | {
59 | StrongActorPtr pStrongActor = MakeStrongPtr(pActor);
60 | if (pStrongActor)
61 | {
62 | GCC_LOG("Actor", "Applying ammo pickup to actor id " + ToStr(pStrongActor->GetId()));
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/AmmoPickup.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // AmmoPickup.h - An ammo pickup
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "PickupInterface.h"
41 |
42 | //---------------------------------------------------------------------------------------------------------------------
43 | // AmmoPickup implementation class.
44 | // Chapter 6, page 170
45 | // [rez] This component isn't actually used in Teapot wars. It was used as an example for describing components in
46 | // the book. I decided to include it here to give you a starting point to add ammo drops in your game. :)
47 | //---------------------------------------------------------------------------------------------------------------------
48 | class AmmoPickup : public PickupInterface
49 | {
50 | public:
51 | static const char* g_Name;
52 | virtual const char* VGetName() const { return g_Name; }
53 |
54 | virtual bool VInit(TiXmlElement* pData) override;
55 | virtual TiXmlElement* VGenerateXml(void) override;
56 | virtual void VApply(WeakActorPtr pActor) override;
57 | };
58 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/AudioComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // AudioComponent.h - A component for attaching sounds to an actor
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | //---------------------------------------------------------------------------------------------------------------------
43 | // AudioComponent class.
44 | // [rez] This component was never directly described anywhere in the book but it's used to allow actors to trigger
45 | // sound effects.
46 | //---------------------------------------------------------------------------------------------------------------------
47 | class AudioComponent : public ActorComponent
48 | {
49 | std::string m_audioResource;
50 | bool m_looping;
51 | float m_fadeInTime;
52 | int m_volume;
53 |
54 | public:
55 | static const char *g_Name;
56 | virtual const char *VGetName() const { return g_Name; }
57 |
58 | bool Start();
59 |
60 | AudioComponent(void);
61 |
62 | virtual TiXmlElement* VGenerateXml(void);
63 |
64 | // ActorComponent interface
65 | virtual bool VInit(TiXmlElement* pData) override;
66 | virtual void VPostInit(void) override;
67 | };
68 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/BaseScriptComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // BaseScriptComponent.h - Component for exposing actors to Lua
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ScriptComponentInterface.h"
41 | #include "LuaPlus.h"
42 |
43 |
44 | //---------------------------------------------------------------------------------------------------------------------
45 | // BaseScriptComponent class
46 | // Chapter 12, page 337
47 | //---------------------------------------------------------------------------------------------------------------------
48 | class BaseScriptComponent : public ScriptComponentInterface
49 | {
50 | std::string m_scriptObjectName;
51 | std::string m_constructorName;
52 | std::string m_destructorName;
53 |
54 | LuaPlus::LuaObject m_scriptObject;
55 | LuaPlus::LuaObject m_scriptConstructor;
56 | LuaPlus::LuaObject m_scriptDestructor;
57 |
58 | public:
59 | static const char* g_Name;
60 | virtual const char* VGetName() const { return g_Name; }
61 |
62 | BaseScriptComponent(void);
63 | virtual ~BaseScriptComponent(void);
64 | virtual bool VInit(TiXmlElement* pData);
65 | virtual void VPostInit(void);
66 | virtual TiXmlElement* VGenerateXml(void);
67 |
68 | static void RegisterScriptFunctions(void);
69 | static void UnregisterScriptFunctions(void);
70 |
71 | private:
72 | void CreateScriptObject(void);
73 |
74 | // component script functions
75 | LuaPlus::LuaObject GetActorId(void);
76 |
77 | // physics component script functions
78 | LuaPlus::LuaObject GetPos(void);
79 | void SetPos(LuaPlus::LuaObject newPos);
80 | LuaPlus::LuaObject GetLookAt(void) const;
81 | float GetYOrientationRadians(void) const;
82 | void RotateY(float angleRadians);
83 | void SetPosition(float x, float y, float z);
84 | void LookAt(Vec3 target);
85 | void Stop(void);
86 | };
87 |
88 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/HealthPickup.cpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // HealthPickup.cpp - An health pickup
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | #include "GameCodeStd.h"
42 | #include "HealthPickup.h"
43 | #include "../Utilities/String.h"
44 |
45 | const char* HealthPickup::g_Name = "HealthPickup";
46 |
47 | bool HealthPickup::VInit(TiXmlElement* pData)
48 | {
49 | return true;
50 | }
51 |
52 | TiXmlElement* HealthPickup::VGenerateXml(void)
53 | {
54 | TiXmlElement* pComponentElement = GCC_NEW TiXmlElement(VGetName());
55 | return pComponentElement;
56 | }
57 |
58 | void HealthPickup::VApply(WeakActorPtr pActor)
59 | {
60 | StrongActorPtr pStrongActor = MakeStrongPtr(pActor);
61 | if (pStrongActor)
62 | {
63 | GCC_LOG("Actor", "Applying health pickup to actor id " + ToStr(pStrongActor->GetId()));
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/HealthPickup.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // HealthPickup.h - A health pickup
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "PickupInterface.h"
41 |
42 |
43 | //---------------------------------------------------------------------------------------------------------------------
44 | // HealthPickup implementation class.
45 | // Chapter 6, page 170
46 | // [rez] This component isn't actually used in Teapot wars. It was used as an example for describing components in
47 | // the book. I decided to include it here to give you a starting point to add health drops in your game. :)
48 | //---------------------------------------------------------------------------------------------------------------------
49 | class HealthPickup : public PickupInterface
50 | {
51 | public:
52 | static const char* g_Name;
53 | virtual const char* VGetName() const { return g_Name; }
54 |
55 | virtual bool VInit(TiXmlElement* pData) override;
56 | virtual TiXmlElement* VGenerateXml(void) override;
57 | virtual void VApply(WeakActorPtr pActor) override;
58 | };
59 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/PhysicsComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // PhysicsComponent.h - Component for physical movement and collision detection
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | class TiXmlElement;
43 |
44 | class PhysicsComponent : public ActorComponent
45 | {
46 | public:
47 | const static char *g_Name;
48 | virtual const char *VGetName() const override { return PhysicsComponent::g_Name; }
49 |
50 | public:
51 | PhysicsComponent(void);
52 | virtual ~PhysicsComponent(void);
53 | virtual TiXmlElement* VGenerateXml(void) override;
54 |
55 | // ActorComponent interface
56 | virtual bool VInit(TiXmlElement* pData) override;
57 | virtual void VPostInit(void) override;
58 | virtual void VUpdate(int deltaMs) override;
59 |
60 | // Physics functions
61 | void ApplyForce(const Vec3& direction, float forceNewtons);
62 | void ApplyTorque(const Vec3& direction, float forceNewtons);
63 | bool KinematicMove(const Mat4x4& transform);
64 |
65 | // acceleration
66 | void ApplyAcceleration(float acceleration);
67 | void RemoveAcceleration(void);
68 | void ApplyAngularAcceleration(float acceleration);
69 | void RemoveAngularAcceleration(void);
70 |
71 | //void RotateY(float angleRadians);
72 | Vec3 GetVelocity(void);
73 | void SetVelocity(const Vec3& velocity);
74 | void RotateY(float angleRadians);
75 | void SetPosition(float x, float y, float z);
76 | void Stop(void);
77 |
78 |
79 | protected:
80 | void CreateShape();
81 | void BuildRigidBodyTransform(TiXmlElement* pTransformElement);
82 |
83 | float m_acceleration, m_angularAcceleration;
84 | float m_maxVelocity, m_maxAngularVelocity;
85 |
86 | std::string m_shape;
87 | std::string m_density;
88 | std::string m_material;
89 |
90 | Vec3 m_RigidBodyLocation; // this isn't world position! This is how the rigid body is offset from the position of the actor.
91 | Vec3 m_RigidBodyOrientation; // ditto, orientation
92 | Vec3 m_RigidBodyScale; // ditto, scale
93 |
94 | shared_ptr m_pGamePhysics; // might be better as a weak ptr...
95 | };
96 |
97 |
98 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/PickupInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // PickupInterface.h - Interface class for all pickups
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | class PickupInterface : public ActorComponent
43 | {
44 | public:
45 | // static ComponentId COMPONENT_ID; // unique ID for this component type
46 | // virtual ComponentId VGetComponentId(void) const override { return COMPONENT_ID; }
47 |
48 | // Pickup interface
49 | virtual void VApply(WeakActorPtr pActor) = 0;
50 | };
51 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/RenderComponentInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // RenderComponentInterface.h - Interface for render components
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | class RenderComponentInterface : public ActorComponent
43 | {
44 | public:
45 | // virtual ComponentId VGetComponentId(void) const override { return COMPONENT_ID; }
46 |
47 | // RenderComponentInterface
48 | virtual shared_ptr VGetSceneNode(void) = 0;
49 | };
50 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/ScriptComponentInterface.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ScriptComponentInterface.h - Interface for script components
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | //---------------------------------------------------------------------------------------------------------------------
43 | // This component is essentially a placeholder for the script representation of the entity. The engine doesn't do
44 | // much (if anything) with it, hence the lack of interface.
45 | //---------------------------------------------------------------------------------------------------------------------
46 | class ScriptComponentInterface : public ActorComponent
47 | {
48 | public:
49 | // static ComponentId COMPONENT_ID;
50 | // virtual ComponentId VGetComponentId(void) const { return COMPONENT_ID; }
51 | };
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Source/GCC4/Actors/TransformComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // TransformComponent.h - Component for managing transforms on actors
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "ActorComponent.h"
41 |
42 | //---------------------------------------------------------------------------------------------------------------------
43 | // This component implementation is a very simple representation of the physical aspect of an actor. It just defines
44 | // the transform and doesn't register with the physics system at all.
45 | //---------------------------------------------------------------------------------------------------------------------
46 | class TransformComponent : public ActorComponent
47 | {
48 | Mat4x4 m_transform;
49 | public:
50 | static const char* g_Name;
51 | virtual const char* VGetName() const { return g_Name; }
52 |
53 | TransformComponent(void) : m_transform(Mat4x4::g_Identity) { }
54 | virtual bool VInit(TiXmlElement* pData) override;
55 | virtual TiXmlElement* VGenerateXml(void) override;
56 |
57 | // transform functions
58 | Mat4x4 GetTransform(void) const { return m_transform; }
59 | void SetTransform(const Mat4x4& newTransform) { m_transform = newTransform; }
60 | Vec3 GetPosition(void) const { return m_transform.GetPosition(); }
61 | void SetPosition(const Vec3& pos) { m_transform.SetPosition(pos); }
62 | Vec3 GetLookAt(void) const { return m_transform.GetDirection(); }
63 | };
64 |
--------------------------------------------------------------------------------
/Source/GCC4/Debugging/Debugging.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // Debugging.cpp : Miscellaneous debugging tools
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 |
40 |
41 | #include "GameCodeStd.h"
42 |
43 | //========================================================================
44 | // Game Coding Complete Referance - Debugging Chapter
45 | //========================================================================
46 |
47 | #include
48 | int Refs(IUnknown *pUnk)
49 | {
50 | pUnk->AddRef();
51 | return pUnk->Release();
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/Source/GCC4/Debugging/MiniDump.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Debugging/MiniDump.h
--------------------------------------------------------------------------------
/Source/GCC4/EventManager/EventManager.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // EventManager.cpp : implements a multi-listener multi-sender event system
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 |
40 | #include "GameCodeStd.h"
41 | #include "EventManager.h"
42 |
43 |
44 | static IEventManager* g_pEventMgr = NULL;
45 | GenericObjectFactory g_eventFactory;
46 |
47 | //GCC_MEMORY_WATCHER_DEFINITION(IEventData);
48 |
49 | IEventManager* IEventManager::Get(void)
50 | {
51 | GCC_ASSERT(g_pEventMgr);
52 | return g_pEventMgr;
53 | }
54 |
55 | IEventManager::IEventManager(const char* pName, bool setAsGlobal)
56 | {
57 | if (setAsGlobal)
58 | {
59 | if (g_pEventMgr)
60 | {
61 | GCC_ERROR("Attempting to create two global event managers! The old one will be destroyed and overwritten with this one.");
62 | delete g_pEventMgr;
63 | }
64 |
65 | g_pEventMgr = this;
66 | }
67 | }
68 |
69 | IEventManager::~IEventManager(void)
70 | {
71 | if (g_pEventMgr == this)
72 | g_pEventMgr = NULL;
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/Source/GCC4/EventManager/EventManagerImpl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // EventMangerImpl.cpp : implementation side of the event system
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "EventManager.h"
41 |
42 | const unsigned int EVENTMANAGER_NUM_QUEUES = 2;
43 |
44 | class EventManager : public IEventManager
45 | {
46 | typedef std::list EventListenerList;
47 | typedef std::map EventListenerMap;
48 | typedef std::list EventQueue;
49 |
50 | EventListenerMap m_eventListeners;
51 | EventQueue m_queues[EVENTMANAGER_NUM_QUEUES];
52 | int m_activeQueue; // index of actively processing queue; events enque to the opposing queue
53 |
54 | ThreadSafeEventQueue m_realtimeEventQueue;
55 |
56 | public:
57 | explicit EventManager(const char* pName, bool setAsGlobal);
58 | virtual ~EventManager(void);
59 |
60 | virtual bool VAddListener(const EventListenerDelegate& eventDelegate, const EventType& type);
61 | virtual bool VRemoveListener(const EventListenerDelegate& eventDelegate, const EventType& type);
62 |
63 | virtual bool VTriggerEvent(const IEventDataPtr& pEvent) const;
64 | virtual bool VQueueEvent(const IEventDataPtr& pEvent);
65 | virtual bool VThreadSafeQueueEvent(const IEventDataPtr& pEvent);
66 | virtual bool VAbortEvent(const EventType& type, bool allOfType = false);
67 |
68 | virtual bool VUpdate(unsigned long maxMillis = kINFINITE);
69 | };
70 |
--------------------------------------------------------------------------------
/Source/GCC4/EventManager/Events.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // Events.cpp : defines common game events
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/6
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 | #include "GameCodeStd.h"
40 |
41 | #include "Events.h"
42 | #include "../Physics/PhysicsEventListener.h"
43 | #include "../LUAScripting/ScriptEvent.h"
44 |
45 | // To define a new event - you need a 32-bit GUID.
46 | // In Visual Studio, go to Tools->Create GUID and grab the first bit.
47 |
48 | const EventType EvtData_Environment_Loaded::sk_EventType(0xa3814acd);
49 | const EventType EvtData_Remote_Environment_Loaded::sk_EventType(0x8E2AD6E6);
50 | const EventType EvtData_New_Actor::sk_EventType(0xe86c7c31);
51 | const EventType EvtData_Move_Actor::sk_EventType(0xeeaa0a40);
52 | const EventType EvtData_Destroy_Actor::sk_EventType(0x77dd2b3a);
53 | const EventType EvtData_New_Render_Component::sk_EventType(0xaf4aff75);
54 | const EventType EvtData_Modified_Render_Component::sk_EventType(0x80fe9766);
55 | const EventType EvtData_Request_Start_Game::sk_EventType(0x11f2b19d);
56 | const EventType EvtData_Remote_Client::sk_EventType(0x301693d5);
57 | const EventType EvtData_Network_Player_Actor_Assignment::sk_EventType(0xa7c92f11);
58 | const EventType EvtData_Update_Tick::sk_EventType(0xf0f5d183);
59 | const EventType EvtData_Decompress_Request::sk_EventType(0xc128a129);
60 | const EventType EvtData_Decompression_Progress::sk_EventType(0x68de1f28);
61 | const EventType EvtData_Request_New_Actor::sk_EventType(0x40378c64);
62 | const EventType EvtData_Request_Destroy_Actor::sk_EventType(0xf5395770);
63 | const EventType EvtData_PlaySound::sk_EventType(0x3d8118ee);
64 |
65 | bool EvtData_PlaySound::VBuildEventFromScript(void)
66 | {
67 | if (m_eventData.IsString())
68 | {
69 | m_soundResource = m_eventData.GetString();
70 | return true;
71 | }
72 |
73 | return false;
74 | }
75 |
76 | void RegisterEngineScriptEvents(void)
77 | {
78 | REGISTER_SCRIPT_EVENT(EvtData_Request_Destroy_Actor, EvtData_Request_Destroy_Actor::sk_EventType);
79 | REGISTER_SCRIPT_EVENT(EvtData_PhysCollision, EvtData_PhysCollision::sk_EventType);
80 | REGISTER_SCRIPT_EVENT(EvtData_PlaySound, EvtData_PlaySound::sk_EventType);
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/Source/GCC4/Graphics3D/MovementController.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // File: MovementController.h
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "../GameCode4/Interfaces.h"
41 | #include "Geometry.h"
42 |
43 |
44 | // Forward declarations
45 | class SceneNode;
46 |
47 | ////////////////////////////////////////////////////
48 | //
49 | // MovementController Description
50 | //
51 | // Implements a WASD style movement controller
52 | //
53 | // class MovementController - Chapter 10, page 281
54 | //
55 | ////////////////////////////////////////////////////
56 |
57 | class MovementController : public IPointerHandler, public IKeyboardHandler
58 | {
59 | protected:
60 | Mat4x4 m_matFromWorld;
61 | Mat4x4 m_matToWorld;
62 | Mat4x4 m_matPosition;
63 |
64 | Point m_lastMousePos;
65 | bool m_bKey[256]; // Which keys are up and down
66 |
67 | // Orientation Controls
68 | float m_fTargetYaw;
69 | float m_fTargetPitch;
70 | float m_fYaw;
71 | float m_fPitch;
72 | float m_fPitchOnDown;
73 | float m_fYawOnDown;
74 | float m_maxSpeed;
75 | float m_currentSpeed;
76 |
77 | // Added for Ch19/20 refactor
78 | bool m_mouseLButtonDown;
79 | bool m_bRotateWhenLButtonDown;
80 |
81 | shared_ptr m_object;
82 |
83 | public:
84 | MovementController(shared_ptr object, float initialYaw, float initialPitch, bool rotateWhenLButtonDown);
85 | void SetObject(shared_ptr newObject);
86 |
87 | void OnUpdate(DWORD const elapsedMs);
88 |
89 | public:
90 | bool VOnPointerMove(const Point &mousePos, const int radius);
91 | bool VOnPointerButtonDown(const Point &mousePos, const int radius, const std::string &buttonName);
92 | bool VOnPointerButtonUp(const Point &mousePos, const int radius, const std::string &buttonName);
93 |
94 | bool VOnKeyDown(const BYTE c) { m_bKey[c] = true; return true; }
95 | bool VOnKeyUp(const BYTE c) { m_bKey[c] = false; return true; }
96 |
97 | const Mat4x4 *GetToWorld() { return &m_matToWorld; }
98 | const Mat4x4 *GetFromWorld() { return &m_matFromWorld; }
99 | };
100 |
101 |
--------------------------------------------------------------------------------
/Source/GCC4/Graphics3D/Raycast.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // Raycast.cpp - implements a raycast into the rendered scene
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | #include "Geometry.h"
42 |
43 | class Intersection
44 | {
45 | public:
46 | FLOAT m_fDist; // distance from ray origin to intersection
47 | DWORD m_dwFace; // the face index of the intersection
48 | FLOAT m_fBary1, m_fBary2; // Barycentric coordinates of the intersection
49 | FLOAT m_tu, m_tv; // texture coords of intersection
50 | ActorId m_actorId; // Which actor was intersected if there was one
51 | Vec3 m_worldLoc; // world location of intersection
52 | Vec3 m_actorLoc; // actor local coordinates of intersection
53 | Vec3 m_normal; // normal of intersection
54 |
55 | bool const operator <(Intersection const &other) { return m_fDist < other.m_fDist; }
56 | };
57 |
58 | template
59 | void InitIntersection(Intersection &intersection, DWORD faceIndex, FLOAT dist, FLOAT u, FLOAT v, ActorId actorId, WORD* pIndices, T* pVertices, const Mat4x4 &matWorld);
60 |
61 |
62 | typedef std::vector IntersectionArray;
63 |
64 | class CDXUTSDKMesh;
65 |
66 | class RayCast
67 | {
68 | protected:
69 | LPDIRECT3DVERTEXBUFFER9 m_pVB;
70 |
71 | public:
72 | RayCast(Point point, DWORD maxIntersections = 16);
73 |
74 | DWORD m_MaxIntersections;
75 | DWORD m_NumIntersections;
76 | bool m_bUseD3DXIntersect; // Whether to use D3DXIntersect
77 | bool m_bAllHits; // Whether to just get the first "hit" or all "hits"
78 | Point m_Point;
79 |
80 | D3DXVECTOR3 m_vPickRayDir;
81 | D3DXVECTOR3 m_vPickRayOrig;
82 |
83 | IntersectionArray m_IntersectionArray;
84 |
85 | HRESULT Pick(Scene *pScene, ActorId actorId, ID3DXMesh *pMesh);
86 | HRESULT Pick(Scene *pScene, ActorId actorId, CDXUTSDKMesh *pMesh);
87 |
88 | HRESULT Pick(Scene *pScene, ActorId actorId, LPDIRECT3DVERTEXBUFFER9 pVerts, LPDIRECT3DINDEXBUFFER9 pIndices, DWORD numPolys);
89 | HRESULT Pick(Scene *pScene, ActorId actorId, LPDIRECT3DVERTEXBUFFER9 pVerts, DWORD numPolys);
90 |
91 | void Sort();
92 | };
93 |
94 |
95 |
--------------------------------------------------------------------------------
/Source/GCC4/Graphics3D/Sky.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // Sky.h - implements a sky box in either D3D9 or D3D11
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "Geometry.h"
41 | #include "Material.h"
42 | #include "Shaders.h"
43 |
44 | // Forward declarations
45 | class SceneNode;
46 | class Scene;
47 |
48 | ////////////////////////////////////////////////////
49 | //
50 | // class SkyNode - Chapter 16, page 554
51 | //
52 | // Implements a believable sky that follows
53 | // the camera around - this is a base class that the D3D9 and D3D11 classes
54 | // inherit from
55 | //
56 | ////////////////////////////////////////////////////
57 |
58 | class SkyNode : public SceneNode
59 | {
60 | protected:
61 | DWORD m_numVerts;
62 | DWORD m_sides;
63 | const char * m_textureBaseName;
64 | shared_ptr m_camera;
65 | bool m_bActive;
66 |
67 | std::string GetTextureName(const int side);
68 |
69 | public:
70 | SkyNode(const char *textureFile);
71 | virtual ~SkyNode() { }
72 | HRESULT VPreRender(Scene *pScene);
73 | bool VIsVisible(Scene *pScene) const { return m_bActive; }
74 | };
75 |
76 |
77 | class D3DSkyNode9 : public SkyNode
78 | {
79 | protected:
80 | LPDIRECT3DTEXTURE9 m_pTexture[5]; // the sky textures
81 | LPDIRECT3DVERTEXBUFFER9 m_pVerts; // the sky verts
82 |
83 | public:
84 | D3DSkyNode9(const char *pTextureBaseName );
85 | virtual ~D3DSkyNode9();
86 | HRESULT VOnRestore(Scene *pScene);
87 | HRESULT VRender(Scene *pScene);
88 | };
89 |
90 |
91 | class D3DSkyNode11 : public SkyNode
92 | {
93 | public:
94 | D3DSkyNode11(const char *pTextureBaseName );
95 | virtual ~D3DSkyNode11();
96 | HRESULT VOnRestore(Scene *pScene);
97 | HRESULT VRender(Scene *pScene);
98 |
99 | protected:
100 | ID3D11Buffer* m_pIndexBuffer;
101 | ID3D11Buffer* m_pVertexBuffer;
102 |
103 | GameCode4_Hlsl_VertexShader m_VertexShader;
104 | GameCode4_Hlsl_PixelShader m_PixelShader;
105 | };
106 |
107 |
--------------------------------------------------------------------------------
/Source/GCC4/LUAScripting/LuaStateManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | // GameCode4 is the sample application that encapsulates much of the source code
3 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
4 | // "Rez" Graham, published by Charles River Media.
5 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
6 | //
7 | // If this source code has found it's way to you, and you think it has helped you
8 | // in any way, do the authors a favor and buy a new copy of the book - there are
9 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
10 | // by clicking here:
11 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
12 | //
13 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
14 | //
15 | // The source code is managed and maintained through Google Code:
16 | // http://code.google.com/p/gamecode4/
17 | //
18 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
19 | //
20 | // This program is free software; you can redistribute it and/or
21 | // modify it under the terms of the GNU Lesser GPL v3
22 | // as published by the Free Software Foundation.
23 | //
24 | // This program is distributed in the hope that it will be useful,
25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
27 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
28 | //
29 | // You should have received a copy of the GNU Lesser GPL v3
30 | // along with this program; if not, write to the Free Software
31 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 | //
33 | //========================================================================
34 |
35 | #include "LuaPlus.h"
36 |
37 |
38 | //---------------------------------------------------------------------------------------------------------------------
39 | // LuaStateManager - Chapter 12, page 367
40 | //---------------------------------------------------------------------------------------------------------------------
41 | class LuaStateManager : public IScriptManager
42 | {
43 | static LuaStateManager* s_pSingleton;
44 | LuaPlus::LuaState* m_pLuaState;
45 | std::string m_lastError;
46 |
47 | public:
48 | // Singleton functions
49 | static bool Create(void);
50 | static void Destroy(void);
51 | static LuaStateManager* Get(void) { GCC_ASSERT(s_pSingleton); return s_pSingleton; }
52 |
53 | // IScriptManager interface
54 | virtual bool VInit(void) override;
55 | virtual void VExecuteFile(const char* resource) override;
56 | virtual void VExecuteString(const char* str) override;
57 |
58 | LuaPlus::LuaObject GetGlobalVars(void);
59 | LuaPlus::LuaState* GetLuaState(void) const;
60 |
61 | // public helpers
62 | LuaPlus::LuaObject CreatePath(const char* pathString, bool toIgnoreLastElement = false);
63 | void ConvertVec3ToTable(const Vec3& vec, LuaPlus::LuaObject& outLuaTable) const;
64 | void ConvertTableToVec3(const LuaPlus::LuaObject& luaTable, Vec3& outVec3) const;
65 |
66 | private:
67 | void SetError(int errorNum);
68 | void ClearStack(void);
69 |
70 | // private constructor & destructor; call the static Create() and Destroy() functions instead
71 | explicit LuaStateManager(void);
72 | virtual ~LuaStateManager(void);
73 | };
74 |
75 |
--------------------------------------------------------------------------------
/Source/GCC4/LUAScripting/ScriptExports.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ScriptExports.h
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | namespace ScriptExports
41 | {
42 | void Register(void);
43 | void Unregister(void);
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Source/GCC4/LUAScripting/ScriptProcess.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ScriptProcess.h
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | #include "../Mainloop/Process.h"
42 | #include "LuaStateManager.h"
43 |
44 |
45 | //---------------------------------------------------------------------------------------------------------------------
46 | // ScriptProcess - Chapter 12, page 370
47 | //---------------------------------------------------------------------------------------------------------------------
48 | class ScriptProcess : public Process
49 | {
50 | unsigned long m_frequency, m_time;
51 | LuaPlus::LuaObject m_scriptInitFunction, m_scriptUpdateFunction;
52 | LuaPlus::LuaObject m_scriptSuccessFunction, m_scriptFailFunction, m_scriptAbortFunction;
53 | LuaPlus::LuaObject m_self;
54 |
55 | public:
56 | static void RegisterScriptClass(void);
57 |
58 | protected:
59 | // Process interface
60 | virtual void VOnInit(void);
61 | virtual void VOnUpdate(unsigned long deltaMs);
62 | virtual void VOnSuccess(void);
63 | virtual void VOnFail(void);
64 | virtual void VOnAbort(void);
65 |
66 | private:
67 | // private helpers
68 | static void RegisterScriptClassFunctions(LuaPlus::LuaObject& metaTableObj);
69 | static LuaPlus::LuaObject CreateFromScript(LuaPlus::LuaObject self, LuaPlus::LuaObject constructionData, LuaPlus::LuaObject originalSubClass);
70 | virtual bool BuildCppDataFromScript(LuaPlus::LuaObject scriptClass, LuaPlus::LuaObject constructionData);
71 |
72 | // These are needed because the base-class version of these functions are all const and LuaPlus can't deal
73 | // with registering const functions.
74 | bool ScriptIsAlive(void) { return IsAlive(); }
75 | bool ScriptIsDead(void) { return IsDead(); }
76 | bool ScriptIsPaused(void) { return IsPaused(); }
77 |
78 | // This wrapper function is needed so we can translate a Lua script object to something C++ can use.
79 | void ScriptAttachChild(LuaPlus::LuaObject child);
80 |
81 | // don't allow construction outside of this class
82 | explicit ScriptProcess(void);
83 | };
84 |
85 |
--------------------------------------------------------------------------------
/Source/GCC4/LUAScripting/ScriptResource.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // XmlResource.cpp : Defines a simple resource cache
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 | #include "GameCodeStd.h"
40 | #include "ScriptResource.h"
41 | #include "LuaStateManager.h"
42 |
43 |
44 | bool ScriptResourceLoader::VLoadResource(char *rawBuffer, unsigned int rawSize, shared_ptr handle)
45 | {
46 | if (rawSize <= 0)
47 | return false;
48 |
49 | if (!g_pApp->m_pGame || g_pApp->m_pGame->CanRunLua())
50 | LuaStateManager::Get()->VExecuteString(rawBuffer);
51 |
52 | return true;
53 | }
54 |
55 |
56 | shared_ptr CreateScriptResourceLoader()
57 | {
58 | return shared_ptr(GCC_NEW ScriptResourceLoader());
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/Source/GCC4/LUAScripting/ScriptResource.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ScriptResource.h
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | // --------------------------------------------------------------------------
41 | // File: ScriptResource.h
42 | //
43 | // Purpose: The declaration of a quick'n dirty ZIP file reader class.
44 | // Original code from Javier Arevalo.
45 | // Get zlib from http://www.cdrom.com/pub/infozip/zlib/
46 | //
47 | // class XmlFile - Chapter 7, page 186
48 | // --------------------------------------------------------------------------
49 |
50 | #include "../ResourceCache/ResCache.h"
51 |
52 |
53 | class ScriptResourceLoader : public IResourceLoader
54 | {
55 | public:
56 | virtual bool VUseRawFile() { return false; }
57 | virtual bool VDiscardRawBufferAfterLoad() { return true; }
58 | virtual bool VAddNullZero() { return true; }
59 | virtual unsigned int VGetLoadedResourceSize(char *rawBuffer, unsigned int rawSize) { return rawSize; }
60 | virtual bool VLoadResource(char *rawBuffer, unsigned int rawSize, shared_ptr handle);
61 | virtual std::string VGetPattern() { return "*.lua"; }
62 | };
63 |
64 |
65 |
--------------------------------------------------------------------------------
/Source/GCC4/Mainloop/Initialization.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Mainloop/Initialization.cpp
--------------------------------------------------------------------------------
/Source/GCC4/Mainloop/Initialization.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // Initialization.h : Defines utility functions for game initialization
4 | //
5 | //
6 | // Part of the GameCode4 Application
7 | //
8 | // GameCode4 is the sample application that encapsulates much of the source code
9 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
10 | // "Rez" Graham, published by Charles River Media.
11 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
12 | //
13 | // If this source code has found it's way to you, and you think it has helped you
14 | // in any way, do the authors a favor and buy a new copy of the book - there are
15 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
16 | // by clicking here:
17 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
18 | //
19 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
20 | //
21 | // The source code is managed and maintained through Google Code:
22 | // http://code.google.com/p/gamecode4/
23 | //
24 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
25 | //
26 | // This program is free software; you can redistribute it and/or
27 | // modify it under the terms of the GNU Lesser GPL v3
28 | // as published by the Free Software Foundation.
29 | //
30 | // This program is distributed in the hope that it will be useful,
31 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
33 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
34 | //
35 | // You should have received a copy of the GNU Lesser GPL v3
36 | // along with this program; if not, write to the Free Software
37 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38 | //
39 | //========================================================================
40 |
41 |
42 | extern bool CheckStorage(const DWORDLONG diskSpaceNeeded);
43 | extern DWORD ReadCPUSpeed();
44 | extern bool CheckMemory(const DWORDLONG physicalRAMNeeded, const DWORDLONG virtualRAMNeeded);
45 | extern bool IsOnlyInstance(LPCTSTR gameTitle);
46 | extern const TCHAR *GetSaveGameDirectory(HWND hWnd, const TCHAR *gameAppDirectory);
47 | extern bool CheckForJoystick(HWND hWnd);
48 |
49 | //extern DWORD GetFreeVRAM(); // deprecated!!!!
50 |
51 | struct GameOptions
52 | {
53 | // Level option
54 | std::string m_Level;
55 |
56 | // Rendering options
57 | std::string m_Renderer;
58 | bool m_runFullSpeed;
59 | Point m_ScreenSize;
60 |
61 | // Sound options
62 | float m_soundEffectsVolume;
63 | float m_musicVolume;
64 |
65 | // Multiplayer options
66 | int m_expectedPlayers;
67 | int m_listenPort;
68 | std::string m_gameHost;
69 | int m_numAIs;
70 | int m_maxAIs;
71 | int m_maxPlayers;
72 |
73 | // resource cache options
74 | bool m_useDevelopmentDirectories;
75 |
76 | // TiXmlElement - look at this to find other options added by the developer
77 | TiXmlDocument *m_pDoc;
78 |
79 | GameOptions();
80 | ~GameOptions() { SAFE_DELETE(m_pDoc); }
81 |
82 | void Init(const char* xmlFilePath, LPWSTR lpCmdLine);
83 | };
84 |
--------------------------------------------------------------------------------
/Source/GCC4/Mainloop/ProcessManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ProcessManager.h : defines common game events
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "Process.h"
41 |
42 | class ProcessManager
43 | {
44 | typedef std::list ProcessList;
45 |
46 | ProcessList m_processList;
47 |
48 | public:
49 | // construction
50 | ~ProcessManager(void);
51 |
52 | // interface
53 | unsigned int UpdateProcesses(unsigned long deltaMs); // updates all attached processes
54 | WeakProcessPtr AttachProcess(StrongProcessPtr pProcess); // attaches a process to the process mgr
55 | void AbortAllProcesses(bool immediate);
56 |
57 | // accessors
58 | unsigned int GetProcessCount(void) const { return m_processList.size(); }
59 |
60 | private:
61 | void ClearAllProcesses(void); // should only be called by the destructor
62 | };
63 |
64 |
65 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Msvc/GameCode.ico
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode4_2015.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "resource.h"
4 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode4_2015.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Msvc/GameCode4_2015.ico
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode4_2015.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Msvc/GameCode4_2015.rc
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode4_2015.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.40629.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameCode4_2015", "GameCode4_2015.vcxproj", "{5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Debug|x64 = Debug|x64
12 | Release|Win32 = Release|Win32
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Debug|Win32.ActiveCfg = Debug|Win32
17 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Debug|Win32.Build.0 = Debug|Win32
18 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Debug|x64.ActiveCfg = Debug|x64
19 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Debug|x64.Build.0 = Debug|x64
20 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Release|Win32.ActiveCfg = Release|Win32
21 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Release|Win32.Build.0 = Release|Win32
22 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Release|x64.ActiveCfg = Release|x64
23 | {5F8DE669-F90C-498F-891B-EE6ACE0CA1BD}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/GameCode4_2015.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | WIN32 APPLICATION : GameCode4_2015 Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this GameCode4_2015 application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your GameCode4_2015 application.
9 |
10 |
11 | GameCode4_2015.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | GameCode4_2015.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 | GameCode4_2015.cpp
25 | This is the main application source file.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | AppWizard has created the following resources:
29 |
30 | GameCode4_2015.rc
31 | This is a listing of all of the Microsoft Windows resources that the
32 | program uses. It includes the icons, bitmaps, and cursors that are stored
33 | in the RES subdirectory. This file can be directly edited in Microsoft
34 | Visual C++.
35 |
36 | Resource.h
37 | This is the standard header file, which defines new resource IDs.
38 | Microsoft Visual C++ reads and updates this file.
39 |
40 | GameCode4_2015.ico
41 | This is an icon file, which is used as the application's icon (32x32).
42 | This icon is included by the main resource file GameCode4_2015.rc.
43 |
44 | small.ico
45 | This is an icon file, which contains a smaller version (16x16)
46 | of the application's icon. This icon is included by the main resource
47 | file GameCode4_2015.rc.
48 |
49 | /////////////////////////////////////////////////////////////////////////////
50 | Other standard files:
51 |
52 | StdAfx.h, StdAfx.cpp
53 | These files are used to build a precompiled header (PCH) file
54 | named GameCode4_2015.pch and a precompiled types file named StdAfx.obj.
55 |
56 | /////////////////////////////////////////////////////////////////////////////
57 | Other notes:
58 |
59 | AppWizard uses "TODO:" comments to indicate parts of the source code you
60 | should add to or customize.
61 |
62 | /////////////////////////////////////////////////////////////////////////////
63 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/Resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by GameCode4_2015.rc
4 | //
5 |
6 | #define IDS_APP_TITLE 103
7 |
8 | #define IDR_MAINFRAME 128
9 | #define IDD_GAMECODE4_2015_DIALOG 102
10 | #define IDD_ABOUTBOX 103
11 | #define IDM_ABOUT 104
12 | #define IDM_EXIT 105
13 | #define IDI_GAMECODE4_2015 107
14 | #define IDI_SMALL 108
15 | #define IDC_GAMECODE4_2015 109
16 | #define IDC_MYICON 2
17 | #ifndef IDC_STATIC
18 | #define IDC_STATIC -1
19 | #endif
20 | // Next default values for new objects
21 | //
22 | #ifdef APSTUDIO_INVOKED
23 | #ifndef APSTUDIO_READONLY_SYMBOLS
24 |
25 | #define _APS_NO_MFC 130
26 | #define _APS_NEXT_RESOURCE_VALUE 129
27 | #define _APS_NEXT_COMMAND_VALUE 32771
28 | #define _APS_NEXT_CONTROL_VALUE 1000
29 | #define _APS_NEXT_SYMED_VALUE 110
30 | #endif
31 | #endif
32 |
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/small.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4/Msvc/small.ico
--------------------------------------------------------------------------------
/Source/GCC4/Msvc/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/Source/GCC4/Multicore/RealtimeProcess.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // RealtimeProcess.h : Defines real time processes that can be used with ProcessManager
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "..\Mainloop\Process.h"
41 |
42 | class RealtimeProcess : public Process
43 | {
44 | protected:
45 | HANDLE m_hThread;
46 | DWORD m_ThreadID;
47 | int m_ThreadPriority;
48 |
49 | public:
50 | // Other prioities can be:
51 | // THREAD_PRIORITY_ABOVE_NORMAL
52 | // THREAD_PRIORITY_BELOW_NORMAL
53 | // THREAD_PRIORITY_HIGHEST
54 | // THREAD_PRIORITY_LOWEST
55 | // THREAD_PRIORITY_IDLE
56 | // THREAD_PRIORITY_TIME_CRITICAL
57 | //
58 | //
59 | RealtimeProcess(int priority = THREAD_PRIORITY_NORMAL);
60 | virtual ~RealtimeProcess(void) { CloseHandle(m_hThread); }
61 | static DWORD WINAPI ThreadProc( LPVOID lpParam );
62 |
63 | protected:
64 | virtual void VOnInit(void);
65 | virtual void VOnUpdate(unsigned long deltaMs) override { } // do nothing.
66 | virtual void VThreadProc(void) = 0; // must be defined for all real time processes.
67 | };
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/Source/GCC4/Physics/Physics.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // Physics.h : Implements the IGamePhysics interface
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | extern IGamePhysics *CreateGamePhysics();
42 | extern IGamePhysics *CreateNullPhysics();
43 |
44 |
--------------------------------------------------------------------------------
/Source/GCC4/Physics/PhysicsDebugDrawer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // PhysicsDebugDrawer.h - implements a physics debug drawer in DX9
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | #include "btBulletDynamicsCommon.h"
42 |
43 | //////////////////////////////////////////////////////////////////////////////
44 | // class BulletDebugDrawer - Chapter 17, page 605
45 | //
46 | // Bullet uses this object to draw debug information. This implementation
47 | // of btIDebugDraw uses direct3D lines to represent the current state
48 | // of the physics simulation
49 | //
50 | class BulletDebugDrawer : public btIDebugDraw
51 | {
52 | DebugDrawModes m_DebugModes;
53 | public:
54 | // btIDebugDraw interface
55 | virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) override;
56 | virtual void reportErrorWarning(const char* warningString) override;
57 | virtual void draw3dText(const btVector3& location,const char* textString) override;
58 | virtual void setDebugMode(int debugMode) override;
59 | virtual int getDebugMode() const override;
60 | virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color) override;
61 |
62 | // [mrmike] Added post press to read PlayerOptions.xml to turn on physics debug options.
63 | void ReadOptions(void);
64 | };
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Source/GCC4/Physics/PhysicsEventListener.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // PhysicsEventListener.cpp : implements the events sent FROM the phsyics system
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 |
40 | //
41 | // Basic, simple, physics event listener construct
42 | //
43 |
44 | #include "GameCodeStd.h"
45 |
46 | #include "PhysicsEventListener.h"
47 |
48 | #include "Physics.h"
49 | #include "..\EventManager\Events.h"
50 | #include "../LUAScripting/LuaStateManager.h"
51 |
52 | const EventType EvtData_PhysTrigger_Enter::sk_EventType(0x99358c15);
53 | const EventType EvtData_PhysTrigger_Leave::sk_EventType(0x3f49c41f);
54 | const EventType EvtData_PhysCollision::sk_EventType(0x54c58d0d);
55 | const EventType EvtData_PhysSeparation::sk_EventType(0x3dcea6e1);
56 |
57 |
58 | void EvtData_PhysCollision::VBuildEventData(void)
59 | {
60 | m_eventData.AssignNewTable(LuaStateManager::Get()->GetLuaState());
61 | m_eventData.SetInteger("actorA", m_ActorA);
62 | m_eventData.SetInteger("actorB", m_ActorB);
63 | }
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Source/GCC4/ResourceCache/XmlResource.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // XmlResource.cpp : API to use load Xml files from the Resource Cache
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 | #include "GameCodeStd.h"
40 | #include "XmlResource.h"
41 |
42 | void XmlResourceExtraData::ParseXml(char* pRawBuffer)
43 | {
44 | m_xmlDocument.Parse(pRawBuffer);
45 | }
46 |
47 |
48 | bool XmlResourceLoader::VLoadResource(char *rawBuffer, unsigned int rawSize, shared_ptr handle)
49 | {
50 | if (rawSize <= 0)
51 | return false;
52 |
53 | shared_ptr pExtraData = shared_ptr(GCC_NEW XmlResourceExtraData());
54 | pExtraData->ParseXml(rawBuffer);
55 |
56 | handle->SetExtra(shared_ptr(pExtraData));
57 |
58 | return true;
59 | }
60 |
61 |
62 | shared_ptr CreateXmlResourceLoader()
63 | {
64 | return shared_ptr(GCC_NEW XmlResourceLoader());
65 | }
66 |
67 |
68 | TiXmlElement* XmlResourceLoader::LoadAndReturnRootXmlElement(const char* resourceString)
69 | {
70 | Resource resource(resourceString);
71 | shared_ptr pResourceHandle = g_pApp->m_ResCache->GetHandle(&resource); // this actually loads the XML file from the zip file
72 | shared_ptr pExtraData = static_pointer_cast(pResourceHandle->GetExtra());
73 | return pExtraData->GetRoot();
74 | }
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Source/GCC4/ResourceCache/XmlResource.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // XmlResource.h : API to use load Xml files from the Resource Cache
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | #include "ResCache.h"
42 | #include
43 |
44 |
45 | class XmlResourceExtraData : public IResourceExtraData
46 | {
47 | TiXmlDocument m_xmlDocument;
48 |
49 | public:
50 | virtual std::string VToString() { return "XmlResourceExtraData"; }
51 | void ParseXml(char* pRawBuffer);
52 | TiXmlElement* GetRoot(void) { return m_xmlDocument.RootElement(); }
53 | };
54 |
55 |
56 | class XmlResourceLoader : public IResourceLoader
57 | {
58 | public:
59 | virtual bool VUseRawFile() { return false; }
60 | virtual bool VDiscardRawBufferAfterLoad() { return true; }
61 | virtual unsigned int VGetLoadedResourceSize(char *rawBuffer, unsigned int rawSize) { return rawSize; }
62 | virtual bool VLoadResource(char *rawBuffer, unsigned int rawSize, shared_ptr handle);
63 | virtual std::string VGetPattern() { return "*.xml"; }
64 |
65 | // convenience function
66 | static TiXmlElement* LoadAndReturnRootXmlElement(const char* resourceString);
67 | };
68 |
69 |
70 |
--------------------------------------------------------------------------------
/Source/GCC4/ResourceCache/ZipFile.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // ZipFile.h : API to use Zip files
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | // --------------------------------------------------------------------------
41 | // File: ZipFile.h
42 | //
43 | // Purpose: The declaration of a quick'n dirty ZIP file reader class.
44 | // Original code from Javier Arevalo.
45 | // Get zlib from http://www.cdrom.com/pub/infozip/zlib/
46 | //
47 | // class ZipFile - Chapter 8, page 214
48 | // --------------------------------------------------------------------------
49 |
50 | #include
51 |
52 | typedef std::map ZipContentsMap; // maps path to a zip content id
53 |
54 | class ZipFile
55 | {
56 | public:
57 | ZipFile() { m_nEntries=0; m_pFile=NULL; m_pDirData=NULL; }
58 | virtual ~ZipFile() { End(); fclose(m_pFile); }
59 |
60 | bool Init(const std::wstring &resFileName);
61 | void End();
62 |
63 | int GetNumFiles()const { return m_nEntries; }
64 | std::string GetFilename(int i) const;
65 | int GetFileLen(int i) const;
66 | bool ReadFile(int i, void *pBuf);
67 |
68 | // Added to show multi-threaded decompression
69 | bool ReadLargeFile(int i, void *pBuf, void (*progressCallback)(int, bool &));
70 |
71 | int Find(const std::string &path) const;
72 |
73 | ZipContentsMap m_ZipContentsMap;
74 |
75 | private:
76 | struct TZipDirHeader;
77 | struct TZipDirFileHeader;
78 | struct TZipLocalHeader;
79 |
80 | FILE *m_pFile; // Zip file
81 | char *m_pDirData; // Raw data buffer.
82 | int m_nEntries; // Number of entries.
83 |
84 | // Pointers to the dir entries in pDirData.
85 | const TZipDirFileHeader **m_papDir;
86 | };
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Source/GCC4/UserInterface/MessageBox.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // MessageBox.h : Defines a modal message dialog
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include
41 |
42 | //
43 | // class MessageBox - Chapter 10, page 286
44 | //
45 | class MessageBox : public BaseUI
46 | {
47 | protected:
48 | CDXUTDialog m_UI; // DirectX dialog
49 | int m_ButtonId;
50 |
51 | public:
52 | MessageBox(std::wstring msg, std::wstring title, int buttonFlags=MB_OK);
53 | ~MessageBox();
54 |
55 | // IScreenElement Implementation
56 | virtual HRESULT VOnRestore();
57 | virtual HRESULT VOnRender(double fTime, float fElapsedTime);
58 | virtual int VGetZOrder() const { return 99; }
59 | virtual void VSetZOrder(int const zOrder) { }
60 |
61 | virtual LRESULT CALLBACK VOnMsgProc( AppMsg msg );
62 | static void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void *pUserContext );
63 | static int Ask(MessageBox_Questions question);
64 |
65 | };
66 |
67 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/GCC4EditorDLL_2015.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4Editor/EditorApp/GCC4EditorDLL_2015.dll
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/Program.cs:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // Program.cs - entry point for the C# Editor
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 | using System;
40 | using System.Collections.Generic;
41 | using System.Windows.Forms;
42 |
43 | namespace EditorApp
44 | {
45 | //
46 | // class Program - Chapter 22, page 768
47 | //
48 | static class Program
49 | {
50 | ///
51 | /// The main entry point for the application.
52 | ///
53 | [STAThread]
54 | static void Main()
55 | {
56 | Application.EnableVisualStyles();
57 | Application.SetCompatibleTextRenderingDefault(false);
58 | EditorForm form = new EditorForm();
59 |
60 | // Hook up our message handler
61 | MessageHandler messageHandler = form.GetMessageHandler();
62 | Application.AddMessageFilter(messageHandler);
63 | Application.Idle += new EventHandler(messageHandler.Application_Idle);
64 | Application.Run(form);
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EditorApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EditorApp")]
13 | [assembly: AssemblyCopyright("Copyright © 2008")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b697a10d-ab42-4a9e-8f9e-40b964a5e03d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace EditorApp.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EditorApp.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace EditorApp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/TeapotWarsEditorApp_2015.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | D:\ProjectsSVN\GameCode4\Dev\Game\
5 | false
6 |
7 |
8 | D:\ProjectsSVN\GameCode4\Dev\Game\
9 | false
10 |
11 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/EditorApp/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/Editor.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4Editor/GCC4EditorDLL/Editor.aps
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/Editor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // Editor.h : source file for the editor application and logic in C++
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 |
41 | //========================================================================
42 | // Content References in Game Coding Complete 4th Edition
43 | //
44 | // class Editor - Chapter 22, page 749
45 | // class EditorLogic - Chapter 22, page 750
46 | //
47 |
48 | #include "..\..\GCC4\GameCode4\GameCode.h"
49 |
50 | #include "..\..\GCC4\Physics\Physics.h"
51 | #include "..\..\GCC4\Physics\PhysicsEventListener.h"
52 | #include "..\..\GCC4\MainLoop\Initialization.h"
53 |
54 | #include "..\..\GCC4\EventManager\Events.h"
55 | #include "..\..\GCC4\EventManager\EventManagerImpl.h"
56 |
57 | #include "EditorHumanView.h"
58 |
59 | using namespace std;
60 |
61 | class EditorLogic;
62 |
63 | class EditorApp : public GameCodeApp
64 | {
65 | public:
66 | EditorApp() : GameCodeApp() { m_bIsEditorRunning = true; }
67 | TCHAR *VGetGameTitle() { return _T("GameCode4 Editor"); }
68 | TCHAR *VGetGameAppDirectory() { return _T("Game Coding Complete 4\\Editor\\1.0"); }
69 | HICON VGetIcon();
70 |
71 | protected:
72 | BaseGameLogic *VCreateGameAndView();
73 | };
74 |
75 |
76 | class EditorLogic : public BaseGameLogic
77 | {
78 | public:
79 | EditorLogic();
80 | ~EditorLogic();
81 |
82 | virtual bool VLoadGame(const char* levelName);
83 | const std::string &GetProjectDirectory(void) { return m_ProjectDirectory; }
84 |
85 | // We need to expose this information so that the C# app can
86 | // know how big of an array to allocate to hold the list of
87 | // actors
88 | int GetNumActors() { return (int)m_actors.size(); }
89 |
90 | // Exposes the actor map so that the global functions
91 | // can retrieve actor information
92 | const ActorMap& GetActorMap() { return m_actors; }
93 |
94 | bool IsRunning() { return (BGS_Running == m_State); }
95 | shared_ptr GetHumanView();
96 |
97 | protected:
98 | std::string m_ProjectDirectory;
99 | };
100 |
101 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/Editor.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4Editor/GCC4EditorDLL/Editor.ico
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/Editor.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "windows.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // English (U.S.) resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19 | #ifdef _WIN32
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 | #pragma code_page(1252)
22 | #endif //_WIN32
23 |
24 | #ifdef APSTUDIO_INVOKED
25 | /////////////////////////////////////////////////////////////////////////////
26 | //
27 | // TEXTINCLUDE
28 | //
29 |
30 | 1 TEXTINCLUDE
31 | BEGIN
32 | "resource.h\0"
33 | END
34 |
35 | 2 TEXTINCLUDE
36 | BEGIN
37 | "#include ""afxres.h""\r\n"
38 | "\0"
39 | END
40 |
41 | 3 TEXTINCLUDE
42 | BEGIN
43 | "\r\n"
44 | "\0"
45 | END
46 |
47 | #endif // APSTUDIO_INVOKED
48 |
49 |
50 | /////////////////////////////////////////////////////////////////////////////
51 | //
52 | // Icon
53 | //
54 |
55 | // Icon with lowest ID value placed first to ensure application icon
56 | // remains consistent on all systems.
57 | IDI_ICON1 ICON "Editor.ico"
58 | #endif // English (U.S.) resources
59 | /////////////////////////////////////////////////////////////////////////////
60 |
61 |
62 |
63 | #ifndef APSTUDIO_INVOKED
64 | /////////////////////////////////////////////////////////////////////////////
65 | //
66 | // Generated from the TEXTINCLUDE 3 resource.
67 | //
68 |
69 |
70 | /////////////////////////////////////////////////////////////////////////////
71 | #endif // not APSTUDIO_INVOKED
72 |
73 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/EditorGlobalFunctions.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/GCC4Editor/GCC4EditorDLL/EditorGlobalFunctions.cpp
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/EditorGlobalFunctions.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // EditorGlobalFunctions.h : exports game engine functions to C++ DLL
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #define DllExport _declspec(dllexport)
41 |
42 | #include "Editor.h"
43 |
44 | //========================================================================
45 | //
46 | // This file contains functions that will be exposed via the dll wrapper
47 | // to the C# app. The functions will be used by the C# app to query information
48 | // about the editor, and to change the editor's scene.
49 | //
50 | // - Chapter 22, page 763
51 | //
52 | //========================================================================
53 |
54 |
55 | // Editor Framework Functions
56 | extern "C" DllExport int EditorMain(int *instancePtrAddress, int *hPrevInstancePtrAddress, int *hWndPtrAddress, int nCmdShow, int screenWidth, int screenHeight);
57 | extern "C" DllExport void WndProc(int *hWndPtrAddress, int msg, int wParam, int lParam);
58 | extern "C" DllExport int IsGameRunning();
59 | extern "C" DllExport void RenderFrame();
60 | extern "C" DllExport int Shutdown();
61 | extern "C" DllExport void OpenLevel( BSTR lFileName );
62 |
63 | // Actor accessor functions
64 | extern "C" DllExport int GetNumActors();
65 | extern "C" DllExport void GetActorList( int *actorIdArrayPtrAddress, int size );
66 | extern "C" DllExport int GetActorXmlSize ( ActorId actorId );
67 | extern "C" DllExport void GetActorXml ( int *actorXmlPtrAddress, ActorId actorId );
68 | extern "C" DllExport int PickActor(int *hWndPtrAddress);
69 |
70 | // Actor Modification functions
71 | extern "C" DllExport int CreateActor( BSTR bstrActorResource );
72 | extern "C" DllExport void ModifyActor ( BSTR bstrActorModificationXML );
73 | extern "C" DllExport void DestroyActor( ActorId actorId );
74 |
75 | // Level script additions - added post press
76 | extern "C" DllExport int GetLevelScriptAdditionsXmlSize ( );
77 | extern "C" DllExport void GetLevelScriptAdditionsXml ( int *xmlPtrAddress );
78 |
79 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/EditorHumanView.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // EditorHumanView.h : Editor's Human View
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "..\..\GCC4\Graphics3D\SceneNodes.h"
41 | #include "..\..\GCC4\EventManager\EventManager.h"
42 | #include "..\..\GCC4\UserInterface\HumanView.h"
43 |
44 | //========================================================================
45 | //
46 | // This will be similar to TeapotWarsView, but will be much more
47 | // streamlined since we don't a HUD, or a main menu screen, or sound
48 | // controllers.
49 | //
50 | //========================================================================
51 |
52 | class EditorController;
53 |
54 | class EditorHumanView : public HumanView
55 | {
56 | public:
57 |
58 | EditorHumanView(shared_ptr renderer);
59 | virtual ~EditorHumanView() { }
60 | virtual void VOnUpdate(unsigned long deltaMilliseconds);
61 | shared_ptr GetScene() { return m_pScene; }
62 |
63 | protected:
64 | shared_ptr m_pFreeCameraController;
65 |
66 | virtual bool VLoadGameDelegate(TiXmlElement* pLevelData) override;
67 | };
68 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/GCC4EditorDLL/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Editor.rc
4 | //
5 | #define IDI_ICON1 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/Msvc/GCC4EditorDLL.cpp:
--------------------------------------------------------------------------------
1 | // TeapotWarsDLL.cpp : Defines the exported functions for the DLL application.
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/Msvc/GCC4EditorDLL_2015.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
11 |
12 |
13 |
14 |
15 |
16 | Resource Files
17 |
18 |
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
37 |
38 | Source Files
39 |
40 |
41 | Source Files
42 |
43 |
44 | Source Files
45 |
46 |
47 | Source Files
48 |
49 |
50 |
51 |
52 | Resource Files
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/Msvc/GCC4EditorDLL_2015.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Source/GCC4Editor/Msvc/GCC4EditorStd.cpp:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GCC4EditorStd.cpp : creates the precompiled header file for C++ Editor DLL
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 |
40 | #include "GCC4EditorStd.h"
--------------------------------------------------------------------------------
/Source/GCC4Editor/Msvc/GCC4EditorStd.h:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GCC4EditorStd.h : precompiled header file for C++ Editor DLL
3 | //
4 | // Part of the GameCode4 Application
5 | //
6 | // GameCode4 is the sample application that encapsulates much of the source code
7 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
8 | // "Rez" Graham, published by Charles River Media.
9 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
10 | //
11 | // If this source code has found it's way to you, and you think it has helped you
12 | // in any way, do the authors a favor and buy a new copy of the book - there are
13 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
14 | // by clicking here:
15 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
16 | //
17 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
18 | //
19 | // The source code is managed and maintained through Google Code:
20 | // http://code.google.com/p/gamecode4/
21 | //
22 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
23 | //
24 | // This program is free software; you can redistribute it and/or
25 | // modify it under the terms of the GNU Lesser GPL v3
26 | // as published by the Free Software Foundation.
27 | //
28 | // This program is distributed in the hope that it will be useful,
29 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
31 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
32 | //
33 | // You should have received a copy of the GNU Lesser GPL v3
34 | // along with this program; if not, write to the Free Software
35 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | //
37 | //========================================================================
38 |
39 |
40 |
41 | #include "../../GCC4/Msvc/GameCodeStd.h"
42 |
43 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | WIN32 APPLICATION : TeapotWars_2015 Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this TeapotWars_2015 application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your TeapotWars_2015 application.
9 |
10 |
11 | TeapotWars_2015.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | TeapotWars_2015.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 | TeapotWars_2015.cpp
25 | This is the main application source file.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | AppWizard has created the following resources:
29 |
30 | TeapotWars_2015.rc
31 | This is a listing of all of the Microsoft Windows resources that the
32 | program uses. It includes the icons, bitmaps, and cursors that are stored
33 | in the RES subdirectory. This file can be directly edited in Microsoft
34 | Visual C++.
35 |
36 | Resource.h
37 | This is the standard header file, which defines new resource IDs.
38 | Microsoft Visual C++ reads and updates this file.
39 |
40 | TeapotWars_2015.ico
41 | This is an icon file, which is used as the application's icon (32x32).
42 | This icon is included by the main resource file TeapotWars_2015.rc.
43 |
44 | small.ico
45 | This is an icon file, which contains a smaller version (16x16)
46 | of the application's icon. This icon is included by the main resource
47 | file TeapotWars_2015.rc.
48 |
49 | /////////////////////////////////////////////////////////////////////////////
50 | Other standard files:
51 |
52 | StdAfx.h, StdAfx.cpp
53 | These files are used to build a precompiled header (PCH) file
54 | named TeapotWars_2015.pch and a precompiled types file named StdAfx.obj.
55 |
56 | /////////////////////////////////////////////////////////////////////////////
57 | Other notes:
58 |
59 | AppWizard uses "TODO:" comments to indicate parts of the source code you
60 | should add to or customize.
61 |
62 | /////////////////////////////////////////////////////////////////////////////
63 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/Resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by TeapotWars_2015.rc
4 | //
5 |
6 | #define IDS_APP_TITLE 103
7 |
8 | #define IDR_MAINFRAME 128
9 | #define IDD_TEAPOTWARS_2015_DIALOG 102
10 | #define IDD_ABOUTBOX 103
11 | #define IDM_ABOUT 104
12 | #define IDM_EXIT 105
13 | #define IDI_TEAPOTWARS_2015 107
14 | #define IDI_SMALL 108
15 | #define IDC_TEAPOTWARS_2015 109
16 | #define IDC_MYICON 2
17 | #ifndef IDC_STATIC
18 | #define IDC_STATIC -1
19 | #endif
20 | // Next default values for new objects
21 | //
22 | #ifdef APSTUDIO_INVOKED
23 | #ifndef APSTUDIO_READONLY_SYMBOLS
24 |
25 | #define _APS_NO_MFC 130
26 | #define _APS_NEXT_RESOURCE_VALUE 129
27 | #define _APS_NEXT_COMMAND_VALUE 32771
28 | #define _APS_NEXT_CONTROL_VALUE 1000
29 | #define _APS_NEXT_SYMED_VALUE 110
30 | #endif
31 | #endif
32 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotResources.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by TeapotWars.rc
4 | //
5 | #define IDI_ICON1 101
6 | #define IDI_MAIN_ICON 101
7 |
8 | // Next default values for new objects
9 | //
10 | #ifdef APSTUDIO_INVOKED
11 | #ifndef APSTUDIO_READONLY_SYMBOLS
12 | #define _APS_NEXT_RESOURCE_VALUE 102
13 | #define _APS_NEXT_COMMAND_VALUE 40001
14 | #define _APS_NEXT_CONTROL_VALUE 1001
15 | #define _APS_NEXT_SYMED_VALUE 101
16 | #endif
17 | #endif
18 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "TeapotResources.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "windows.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // English (U.S.) resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19 | #ifdef _WIN32
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 | #pragma code_page(1252)
22 | #endif //_WIN32
23 |
24 | #ifdef APSTUDIO_INVOKED
25 | /////////////////////////////////////////////////////////////////////////////
26 | //
27 | // TEXTINCLUDE
28 | //
29 |
30 | 1 TEXTINCLUDE
31 | BEGIN
32 | "TeapotResources.h\0"
33 | END
34 |
35 | 2 TEXTINCLUDE
36 | BEGIN
37 | "#include ""afxres.h""\r\n"
38 | "\0"
39 | END
40 |
41 | 3 TEXTINCLUDE
42 | BEGIN
43 | "\r\n"
44 | "\0"
45 | END
46 |
47 | #endif // APSTUDIO_INVOKED
48 |
49 |
50 | /////////////////////////////////////////////////////////////////////////////
51 | //
52 | // Icon
53 | //
54 |
55 | // Icon with lowest ID value placed first to ensure application icon
56 | // remains consistent on all systems.
57 | IDI_MAIN_ICON ICON "teapot.ico"
58 |
59 | /////////////////////////////////////////////////////////////////////////////
60 | //
61 | // Version
62 | //
63 |
64 | VS_VERSION_INFO VERSIONINFO
65 | FILEVERSION 2,3,0,339
66 | PRODUCTVERSION 2,3,0,339
67 | FILEFLAGSMASK 0x17L
68 | #ifdef _DEBUG
69 | FILEFLAGS 0x1L
70 | #else
71 | FILEFLAGS 0x0L
72 | #endif
73 | FILEOS 0x4L
74 | FILETYPE 0x7L
75 | FILESUBTYPE 0x0L
76 | BEGIN
77 | BLOCK "StringFileInfo"
78 | BEGIN
79 | BLOCK "040904b0"
80 | BEGIN
81 | VALUE "FileDescription", "Teapot Wars"
82 | VALUE "FileVersion", "2, 3, 0, 339"
83 | VALUE "InternalName", "Teapot Wars"
84 | VALUE "LegalCopyright", "Copyright (C) 2006"
85 | VALUE "OriginalFilename", "TeapotWars.exe"
86 | VALUE "ProductName", "Teapot Wars"
87 | VALUE "ProductVersion", "2, 3, 0, 339"
88 | END
89 | END
90 | BLOCK "VarFileInfo"
91 | BEGIN
92 | VALUE "Translation", 0x409, 1200
93 | END
94 | END
95 |
96 | #endif // English (U.S.) resources
97 | /////////////////////////////////////////////////////////////////////////////
98 |
99 |
100 |
101 | #ifndef APSTUDIO_INVOKED
102 | /////////////////////////////////////////////////////////////////////////////
103 | //
104 | // Generated from the TEXTINCLUDE 3 resource.
105 | //
106 |
107 |
108 | /////////////////////////////////////////////////////////////////////////////
109 | #endif // not APSTUDIO_INVOKED
110 |
111 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWarsStd.cpp:
--------------------------------------------------------------------------------
1 |
2 | // Create the TeapotWarsStd.pch file
3 |
4 | #include "TeapotWarsStd.h"
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWarsStd.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "../../GCC4/Msvc/GameCodeStd.h"
4 |
5 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars_2015.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "resource.h"
4 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars_2015.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/TeapotWars/Msvc/TeapotWars_2015.ico
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars_2015.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/TeapotWars/Msvc/TeapotWars_2015.rc
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars_2015.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | TeapotWars
7 |
8 |
9 | TeapotWars
10 |
11 |
12 | TeapotWars
13 |
14 |
15 | TeapotWars
16 |
17 |
18 | Application
19 |
20 |
21 | Application
22 |
23 |
24 | Application
25 |
26 |
27 |
28 |
29 | {09e969fd-62b9-4ebd-b2cc-a7d4e06dc2a0}
30 |
31 |
32 | {07571a94-ffad-4192-84ee-6e22a66744a0}
33 |
34 |
35 |
36 |
37 | TeapotWars
38 |
39 |
40 | TeapotWars
41 |
42 |
43 | TeapotWars
44 |
45 |
46 | TeapotWars
47 |
48 |
49 | Application
50 |
51 |
52 |
53 |
54 | Application
55 |
56 |
57 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/TeapotWars_2015.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ..\..\..\Game
5 | WindowsLocalDebugger
6 | false
7 |
8 |
9 | ..\..\..\Game
10 | WindowsLocalDebugger
11 |
12 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/small.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/TeapotWars/Msvc/small.ico
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // TeapotWars_2015.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11 | // Windows Header Files:
12 | #include
13 |
14 | // C RunTime Header Files
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 |
21 | // TODO: reference additional headers your program requires here
22 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/Source/TeapotWars/Msvc/teapot.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MikeMcShaffry/gamecode4/5837cbc520c9625d6b9f7301690d88efc1808a48/Source/TeapotWars/Msvc/teapot.ico
--------------------------------------------------------------------------------
/Source/TeapotWars/TeapotController.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // File: TeapotController.h
4 | //
5 | // Part of the GameCode4 Application
6 | //
7 | // GameCode4 is the sample application that encapsulates much of the source code
8 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
9 | // "Rez" Graham, published by Charles River Media.
10 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
11 | //
12 | // If this source code has found it's way to you, and you think it has helped you
13 | // in any way, do the authors a favor and buy a new copy of the book - there are
14 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
15 | // by clicking here:
16 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
17 | //
18 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
19 | //
20 | // The source code is managed and maintained through Google Code:
21 | // http://code.google.com/p/gamecode4/
22 | //
23 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
24 | //
25 | // This program is free software; you can redistribute it and/or
26 | // modify it under the terms of the GNU Lesser GPL v3
27 | // as published by the Free Software Foundation.
28 | //
29 | // This program is distributed in the hope that it will be useful,
30 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
32 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
33 | //
34 | // You should have received a copy of the GNU Lesser GPL v3
35 | // along with this program; if not, write to the Free Software
36 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 | //
38 | //========================================================================
39 |
40 | #include "../GCC4/GameCode4/Interfaces.h"
41 |
42 | class SceneNode;
43 |
44 | class TeapotController : public IPointerHandler, public IKeyboardHandler
45 | {
46 | protected:
47 | BYTE m_bKey[256]; // Which keys are up and down
48 | shared_ptr m_object;
49 |
50 | public:
51 | TeapotController(shared_ptr object);
52 | // void SetObject(shared_ptr newObject);
53 |
54 | void OnUpdate(DWORD const elapsedMs);
55 |
56 | public:
57 | virtual bool VOnPointerMove(const Point &mousePos, const int radius) { return true; }
58 | virtual bool VOnPointerButtonDown(const Point &mousePos, const int radius, const std::string &buttonName);
59 | virtual bool VOnPointerButtonUp(const Point &mousePos, const int radius, const std::string &buttonName) { return (buttonName == "PointerLeft"); }
60 |
61 | bool VOnKeyDown(const BYTE c);
62 | bool VOnKeyUp(const BYTE c);
63 | };
64 |
65 |
--------------------------------------------------------------------------------
/Source/TeapotWars/TeapotWarsNetwork.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //========================================================================
3 | // TeapotWarsNetwork.h : source file for the sample game
4 | //
5 | // GameCode4 is the sample application that encapsulates much of the source code
6 | // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
7 | // "Rez" Graham, published by Charles River Media.
8 | // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
9 | //
10 | // If this source code has found it's way to you, and you think it has helped you
11 | // in any way, do the authors a favor and buy a new copy of the book - there are
12 | // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
13 | // by clicking here:
14 | // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
15 | //
16 | // There's a companion web site at http://www.mcshaffry.com/GameCode/
17 | //
18 | // The source code is managed and maintained through Google Code:
19 | // http://code.google.com/p/gamecode4/
20 | //
21 | // (c) Copyright 2012 Michael L. McShaffry and David Graham
22 | //
23 | // This program is free software; you can redistribute it and/or
24 | // modify it under the terms of the GNU Lesser GPL v3
25 | // as published by the Free Software Foundation.
26 | //
27 | // This program is distributed in the hope that it will be useful,
28 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
29 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
30 | // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
31 | //
32 | // You should have received a copy of the GNU Lesser GPL v3
33 | // along with this program; if not, write to the Free Software
34 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 | //
36 | //========================================================================
37 |
38 | #include "../GCC4/GameCode4/GameCode.h"
39 | #include "../GCC4/Network/Network.h"
40 | #include "TeapotWars.h"
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------