80 float squaredRange = range * range;
85 squaredRange = w * w + h * h;
87 float squaredDistance;
89 std::vector<GameObject*>::iterator m_it = m_gameObjects.begin();
90 T* pClosest =
nullptr;
92 for (; m_it != m_gameObjects.end(); m_it++)
95 if (pGameObject->
IsActive())
continue;
97 squaredDistance = (position - pGameObject->
GetPosition()).LengthSquared();
98 if (squaredDistance < squaredRange)
100 T* pObject =
dynamic_cast<T*
>(pGameObject);
104 squaredRange = squaredDistance;
133 static std::vector<Explosion *> s_explosions;
134 std::vector<Explosion *>::iterator m_explosionIt;
142 Texture* m_pBackground =
nullptr;
144 std::vector<GameObject*>* m_pSectors;
149 unsigned int m_totalSectorCount = 0;
151 std::vector<GameObject*> m_gameObjects;
152 std::vector<GameObject*>::iterator m_gameObjectIt;
155 std::vector<Projectile*> m_projectiles;
157 void CheckCollisions(std::vector<GameObject*>& sector);
159 virtual Vector2 GetSectorCount()
const {
return m_sectorCount; }
161 virtual Vector2 GetSectorSize()
const {
return m_sectorSize; }
163 virtual unsigned int GetTotalSectorCount()
const {
return m_totalSectorCount; }
165 virtual std::vector<GameObject*>* GetSectors() {
return m_pSectors; }
Represents a collision manager that can be used to manage collisions between game objects.
Represents a game object in the game. This is the base class for all objects that can be updated,...
virtual bool IsActive() const
Flag to determine if the object is active.
virtual Vector2 & GetPosition()
Get the position of the object.
The gameplay screen for the Space Fighter Game. It is responsible for creating and loading levels.
Represents a 2D grid of texels.
static int GetScreenHeight()
Gets the screen width in pixels.
static int GetScreenWidth()
Gets the screen width in pixels.
Contains timing values for game updates and rendering.
Loads and manages the lifespan of objects from external files.
Enables a group of sprites to be drawn using the same settings.
Represents a 2D grid of texels.
Defines a vector with 2 components (x and y).
Represents a level in the game.
virtual void UnloadContent()
Unload the content for the level.
virtual void SetBackgroundAudio(AudioSample *pAudio)
Set the background audio for the level.
virtual void AddGameObject(GameObject *pGameObject)
Add a game object to the level. This object will be updated, rendered, and checked for collisions.
virtual AudioSample * GetBackgroundAudio()
Get the background audio for the level.
virtual void SpawnExplosion(GameObject *pExplodingObject)
Spawn an explosion at a specific position.
virtual GameplayScreen * GetGameplayScreen() const
Get a pointer to the gameplay screen.
Level()
Instantiate a level object.
virtual void Draw(SpriteBatch &spriteBatch)
Render the level, and all of the game objects within it.
virtual void LoadContent(ResourceManager &resourceManager)
Load the content for the level, including game objects and resources.
virtual bool IsScreenTransitioning() const
Check if the screen is transitioning.
virtual void SetGameplayScreen(GameplayScreen *pGameplayScreen)
Set a reference to the gameplay screen.
virtual void Update(const GameTime &gameTime)
Update the level.
T * GetClosestObject(const Vector2 position, const float range)
Get a pointer to the closest object of a specific type.
virtual void SetBackground(Texture *pBackground)
Set the background texture for the level.
virtual float GetAlpha() const
Get the alpha value of the screen.
virtual CollisionManager * GetCollisionManager()
Get a pointer to the collision manager.
virtual void UpdateSectorPosition(GameObject *pGameObject)
Update the position of a game object within the level, based on its collision sector (only objects wi...
virtual void HandleInput(const InputState &input)
Handle input for the level.
Represents the player's ship.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...