Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
ParticlePool.cpp
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#include "KatanaEngine.h"
16
17namespace KatanaEngine
18{
19
21 {
22 m_pUpdater = pUpdater;
23 m_pRenderer = pRenderer;
24 }
25
27 {
28 for (IParticle* pParticle : m_particles) delete pParticle;
29
30 delete m_pUpdater;
31 delete m_pRenderer;
32 }
33
34 void ParticlePool::Update(const GameTime& gameTime)
35 {
36 m_particlesIt = m_particles.begin();
37 for (; m_particlesIt != m_particles.end(); m_particlesIt++)
38 {
39 IParticle* pParticle = *m_particlesIt;
40 if (!pParticle->IsActive()) continue;
41 m_pUpdater->Update(pParticle, gameTime);
42 }
43 }
44
46 {
47 m_particlesIt = m_particles.begin();
48 for (; m_particlesIt != m_particles.end(); m_particlesIt++)
49 {
50 IParticle* pParticle = *m_particlesIt;
51 if (!pParticle->IsActive()) continue;
52 m_pRenderer->Draw(pParticle, spriteBatch);
53 }
54 }
55
57 {
58 m_particlesIt = m_particles.begin();
59 for (; m_particlesIt != m_particles.end(); m_particlesIt++)
60 {
61 IParticle* pParticle = *m_particlesIt;
62 if (!pParticle->IsActive()) return pParticle;
63 }
64
65 return nullptr;
66 }
67
68}
Contains timing values for game updates and rendering.
Definition GameTime.h:21
Interface for a particle.
Definition IParticle.h:24
virtual bool IsActive() const =0
Interface for a particle renderer.
virtual void Draw(IParticle *pParticle, SpriteBatch &spriteBatch) const =0
Draws the particle.
Interface for a particle updater.
virtual void Update(IParticle *pParticle, const GameTime &gameTime) const =0
Updates a particle.
virtual void Update(const GameTime &gameTime)
ParticlePool(IParticleUpdater *pUpdater, IParticleRenderer *pRenderer)
Creates a new instance of ParticlePool.
virtual IParticle * GetInactiveParticle()
virtual void Draw(SpriteBatch &spriteBatch)
Enables a group of sprites to be drawn using the same settings.
Definition SpriteBatch.h:48
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18