Physics-Simulator  v1.4.0-beta.2
cannonball.h
Go to the documentation of this file.
1 #ifndef __CANNONBALL_HEADER__
2 #define __CANNONBALL_HEADER__
3 /*****************************************************************************/
4 #include <math.h>
5 #include <cstdlib>
6 #include <vector>
7 #include <time.h>
8 #include "screen.h"
9 /*****************************************************************************/
14 /*****************************************************************************/
20 /*****************************************************************************/
25  double x;
26  double y;
27 };
28 
32  double radius;
33  double mass;
34  double area;
37  double volume;
38  double density;
39  double interia;
40 };
41 
46 struct stcBox {
47  int left;
48  int right;
49  int top;
50  int bottom;
51 };
52 
55 struct stcColor {
56  Uint8 Red;
57  Uint8 Green;
58  Uint8 Blue;
59 };
60 
61 typedef struct stcDoubleValues dblXY;
62 typedef struct stcPhysicalProperties PP;
63 typedef struct stcBox BOX;
64 typedef struct stcColor clr;
65 //typedef struct stcXYZVector XYZ;
66 
67 typedef std::vector<LOC> VPath;
69 /*****************************************************************************/
71  public:
72  clsCannonball();
73  ~clsCannonball();
74  void setValues(double, LOC, double, double, int);
75  LOC getplace(void);
76  LOC getScreenPlace(void);
77  void setplace(LOC);
78  void update(double);
79  void updateForces(void);
80  dblXY getVelocity(void);
81  dblXY getForces(void);
82  void setVelocity(dblXY);
83  PP getPhysicalProps(void);
84  void setPhysicalProps(PP);
85  BOX getBOX(void);
86  void writeInfo(void);
87  void togglePause(void);
88  bool isPaused(void);
89  void checkEdges(void);
90  void setEdgePosition(void);
91  bool blnstarted_;
97  void addForce(dblXY);
98  dblXY getdbLOC(void);
99  void setdbLOC(dblXY);
100  private:
101 
102  uint ballID_;
103  bool blndragenabled_;
104  clr color_;
105  BOX collisionbox_;
106  SDL_Rect screen_place_;
107  LOC place_;
108  dblXY vel_;
109  dblXY dblLOC_;
112  dblXY acc_;
113  PP props_;
114  VPath path_;
115  double deltat_;
119  dblXY forces_;
120  bool paused_;
122  void show(void);
123  void drawPath(LOC);
124  void dragCalcValues(void);
125  void dragUpdateAcc(void);
126  void doFriction(void);
127  void updateCollisionBox(void);
128 };
129 /*****************************************************************************/
130 #endif // __CANNONBALL_HEADER__
double y
Definition: cannonball.h:26
Definition: cannonball.h:24
Uint8 Blue
Definition: cannonball.h:58
Definition: cannonball.h:46
Definition: cannonball.h:55
double density
Definition: cannonball.h:38
int bottom
Definition: cannonball.h:50
int top
Definition: cannonball.h:49
bool blncheckphysics_
Definition: cannonball.h:94
std::vector< LOC > VPath
Definition: cannonball.h:67
double x
Definition: cannonball.h:25
double interia
Definition: cannonball.h:39
unsigned int uint
Definition: global.h:16
int right
Definition: cannonball.h:48
Uint8 Green
Definition: cannonball.h:57
bool blnstarted_
Definition: cannonball.h:91
double mass
Definition: cannonball.h:33
Definition: cannonball.h:31
double radius
Definition: cannonball.h:32
Uint8 Red
Definition: cannonball.h:56
Definition: screen.h:36
int left
Definition: cannonball.h:47
double volume
Definition: cannonball.h:37
This class is used to create and control each of the balls.
Definition: cannonball.h:70
double area
Definition: cannonball.h:34