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
engine_graphics_api.h
Go to the documentation of this file.
1 #ifndef ENGINE_GRAPHICS_API_H
2 #define ENGINE_GRAPHICS_API_H
3 
4 #ifdef __cplusplus
5 
6 #include <SDL2/SDL.h>
7 
8 #include <iostream>
9 #include <string>
10 #include <sstream>
11 #include <fstream>
12 #include <vector>
13 
14 #include "ParticleGroupHandle.h"
15 
16 class Point;
17 
19 namespace GraphicsAPI
20 {
21 #define NUMEVENTS 2
22 
23  enum Events
24  {
25  QUIT,
26  CLICK
27  };
28 
30  enum EditorOrientation
31  {
32  HORIZONTAL,
33  VERTICAL
34  };
35 
37  struct Layout
38  {
39  int w, h;
40  EditorOrientation orient;
41  int ratio;
42  int particleSize;
43  };
44 
46  class LayoutBuilder
47  {
48  public:
49  LayoutBuilder(){};
51  LayoutBuilder *withSize(int w, int h);
53  LayoutBuilder *withEditorOrientation(EditorOrientation orient);
55  LayoutBuilder *withWindowRatio(int particlePCT);
56  // set how big the particles are
57  LayoutBuilder *withParticleSize(int particleSize);
59  Layout *build();
60 
61  private:
62  Layout *l = new Layout();
63  };
65  class Button
66  {
67  public:
68  int height, width;
69  std::string name;
70  SDL_Rect rect;
71  Color color;
72  int id;
73 
74  int x, y; // location coords for this button (center of button)
75  Button();
76  Button(int x, int y);
77  Button(std::string name, Color color, int x, int y, int h, int w);
78 
80  void render(SDL_Renderer *gRenderer);
82  bool isMouseOnButton(int mouseX, int mouseY);
83 
84  };
85 
87  class GraphicsProgram
88  {
89  public:
91  GraphicsProgram(Layout *l);
93  ~GraphicsProgram();
95  void paintPixel(int x, int y, ParticleGroupHandle *group);
97  void paintQuadTreeBounds(Point topLeft, Point bottomRight);
99  void render();
100 
102  void mouseInputHandler();
103 
104  int particleScreenW;
105  int particleScreenH;
106 
107  int screenHeight;
108  int screenWidth;
109  int currChoice;
110 
111  bool quit;
112 
114  std::vector<ParticleGroupHandle *> groupOptions;
115 
116  private:
117 
118  EditorOrientation orient; // whether the button editor is vertcal or horizontal
119  int ratio; //portion of the screen taken up by the particle editor
120  int gBrushSize;
121 
122  int events[NUMEVENTS]; // store event state
123 
124  SDL_PixelFormat *pixelFormat = nullptr;
126  SDL_Window *gWindow = nullptr;
128  SDL_Renderer *gRenderer = nullptr;
130  SDL_Texture *gTexture = nullptr;
131  // pixels
132  Uint32 *pixels = nullptr;
134  std::vector<SDL_Rect *> rects;
135 
136  std::vector<Button> buttons;
137 
139  void mouseButtonHandler(int mouseX, int mouseY);
141  bool isInParticleScreen(int mouseX, int mouseY);
142  bool displayQuads = false;
143  };
144 }
145 
146 #endif // !__cplusplus
147 
148 #endif // !ENGINE_MAIN_GRAPHICS_H
Definition: ParticleGroupHandle.h:29
Definition: ParticleGroup.h:20
LayoutBuilderPtr withWindowRatio(LayoutBuilderPtr builder, int particlePCT)
configure size of particle placing portion of the window. input is the percentage that will take up ...
Definition: engine_capi.cpp:80
LayoutBuilderPtr withParticleSize(LayoutBuilderPtr builder, int particleSize)
configure the size of particles (default 3)
Definition: engine_capi.cpp:97
LayoutBuilderPtr withEditorOrientation(LayoutBuilderPtr builder, int orient)
configure whether horizontal or vertical orientation for the editor
Definition: engine_capi.cpp:85
LayoutBuilderPtr withSize(LayoutBuilderPtr builder, int w, int h)
set size of layout
Definition: engine_capi.cpp:75
where something is in 2d space
Definition: QuadTree.h:7