From c7f4dd960d2530b246dd0b5d04f77d5b11c65551 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 28 Feb 2016 21:02:08 -0500 Subject: complete world rewrite -- edgy --- include/common.h | 5 +++++ include/world.h | 57 +++++++++++++++----------------------------------------- 2 files changed, 20 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/include/common.h b/include/common.h index 6ba6f03..08f0392 100644 --- a/include/common.h +++ b/include/common.h @@ -148,6 +148,9 @@ extern float VOLUME_SFX; #define getRand() rand() +#define randGet rand +#define randInit srand + /** * Included in common.h is a prototype for DEBUG_prints, which writes a formatted * string to the console containing the callee's file and line number. This macro simplifies @@ -227,4 +230,6 @@ int strCreateFunc(const char *equ); template size_t arrAmt(N (&)[s]){return s;} +void UserError(std::string reason); + #endif // COMMON_H diff --git a/include/world.h b/include/world.h index c066865..f60c181 100644 --- a/include/world.h +++ b/include/world.h @@ -11,24 +11,11 @@ #include #include -/** - * Defines at what interval y values should be calculated for the array 'line'. - */ - -#define GEN_INC 10 - -/** - * Defines the lowest possible y value for a world line. - */ - -#define GEN_MIN 80 - -/** - * Defines the highest possible y value for a randomly generated world line. - */ - -#define GEN_MAX 110 +#define GROUND_HEIGHT_INITIAL 80 +#define GROUND_HEIGHT_MINIMUM 60 +#define GROUND_HEIGHT_MAXIMUM 110 +#define GROUND_HILLINESS 10 /** * Defines how many game ticks it takes for a day to elapse. @@ -44,7 +31,7 @@ typedef enum { BG_FOREST, /**< A forest theme. */ - BG_WOODHOUSE /**< An indoor wooden house theme. */ + BG_WOODHOUSE, /**< An indoor wooden house theme. */ } WORLD_BG_TYPE; /** @@ -74,12 +61,12 @@ typedef struct { * lines. Dirt color and grass properties are also kept track of here. */ -typedef struct line_t { - float y; /**< Height of this vertical line */ - bool gs; /**< Show grass */ - float gh[2]; /**< Height of glass (2 blades per line) */ - unsigned char color; /**< Lightness of dirt (brown) */ -} line_t; +typedef struct { + bool grassUnpressed; + int grassHeight[2]; + float groundHeight; + unsigned char groundColor; +} WorldData; class World; @@ -149,7 +136,7 @@ protected: * of elements provided by the function. */ - struct line_t *line; + std::vector worldData; /** * Starting x coordinate. @@ -157,7 +144,7 @@ protected: * calculate the width of the world. */ - int x_start; + int worldStart; /** * Handle physics for a single entity. @@ -193,7 +180,7 @@ protected: * An array of star coordinates. */ - vec2 *star; + std::vector star; /** * The Texturec object that holds the background sprites for this world. @@ -308,7 +295,7 @@ public: * generate(). */ - World(void); + World( void ); /** * Frees resources taken by the world. @@ -388,14 +375,6 @@ public: virtual void generate(unsigned int width); - /** - * Generates a world of the provided width using the given function to - * determine ground coordinates. The given y coordinates from the function - * are limited to a certain range, most likely from GEN_MIN to 2000. - */ - - void generateFunc(unsigned int width,float(*func)(float)); - /** * Sets the background theme, collecting the required textures into a * Texturec object. @@ -477,12 +456,6 @@ public: void load(void); }; -/* - * Gets a good base y value for background rendering. -*/ - -float worldGetYBase(World *w); - /* * IndoorWorld - Indoor settings stored in a World class ;) */ -- cgit v1.2.3