-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRectangle.cpp
More file actions
33 lines (28 loc) · 1.17 KB
/
Copy pathRectangle.cpp
File metadata and controls
33 lines (28 loc) · 1.17 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
#include "master.h"
#include "Rectangle.h"
using namespace pyrodactyl;
bool pyroRect::Load(rapidxml::xml_node<char> *node, const bool &echo, const std::string &x_name, const std::string &y_name,
const std::string &w_name, const std::string &h_name)
{
return LoadNum(x, x_name, node, echo)
&& LoadNum(y, y_name, node, echo)
&& LoadNum(w, w_name, node, echo)
&& LoadNum(h, h_name, node, echo);
}
bool pyroRect::Collide(pyroRect box)
{
if (box.x + box.w < x) return false; //just checking if their
if (box.x > x + w) return false; //bounding boxes even touch
if (box.y + box.h < y) return false;
if (box.y > y + h) return false;
return true; //bounding boxes intersect
}
void pyroRect::SaveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root, const char* name)
{
rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, name);
child->append_attribute(doc.allocate_attribute("x", gStrPool.Get(x)));
child->append_attribute(doc.allocate_attribute("y", gStrPool.Get(y)));
child->append_attribute(doc.allocate_attribute("w", gStrPool.Get(w)));
child->append_attribute(doc.allocate_attribute("h", gStrPool.Get(h)));
root->append_node(child);
}