From 2e6369f4dbe2b49a3cb8bec3bacd6559c9733a55 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 2 Jun 2016 07:20:09 -0400 Subject: optimizations --- include/entities.hpp | 118 ++++++++++++++++++++++++++------------------------- include/world.hpp | 2 +- 2 files changed, 61 insertions(+), 59 deletions(-) (limited to 'include') diff --git a/include/entities.hpp b/include/entities.hpp index 5a8e19b..61ecc43 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -106,64 +106,6 @@ extern const unsigned int NPC_INV_SIZE; // a prototype of the world class, necessary for some function prototypes class World; -/** - * The particle class, handles a single particle. - */ -class Particles{ -public: - // the location of the particle - vec2 loc; - float zOffset; - - // the width of the particle, in pixels - float width; - - // the height of the particle, in pixels - float height; - - // the velocity of the particle, in pixels - vec2 vel; - - // the color of the particle - Color color; - - // TODO - vec2 index; - - // the amount of milliseconds left for the particle to live - float duration; - - // when true, the particle will move - bool canMove; - - // TODO - bool fountain; - - // when true, the particle will be affected by gravity - bool gravity; - - // when true, draws the particle behind structures - bool behind; - - // when true, the particle will bounce on impact with ground - bool bounce; - - // creates a particle with the desired characteristics - Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d); - - // allows the particle to be destroyed - ~Particles(void){} - - // draws the particle - void draw(GLfloat*& p) const; - - // updates a particle - void update(float _gravity, float ground_y); - - // returns true if the particle should be killed - bool kill(float delta); -}; - /** * The entity class. * This class contains common functions and variables for all types of @@ -433,6 +375,66 @@ public: void createFromXML(XMLElement *e); }; +/** + * The particle class, handles a single particle. + */ +class Particles{ +public: + // the location of the particle + vec2 loc; + float zOffset; + + // the width of the particle, in pixels + float width; + + // the height of the particle, in pixels + float height; + + // the velocity of the particle, in pixels + vec2 vel; + + // the color of the particle + Color color; + + // TODO + vec2 index; + + // the amount of milliseconds left for the particle to live + float duration; + + // when true, the particle will move + bool canMove; + + // TODO + bool fountain; + + // when true, the particle will be affected by gravity + bool gravity; + + // when true, draws the particle behind structures + bool behind; + + // when true, the particle will bounce on impact with ground + bool bounce; + + Structures *stu; + + // creates a particle with the desired characteristics + Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d); + + // allows the particle to be destroyed + ~Particles(void){} + + // draws the particle + void draw(GLfloat*& p) const; + + // updates a particle + void update(float _gravity, float ground_y); + + // returns true if the particle should be killed + bool timeUp(void); +}; + #include constexpr Object *Objectp(Entity *e) { diff --git a/include/world.hpp b/include/world.hpp index f6a432d..2494120 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -256,7 +256,7 @@ protected: * * @see addParticle() */ - std::vector particles; + std::list particles; /** * A vector of all structures in the world. -- cgit v1.2.3