aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-03-01 08:43:33 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-03-01 08:43:33 -0500
commitd42b81661ac1d1303746082b3606e80e92f5fdd6 (patch)
tree1458419db1bc95c0ac63311385c34cb2913445d2 /include
parent20948cfe47f1fbeeed04e890c457d83cc826d74d (diff)
parent47f8aa5b312a5ef671e83322bcbe201a034f84c0 (diff)
Merge branch 'master' of http://github.com/tcsullivan/gamedev
Diffstat (limited to 'include')
-rw-r--r--include/common.h5
-rw-r--r--include/world.h61
2 files changed, 22 insertions, 44 deletions
diff --git a/include/common.h b/include/common.h
index 933067b..9650f49 100644
--- a/include/common.h
+++ b/include/common.h
@@ -151,6 +151,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
@@ -230,4 +233,6 @@ int strCreateFunc(const char *equ);
template<typename N, size_t s>
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 733daae..b3d1071 100644
--- a/include/world.h
+++ b/include/world.h
@@ -11,24 +11,11 @@
#include <common.h>
#include <entities.h>
-/**
- * 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;
+ float grassHeight[2];
+ float groundHeight;
+ unsigned char groundColor;
+} WorldData;
class World;
@@ -151,7 +138,7 @@ protected:
* of elements provided by the function.
*/
- struct line_t *line;
+ std::vector<WorldData> worldData;
/**
* Starting x coordinate.
@@ -159,7 +146,7 @@ protected:
* calculate the width of the world.
*/
- int x_start;
+ int worldStart;
/**
* Handle physics for a single entity.
@@ -195,7 +182,7 @@ protected:
* An array of star coordinates.
*/
- vec2 *star;
+ std::vector<vec2> star;
/**
* The Texturec object that holds the background sprites for this world.
@@ -301,7 +288,7 @@ public:
* A vector of all light elements in this world.
*/
- std::vector<Light > light;
+ std::vector<Light> light;
/**
* Vector of all building textures for the current world style
@@ -315,7 +302,7 @@ public:
* generate().
*/
- World(void);
+ World( void );
/**
* Frees resources taken by the world.
@@ -397,14 +384,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.
*/
@@ -486,12 +465,6 @@ public:
};
/*
- * Gets a good base y value for background rendering.
-*/
-
-float worldGetYBase(World *w);
-
-/*
* IndoorWorld - Indoor settings stored in a World class ;)
*/
@@ -516,7 +489,7 @@ public:
};
extern int worldShade;
-extern char *currentXML;
+extern std::string currentXML;
World *loadWorldFromXML(const char *path);
World *loadWorldFromXMLNoSave(const char *path);