Particle Game Maker Engine  1.0.0
Enables the user to create their own particle game using a simple and coherent api in the PongChamp scripting language
ParticleSpacialPartitioner.h
Go to the documentation of this file.
1 #ifndef PARTICLE_SPACIAL_PARTITIONER_H
2 #define PARTICLE_SPACIAL_PARTITIONER_H
3 
4 #include "ParticleGroupHandle.h"
5 #include "engine_graphics_api.h"
6 #include "QuadTree.h"
7 #include <map>
8 #include <queue>
9 
10 struct Particle
11 {
12  int x, y, m_group;
13 };
14 
17 {
18 public:
20  static int startUp(GraphicsAPI::GraphicsProgram *graphicsProg);
21 
26  static void addParticle(int x, int y, ParticleGroupHandle* groupRef);
27 
29  static void draw();
30 
32  static void update();
33 
35  static void deleteFromParticle();
36 
38  static void deleteToParticle();
39 
41  static void deleteUpdate();
42 
44  static void moveThisParticle(int x, int y);
45 
47  static void moveFromParticle(int x, int y);
48 
50  static void moveToParticle(int x, int y);
51 
53  static void updateChangeGroup(ParticleGroupHandle* changeTo);
54 
56  static void collideChangeGroupTo(ParticleGroupHandle* changeTo);
57 
59  static void collideChangeGroupFrom(ParticleGroupHandle* changeTo);
60 
62  static int nextNodeID;
63 
64 
66  void operator=(const ParticleSpacialPartitioner &) = delete;
67 
68 private:
69  ParticleSpacialPartitioner() = default;
70  GraphicsAPI::GraphicsProgram *graphics;
72  QuadTree *base;
73 
75  QuadTree *currentQuad;
76 
78  Node *currentNode;
79 
81  Node *toNode;
82  void updateQuadTree(QuadTree* quad);
83 
84  std::queue<std::pair<QuadTree*, std::pair<Node*, Point>>> queuedMoves; // Quadtree to remove from, (oldPoint, newPoint)
85 
87  std::queue<Node*> queuedAdds;
88 
90  static ParticleSpacialPartitioner &instance();
91 };
92 
93 #endif
objects stored in quadtree
Definition: QuadTree.h:22
void operator=(const ParticleSpacialPartitioner &) = delete
static int nextNodeID
the unique ID of the next node to be spawned maintained by this class and incremented everytime a ne...
Definition: ParticleSpacialPartitioner.h:62
A class to represent QuadTree.
Definition: QuadTree.h:50
static void collideChangeGroupFrom(ParticleGroupHandle *changeTo)
called by collide function class to change the from particle type
Definition: ParticleSpacialPartitioner.cpp:324
static void collideChangeGroupTo(ParticleGroupHandle *changeTo)
called by collide function class to change the To particle type
Definition: ParticleSpacialPartitioner.cpp:317
static void updateChangeGroup(ParticleGroupHandle *changeTo)
called by update function class changeParticle type
Definition: ParticleSpacialPartitioner.cpp:310
static void deleteToParticle()
called by collisionFunction class to delete the FromParticle in a collision
Definition: ParticleSpacialPartitioner.cpp:207
static void deleteFromParticle()
called by collisionFunction class to delete the FromParticle in a collision
Definition: ParticleSpacialPartitioner.cpp:199
static void moveThisParticle(int x, int y)
called by updateFunction class to move a particle while psp is iterating through tree
Definition: ParticleSpacialPartitioner.cpp:221
static void update()
update all particles of the tree
Definition: ParticleSpacialPartitioner.cpp:157
static void draw()
draw the state of the game
Definition: ParticleSpacialPartitioner.cpp:186
static void addParticle(int x, int y, ParticleGroupHandle *groupRef)
Definition: ParticleSpacialPartitioner.cpp:192
static int startUp(GraphicsAPI::GraphicsProgram *graphicsProg)
start up spatial partitioner
Definition: ParticleSpacialPartitioner.cpp:163
A class to maintain the state of the particle game as a series of spacially partitioned QuadTrees...
Definition: ParticleSpacialPartitioner.h:16
static void deleteUpdate()
called by updateFunction class to delete a particle on update
Definition: ParticleSpacialPartitioner.cpp:215
Definition: ParticleGroupHandle.h:29
int m_group
Definition: ParticleSpacialPartitioner.h:12
int y
Definition: ParticleSpacialPartitioner.h:12
int x
Definition: ParticleSpacialPartitioner.h:12
static void moveToParticle(int x, int y)
called by collide function class to move the to particle
Definition: ParticleSpacialPartitioner.cpp:280
Definition: ParticleSpacialPartitioner.h:10
static void moveFromParticle(int x, int y)
called by collide function class to move the from particle
Definition: ParticleSpacialPartitioner.cpp:250