aboutsummaryrefslogtreecommitdiffstats
path: root/include/world.hpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-05-02 07:36:43 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-05-02 07:36:43 -0400
commitc61cbf691bee6dec791c3a161145ae16b448ac2b (patch)
treec276a82d88353d2863bd4da76a77715bab7bc4f2 /include/world.hpp
parent992969772def3578acbd1cef0155333636f75862 (diff)
parentafa34b3140979874d46a362e83dc0d1eebd137eb (diff)
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'include/world.hpp')
-rw-r--r--include/world.hpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/include/world.hpp b/include/world.hpp
index 9566184..0aea879 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -53,6 +53,8 @@ typedef struct {
unsigned char groundColor;
} WorldData;
+typedef std::pair<World *, vec2> WorldSwitchInfo;
+
/* ----------------------------------------------------------------------------
** Variables section
** --------------------------------------------------------------------------*/
@@ -64,13 +66,18 @@ extern int worldShade;
extern std::string currentXML;
// defines how many game ticks it takes for a day to elapse
-extern const unsigned int DAY_CYCLE;
+constexpr const unsigned int DAY_CYCLE = 12000;
// velocity of player when moved by user
-extern const float PLAYER_SPEED_CONSTANT;
+constexpr const float PLAYER_SPEED_CONSTANT = 0.15f;
// maximum pull of gravity in one game tick
-extern const float GRAVITY_CONSTANT;
+constexpr const float GRAVITY_CONSTANT = 0.001f;
+
+// height of the floor in an indoor world
+constexpr const unsigned int INDOOR_FLOOR_THICKNESS = 50;
+constexpr const unsigned int INDOOR_FLOOR_HEIGHTT = 400;
+constexpr const unsigned int INDOOR_FLOOR_HEIGHT = (INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS);
/* ----------------------------------------------------------------------------
** Classes / function prototypes section
@@ -105,7 +112,7 @@ protected:
int worldStart;
// holds / handles textures for background elements
- Texturec *bgTex;
+ TextureIterator bgTex;
// defines what type of background is being used
WorldBGType bgType;
@@ -215,14 +222,14 @@ public:
std::string getToRight(void) const;
// attempts to enter the left/right adjacent world, returning either that world or this
- std::pair<World *, vec2> goWorldLeft(Player *p);
- std::pair<World *, vec2> goWorldRight(Player *p);
+ WorldSwitchInfo goWorldLeft(Player *p);
+ WorldSwitchInfo goWorldRight(Player *p);
// attempts to move an NPC to the left adjacent world, returning true on success
bool goWorldLeft(NPC *e);
// attempts to enter a structure that the player would be standing in front of
- std::pair<World *, float> goInsideStructure(Player *p);
+ WorldSwitchInfo goInsideStructure(Player *p);
// adds a hole at the specified start and end x-coordinates
void addHole(unsigned int start,unsigned int end);
@@ -235,8 +242,6 @@ public:
void addMerchant(float x, float y, bool housed);
- //void addMob(int type, float x, float y);
- //void addMob(int type, float x, float y, void (*hey)(Mob *));
void addMob(Mob *m, vec2 coord);
void addNPC(float x, float y);
@@ -300,41 +305,24 @@ public:
* transported to a temporary world with the player, and the Mob will be
* killed upon exiting the arena.
*/
-
class Arena : public World {
private:
- /**
- * The mob that the player is fighting.
- */
-
+ // the mob that the player is fighting
Mob *mmob;
public:
- /**
- * Creates a world with the player and mob, returning the player to the
- * world `leave` upon exit.
- */
-
+ // creates the arena with the world being left for it
Arena(World *leave, Player *p, Mob *m);
- /**
- * Frees resources taken by the arena.
- */
-
+ // frees memory
~Arena(void);
- /**
- * Attempts to exit the world, returning the player to the world they were
- * last in.
- */
-
- World *exitArena(Player *p);
+ // attempts to exit the arena, returning what world the player should be in
+ WorldSwitchInfo exitArena(Player *p);
};
-bool isCurrentWorldIndoors(void);
-float getIndoorWorldFloorHeight(void);
std::string getWorldWeatherStr(WorldWeather ww);