Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
ParticleRenderer.h
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#pragma once
16
17#include "KatanaEngine.h"
18
19
20namespace KatanaEngine
21{
22
23 // /** @brief Basic particle updater. */
25 {
26
27 public:
28
32 virtual void Draw(IParticle* pParticle, SpriteBatch& spriteBatch) const
33 {
34 if (!m_pTexture) {
35 std::cout << "No texture set for particle renderer!\n";
36 return;
37 }
38
39 Particle* pP = (Particle*)pParticle;
40 Vector2 position = pP->GetPosition();
41 Color color = pP->GetColor();
42 float scale = pP->GetScale();
43 spriteBatch.Draw(m_pTexture, position, color, m_pTexture->GetCenter(), Vector2::ONE * scale);
44 }
45
48 void SetTexture(Texture* pTexture) { m_pTexture = pTexture; }
49
50
51 private:
52
53 Texture* m_pTexture = nullptr;
54
55
56 };
57
58}
Represents a four-component color using red, green, blue, and alpha data.
Definition Color.h:21
Interface for a particle.
Definition IParticle.h:24
Interface for a particle renderer.
Instantiate a basic particle.
Definition Particle.h:24
virtual float GetScale() const
Gets the scale of the particle.
Definition Particle.h:49
virtual Vector2 GetPosition() const
Gets the position of the particle.
Definition Particle.h:37
virtual Color GetColor() const
Gets the color of the particle.
Definition Particle.h:45
Basic particle updater.
void SetTexture(Texture *pTexture)
Sets the texture to use when rendering the particle.
virtual void Draw(IParticle *pParticle, SpriteBatch &spriteBatch) const
Draws the particle.
Enables a group of sprites to be drawn using the same settings.
Definition SpriteBatch.h:48
void Draw(const Texture *pTexture, const Vector2 position, const Region region, const Color color=Color::White, const Vector2 origin=Vector2::ZERO, const Vector2 scale=Vector2::ONE, const float rotation=0, const float drawDepth=0)
Adds a sprite to a batch of sprites to be rendered.
Represents a 2D grid of texels.
Definition Texture.h:21
Vector2 GetCenter() const
Gets the center position of the texture.
Definition Texture.h:48
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
static const Vector2 ONE
A vector with both of its components set to one.
Definition Vector2.h:32
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18