From cb55d6e72ae1f48622ffc2a36d7bdb3719355afe Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 6 Nov 2015 08:19:46 -0500 Subject: world save/load --- include/world.h | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'include/world.h') diff --git a/include/world.h b/include/world.h index 81ec335..e3c7f15 100644 --- a/include/world.h +++ b/include/world.h @@ -4,9 +4,11 @@ #include // For HLINE, vec2, OpenGL utilities, etc. #include -typedef struct { - vec2 p1,p2; -} __attribute__ ((packed)) Platform; +struct line_t { + bool gs; + float y,gh[2]; + unsigned char color; +} __attribute__ ((packed)); /* * World - creates and handles an area of land @@ -27,11 +29,7 @@ protected: * */ - struct line_t { - bool gs; - float y,gh[2]; - unsigned char color; - } __attribute__ ((packed)) *line; + struct line_t *line; /* * Keeps a dynamically allocated array of platforms in the world. @@ -132,6 +130,20 @@ public: */ int getTheWidth(void); + + /* + * Stores all of this class's contents in a string for saving to a file. This array should + * be freed after being written to a file. + */ + + char *save(unsigned int *ssize); + + /* + * Loads a previous world's contents (from save()) into this one. + */ + + void load(char *buf); + }; /* -- cgit v1.2.3