32 virtual void LoadContent(ResourceManager *pResourceManager);
41 virtual void Update(
const GameTime *pGameTime);
45 virtual void Draw(SpriteBatch *pSpriteBatch);
71 float squaredRange = range * range;
76 squaredRange = w * w + h * h;
78 float squaredDistance;
80 std::vector<GameObject *>::iterator m_it = m_gameObjects.begin();
81 T *pClosest =
nullptr;
83 for (; m_it != m_gameObjects.end(); m_it++)
86 if (!pGameObject->
IsActive())
continue;
88 squaredDistance = (position - pGameObject->
GetPosition()).LengthSquared();
89 if (squaredDistance < squaredRange)
91 T *pObject =
dynamic_cast<T *
>(pGameObject);
95 squaredRange = squaredDistance;
129 std::vector<GameObject *> *m_pSectors;
131 Vector2 m_sectorCount;
132 Vector2 m_sectorSize;
134 unsigned int m_totalSectorCount;
136 std::vector<GameObject *> m_gameObjects;
137 std::vector<GameObject *>::iterator m_gameObjectIt;
139 ALLEGRO_SAMPLE *m_pSample;
140 ALLEGRO_SAMPLE_ID m_sampleID;
142 std::vector<ProjectilePool *> m_pProjectilePools;
146 void CheckCollisions(std::vector<GameObject *> §or);
148 virtual Vector2 GetSectorCount()
const {
return m_sectorCount; }
150 virtual Vector2 GetSectorSize()
const {
return m_sectorSize; }
152 virtual unsigned int GetTotalSectorCount()
const {
return m_totalSectorCount; }
154 virtual std::vector<GameObject *> *GetSectors() {
return m_pSectors; }
Used to recycle projectiles.
Definition: ProjectilePool.h:20
virtual ParticleManager * GetParticleManager() const =0
Gets the ParticleManager for loading the level's resources.
virtual void Complete()
Should be called when the victory conditions are met for the level.
Definition: Level.h:53
Handles collisions between game objects.
Definition: CollisionManager.h:30
virtual void UpdateSectorPosition(GameObject *pGameObject)
Updates an object's position on the sector grid.
Definition: Level.cpp:159
static int GetScreenHeight()
Gets the screen width in pixels.
Definition: Game.h:37
Base class for all shooter levels.
Definition: Level.h:21
virtual void Update(const GameTime *pGameTime)
Called when the game has determined that game logic needs to be processed.
virtual void AddGameObject(GameObject *pGameObject)
Adds a game object so it can be managed by the level.
Definition: Level.h:50
Base class for all objects that will be updated and rendered on a GameplayScreen. ...
Definition: GameObject.h:29
Shooter Library is a library of classes, interfaces, and value types that provides a foundation for d...
Definition: Background.h:16
virtual void AddProjectilePool(ProjectilePool *pProjectilePool)
Adds a pool of projectiles to the level.
Definition: Level.h:119
virtual CollisionManager * GetCollisionManager()
Gets the CollisionManager for testing collisions between game objects.
Definition: Level.h:111
virtual Vector2 & GetPosition()
Gets the position of the game object.
Definition: GameObject.h:78
virtual void UnloadContent()
Called when resources need to be unloaded. Override this method to unload any game-specific resources...
Definition: Level.cpp:67
virtual void LoadContent(ResourceManager *pResourceManager)
Called when resources need to be loaded.
virtual void InitializeCollisionManager()
Initailizes the level's default CollisionManager.
Definition: Level.h:107
virtual void Draw(SpriteBatch *pSpriteBatch)
Called when the game determines it is time to draw a frame.
virtual void SetBackground(Background *pBackground)
Sets the background object for the level.
Definition: Level.h:123
T * GetClosestObject(const Vector2 position, const float range)
Get the closest active game object of a specific type.
Definition: Level.h:69
static int GetScreenWidth()
Gets the screen width in pixels.
Definition: Game.h:33
Abstract base class for a scrolling background.
Definition: Background.h:20
virtual bool IsActive() const
Determines if the game object is active.
Definition: GameObject.h:68