aboutsummaryrefslogtreecommitdiffstats
path: root/include/save_util.hpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-06-08 08:43:44 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-06-08 08:43:44 -0400
commit7110a4ab054341c9f41972b06044853138f526a8 (patch)
treec7e0c48f6844becf780496909fa120363cd53497 /include/save_util.hpp
parent5e4b825513aee44afc1342e5c390e80d3a1fdd15 (diff)
save to xml
Diffstat (limited to 'include/save_util.hpp')
-rw-r--r--include/save_util.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/save_util.hpp b/include/save_util.hpp
new file mode 100644
index 0000000..3d5cf54
--- /dev/null
+++ b/include/save_util.hpp
@@ -0,0 +1,36 @@
+#ifndef SAVE_UTIL_H_
+#define SAVE_UTIL_H_
+
+/*
+ * Save macros.
+ */
+
+#define E_SAVE_COORDS { xmle->SetAttribute("x", loc.x); xmle->SetAttribute("y", loc.y); }
+
+#define E_SAVE_HEALTH xmle->SetAttribute("health", health);
+
+/*
+ * Load macos.
+ */
+
+#define E_LOAD_COORDS(yy) { float n; \
+ if (xmle->QueryFloatAttribute("x", &n) == XML_NO_ERROR) \
+ spawn(n, yy); \
+ else \
+ spawn(xmle->FloatAttribute("spawnx"), 100); \
+ \
+ if (xmle->QueryFloatAttribute("y", &n) == XML_NO_ERROR) \
+ loc.y = n; }
+
+#define E_LOAD_HEALTH { float n; \
+ \
+ if (xmle->QueryFloatAttribute("maxHealth", &n) != XML_NO_ERROR) \
+ maxHealth = 1; \
+ \
+ if (xmle->QueryFloatAttribute("health", &n) == XML_NO_ERROR) \
+ health = n; \
+ else \
+ health = maxHealth; }
+
+
+#endif // SAVE_UTIL_H_