diff options
Diffstat (limited to 'include/save_util.hpp')
-rw-r--r-- | include/save_util.hpp | 36 |
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_ |