-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhysicalModel.h
More file actions
135 lines (118 loc) · 2.9 KB
/
PhysicalModel.h
File metadata and controls
135 lines (118 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//
// Created by Ben Dickson on 5/9/17.
//
#ifndef LIBRARY_PHYSICALMODEL_H
#define LIBRARY_PHYSICALMODEL_H
#include <cstdlib>
#include <string>
#include "Point.h"
#include "RenderModel.h"
#include "CollisionModel.h"
class Entity;
using namespace std;
class PhysicalModel
{
private:
string name;
double x=0.0f,y=0.0f;
int r=0;
bool collides,rendered;
RenderModel* renderer = nullptr;
CollisionModel* collider = nullptr;
Entity* parentElement = nullptr;
enum ConType{DOUBLE};
static map<string,ConType> conImport;
// import values
bool importDouble(string var , double value);
// bool importInt(string var, int value);
// bool importString(string var, string value);
public:
inline Entity* getParentElement() const;
inline CollisionModel* getCollider() const;
inline RenderModel* getRenderer() const;
inline Point getGlobalPos() const;
inline bool parseConstructorPair(pair<string,string> p)
{
map<string,ConType>::iterator it = conImport.find(p.first);
if(it!=conImport.end())
{
switch((*it).second)
{
case DOUBLE:
return importDouble(p.first,stod(p.second));
/*
case INT:
return importInt(p.first,stoi(p.second));
case STRING:
return importString(p.first,p.second);
*/
}
}
return false;
}
// constructors
/**
* Constructor for rendered and collision object
* @param cx
* @param cy
* @param cr
* @param rm
* @param cm
* @param p
*/
PhysicalModel(string cname, double cx, double cy,int cr,RenderModel* rm, CollisionModel* cm, Entity* p)
{
name = cname;
x = cx;
y = cy;
r = cr;
renderer = rm;
collider = cm;
parentElement = p;
collides = true;
rendered = true;
}
/**
* Constructor for rendered object that does not collide
* @param cx
* @param cy
* @param cr
* @param rm
* @param p
*/
PhysicalModel(string cname, double cx, double cy,int cr,RenderModel* rm, Entity* p)
{
name = cname;
x = cx;
y = cy;
r = cr;
renderer = rm;
parentElement = p;
collides = false;
rendered = true;
}
/**
* Constructor for invisible object that collides
* @param cx
* @param cy
* @param cr
* @param cm
* @param p
*/
PhysicalModel(string cname, double cx, double cy,int cr,CollisionModel* cm, Entity* p)
{
name = cname;
x = cx;
y = cy;
r = cr;
collider = cm;
parentElement = p;
collides = true;
rendered = false;
}
PhysicalModel(string cname)
{
name = cname;
}
};
#endif //LIBRARY_PHYSICALMODEL_H