Arcade Shooter
SmokeTemplate.h
1 
2 /* .oooooo..o .o. ooo ooooo ooooooooo. ooooo oooooooooooo
3  d8P' `Y8 .888. `88. .888' `888 `Y88. `888' `888' `8
4  Y88bo. .8"888. 888b d'888 888 .d88' 888 888
5  `"Y8888o. .8' `888. 8 Y88. .P 888 888ooo88P' 888 888oooo8
6  `"Y88b .88ooo8888. 8 `888' 888 888 888 888 "
7  oo .d8P .8' `888. 8 Y 888 888 888 o 888 o
8  8""88888P' o88o o8888o o8o o888o o888o o888ooooood8 o888ooooood8
9 
10  Sample © 2017 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace Sample
15 {
16 
18  template <typename T>
19  class SmokeTemplate : public ParticleTemplate
20  {
21 
22  public:
23 
25  {
26  GenerateParticles<T>(100);
27  SetParticleLifespan(1);
28  }
29 
30  virtual ~SmokeTemplate() { }
31 
32 
35  virtual void InitializeParticle(Particle *pParticle)
36  {
37  RotatingParticle *pT = (RotatingParticle *)pParticle;
38  assert(pT && "Type of template T is not compatible.");
39 
40  ParticleTemplate::InitializeParticle(pT);
41 
42  pT->SetScale(Vector2::One * 0.1f);
43  pT->SetAlpha(0.125f);
44 
45  pT->SetRotation(Math::GetRandomFloat() * Math::PI * 2);
46  pT->SetRotationVelocity(Math::GetRandomFloat() * 0.2f - 0.1f);
47 
48  pT->SetPosition(pT->GetPosition() + Vector2::GetRandom(true) * 2);
49  }
50 
51 
55  virtual void UpdateParticle(Particle *pParticle, const GameTime *pGameTime)
56  {
57  RotatingParticle *pT = (RotatingParticle *)pParticle;
58  assert(pT && "Type of template T is not compatible.");
59 
60  float value = pT->GetInterpolationValue();
61  float scale = (1 - value) * 0.25f + 0.1f;
62  pT->SetScale(Vector2::One * scale);
63  pT->SetAlpha(value * 0.125f);
64 
65  float rotation = pT->GetRotation() + pT->GetRotationVelocity();
66 
67  pT->SetRotation(rotation);
68  }
69 
72  virtual Particle *GetInactiveParticle()
73  {
74  return GetInactiveParticleOfType<T>();
75  }
76  };
77 }
Sample is a sample game to use as a template for using Katana Engine and Shooter Library.
Definition: Background.cpp:14
virtual Particle * GetInactiveParticle()
Gets an inactive particle to reuse.
Definition: SmokeTemplate.h:72
virtual void InitializeParticle(Particle *pParticle)
Initaializes the particle. This runs when a particle is emitted.
Definition: SmokeTemplate.h:35
Template for smoke particles.
Definition: SmokeTemplate.h:19
virtual void UpdateParticle(Particle *pParticle, const GameTime *pGameTime)
Updates the particle.
Definition: SmokeTemplate.h:55