TeapotWars.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. //========================================================================
  3. // TeapotWars.h : source file for the sample game
  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. #include "TeapotWarsStd.h"
  40. #include "../../GCC4/EventManager/EventManager.h"
  41. #include <SDL3/SDL.h>
  42. class PathingGraph;
  43. class IEventManager;
  44. //---------------------------------------------------------------------------------------------------------------------
  45. // TeapotWarsApp class - Chapter 21, page 722
  46. // Note: Don't put anything in this class that needs to be destructed
  47. //---------------------------------------------------------------------------------------------------------------------
  48. class TeapotWarsApp : public GameCodeApp
  49. {
  50. protected:
  51. virtual BaseGameLogic *VCreateGameAndView();
  52. public:
  53. virtual std::string VGetGameTitle() { return "Teapot Wars"; }
  54. // virtual TCHAR *VGetGameAppDirectory() { return _T("Game Coding Complete 4\\Teapot Wars\\4.0"); }
  55. // virtual SDL_Surface* VGetIcon();
  56. };
  57. //---------------------------------------------------------------------------------------------------------------------
  58. // TeapotWarsLogic class - Chapter 21, page 723
  59. //---------------------------------------------------------------------------------------------------------------------
  60. class TeapotWarsLogic : public BaseGameLogic
  61. {
  62. public:
  63. TeapotWarsLogic();
  64. virtual ~TeapotWarsLogic();
  65. // Overloads
  66. virtual void VChangeState(BaseGameState newState);
  67. virtual void VAddView(std::shared_ptr<IGameView> pView, ActorId actorId=INVALID_ACTOR_ID);
  68. // virtual shared_ptr<IGamePhysics> VGetGamePhysics(void) { return m_pPhysics; }
  69. // event delegates
  70. void RequestStartGameDelegate(IEventDataPtr pEventData);
  71. // void RemoteClientDelegate(IEventDataPtr pEventData);
  72. // void NetworkPlayerActorAssignmentDelegate(IEventDataPtr pEventData);
  73. void EnvironmentLoadedDelegate(IEventDataPtr pEventData);
  74. // void ThrustDelegate(IEventDataPtr pEventData);
  75. // void SteerDelegate(IEventDataPtr pEventData);
  76. // void StartThrustDelegate(IEventDataPtr pEventData);
  77. // void EndThrustDelegate(IEventDataPtr pEventData);
  78. // void StartSteerDelegate(IEventDataPtr pEventData);
  79. // void EndSteerDelegate(IEventDataPtr pEventData);
  80. void TestScriptDelegate(IEventDataPtr pEventData);
  81. protected:
  82. virtual bool VLoadGameDelegate(TiXmlElement* pLevelData);
  83. private:
  84. void RegisterAllDelegates(void);
  85. void RemoveAllDelegates(void);
  86. };