aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-03-16 08:48:50 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-03-16 08:48:50 -0400
commit8dae5eeac2c6254bb8288c0479c193ab185a312f (patch)
treeb9cac413e7da7b955c598ef39e61e6f2beecc124 /include
parent93d6035dad1eb60fb01648232809e55059dd1cfa (diff)
string'd some stuff
Diffstat (limited to 'include')
-rw-r--r--include/ui.h44
-rw-r--r--include/world.h214
2 files changed, 132 insertions, 126 deletions
diff --git a/include/ui.h b/include/ui.h
index 9523269..072d418 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -99,12 +99,12 @@ namespace ui {
/*
* These flags are used elsewhere.
*/
-
+
extern unsigned int fontSize;
-
+
extern bool debug;
extern bool posFlag;
-
+
extern unsigned char dialogOptChosen;
extern bool dialogBoxExists;
extern bool dialogImportant;
@@ -117,54 +117,54 @@ namespace ui {
*/
void initFonts(void);
-
+
void destroyFonts(void);
-
+
/*
* Sets the current font/font size.
*/
-
+
void setFontFace(const char *ttf);
void setFontSize(unsigned int size);
-
+
/*
* Draw a centered string.
*/
-
- float putStringCentered(const float x,const float y,const char *s);
-
+
+ float putStringCentered(const float x,const float y,std::string s);
+
/*
* Draws a formatted string at the given coordinates.
*/
-
+
float putText(const float x,const float y,const char *str,...);
-
+
/*
* Creates a dialogBox text string (format: `name`: `text`). This function simply sets up
* variables that are drawn in ui::draw(). When the dialog box exists player control is
* limited until a right click is given, closing the box.
*/
-
+
void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
void merchantBox();
void waitForDialog(void);
-
+
void drawPage( std::string path );
-
+
/*
* Draws a larger string in the center of the screen. Drawing is done inside this function.
*/
-
+
void importantText(const char *text,...);
void passiveImportantText(int duration,const char *text,...);
-
+
/*
* Draw various UI elements (dialogBox, player health)
*/
-
+
void draw(void);
-
+
/*
* Draw various menu items
@@ -177,17 +177,17 @@ namespace ui {
* Handle keyboard/mouse events.
*/
void handleEvents(void);
-
+
/*
* Toggle the black overlay thing.
*/
-
+
void toggleBlack(void);
void toggleBlackFast(void);
void toggleWhite(void);
void toggleWhiteFast(void);
void waitForCover(void);
-
+
}
#endif // UI_H
diff --git a/include/world.h b/include/world.h
index 55c08f5..553cd8d 100644
--- a/include/world.h
+++ b/include/world.h
@@ -1,6 +1,6 @@
/** @file world.h
* @brief The world system.
- *
+ *
* This file contains the classes and variables necessary to create an in-game
* world.
*/
@@ -95,7 +95,7 @@ public:
vec2 end;
bool in;
std::vector<Structures *> build;
-
+
Village(const char *meme, World *w);
~Village(void){}
};
@@ -106,112 +106,118 @@ public:
class World {
protected:
+
/**
* The line array.
+ *
* This array is created through 'new' in World::generate(), with an amount
* of elements provided by the function.
*/
-
+
std::vector<WorldData> worldData;
-
+
/**
* Starting x coordinate.
+ *
* This x value is the point at which line[0] should reside, can be used to
* calculate the width of the world.
*/
-
+
int worldStart;
-
+
/**
* Handle physics for a single entity.
+ *
* This function handles gravity and death for an entity. The public version
* of this, World::detect(), handles all entities in the world as well as
* the player. World::singleDetect() should never be used outside of
* World::detect(), which is why it is declared private.
*/
-
- void singleDetect(Entity *e);
-
+
+ void singleDetect( Entity *e );
+
/**
* Empties all entity vectors.
+ *
* Each entity vector is iterated through, calling delete for each entry.
* Once all specific vectors are cleared, the general entity vector is
* emptied of the pointers to those other vectors. This function should only
* be called in World's destructor, as there shouldn't be another reason to
* call this function.
*/
-
- void deleteEntities(void);
-
+
+ void deleteEntities( void );
+
/**
* Number of lines in the world.
+ *
* While this number is helpful for knowing the world's width, it is kept
* private for security reasons. To compensate for this,
* World::getTheWidth() is provided (see below).
*/
-
+
unsigned int lineCount;
-
+
/**
* An array of star coordinates.
*/
-
+
std::vector<vec2> star;
-
+
/**
* The Texturec object that holds the background sprites for this world.
*/
-
+
Texturec *bgTex;
/**
* Defines the set of background images that should be used for this world.
*/
-
+
WorldBGType bgType;
-
+
/**
* The Mix_Music object that holds the background soundtrack for the world.
*/
-
+
Mix_Music *bgmObj;
-
+
/**
* The file path of the song wished to be loaded by bgmObj.
*/
-
+
std::string bgm;
-
- std::vector<std::string>bgFiles;
- std::vector<std::string>bgFilesIndoors;
-
+
+ std::vector<std::string> bgFiles;
+ std::vector<std::string> bgFilesIndoors;
+
public:
/**
* The filename of the XML file for the world to the left; NULL if no world
* is present.
*/
-
- char *toLeft;
-
+
+ std::string toLeft;
+
/**
* The filename of the XML file for the world to the right; NULL if no world
* is present.
*/
-
- char *toRight;
-
+
+ std::string toRight;
+
/**
* Sets what XML file to use for loading the world to the left.
*/
-
- char *setToLeft(const char *file);
-
+
+ std::string setToLeft( std::string file );
+
/**
* Sets what XML file to use for loading the world to the right.
*/
-
- char *setToRight(const char *file);
+
+ std::string setToRight( std::string file );
/**
* A vector of pointers to every NPC, Structure, Mob, and Object in this
@@ -226,38 +232,38 @@ public:
std::vector<NPC *> npc;
std::vector<Merchant *> merchant;
-
+
/**
* A vector of all Structures in this world.
*/
-
+
std::vector<Structures *> build;
-
+
/**
* A vector of all Mobs in this world.
*/
-
+
std::vector<Mob *> mob;
-
+
/**
* A vector of all Objects in this world.
*/
-
+
std::vector<Object *> object;
-
+
/**
* A vector of all particles in this world.
*/
-
+
std::vector<Particles> particles;
-
-
+
+
std::vector<Village *> village;
-
+
/**
* A vector of all light elements in this world.
*/
-
+
std::vector<Light> light;
/**
@@ -265,175 +271,175 @@ public:
*/
std::vector<std::string> sTexLoc;
-
+
/**
* NULLifies pointers and allocates necessary memory. This should be
* followed by some combination of setBackground(), setBGM(), or
* generate().
*/
-
+
World( void );
-
+
/**
* Frees resources taken by the world.
*/
-
+
virtual ~World(void);
-
+
/**
* Adds a structure to the world, with the specified subtype and
* coordinates. `inside` is a file name for the IndoorWorld XML file that
* this structure will lead to; if NULL the player won't be able to enter
* the structure.
*/
-
+
void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
-
+
/**
* Adds a Mob to the world with the specified type and coordinates.
*/
-
+
void addMob(int type,float x,float y);
-
+
/**
* Adds a Mob to the world with a handler function that can be called by
* certain mobs to trigger events.
*/
-
+
void addMob(int t,float x,float y,void (*hey)(Mob *));
-
+
/**
* Adds an NPC to the world with the specified coordinates.
*/
-
+
void addNPC(float x,float y);
-
+
/**
* Adds a Merchant to the world at the specified coordinates.
*/
-
+
void addMerchant(float x, float y);
-
+
/**
* Adds an object to the world with the specified item id and coordinates.
* If `pickupDialog` is not NULL, that string will display in a dialog box
* upon object interaction.
*/
-
+
void addObject( std::string in, std::string pickupDialog, float x, float y);
-
+
/**
* Adds a particle to the world with the specified coordinates, dimensions,
* velocity, color and duration (time to live).
*/
-
+
void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int duration);
-
+
/**
* Adds a light to the world with the specified coordinates and color.
*/
-
+
void addLight(vec2 xy, Color color);
-
+
/**
* Updates the coordinates of everything in the world that has coordinates
* and a velocity. The provided delta time is used for smoother updating.
*/
-
- void update(Player *p,unsigned int delta);
-
+
+ void update( Player *p, unsigned int delta );
+
/**
* Generate a world of the provided width. Worlds are drawn centered on the
* y-axis, so the reachable coordinates on the world would be from negative
* half-width to positive half-width.
*/
-
+
virtual void generate(unsigned int width);
-
+
/**
* Sets the background theme, collecting the required textures into a
* Texturec object.
*/
-
+
void setBackground(WorldBGType bgt);
-
+
/**
* Sets the background music for the world, required for the world to be
* playable.
*/
-
+
void setBGM(std::string path);
/**
* Sets the worlds style folder
*/
- void setStyle(std::string pre);
-
+ void setStyle(std::string pre);
+
/**
* Plays/stops this world's BGM. If `prev` is not NULL, that world's BGM
* will be faded out followed by the fading in of this world's BGM.
*/
-
+
void bgmPlay(World *prev) const;
-
+
/**
* Draw the world and entities based on the player's coordinates.
*/
virtual void draw(Player *p);
-
+
/**
* Handles collision between the entities and the world, as well as entity
* death.
*/
-
+
void detect(Player *p);
-
+
/**
* Attempts to let the player enter the left-linked world specified by
* `toLeft`. Returns the world to the left if the movement is possible,
* otherwise returns this world.
*/
-
+
World *goWorldLeft(Player *p);
-
+
/**
* Attempts to let the player enter the right-linked world specified by
* `toRight`. Returns the world to the right if the movement is possible,
* otherwise returns this world.
*/
-
+
World *goWorldRight(Player *p);
-
+
/**
* This function looks for any structure the player is standing in front of
* that also have an inside world. Returns the inside world if those
* conditions are met, otherwise returns this world.
*/
-
+
World *goInsideStructure(Player *p);
-
+
/**
* Adds a hole between the specified y coordinates. If the player falls in
* this hole the game will exit.
*/
-
+
void addHole(unsigned int start,unsigned int end);
-
+
/**
* Adds a hill to the world, given the peak's coordinates and how wide the
* hill can be.
*/
-
+
void addHill( ivec2 peak, unsigned int width );
-
+
/**
* Gets the world's width.
*/
-
+
int getTheWidth(void) const;
-
+
void save(void);
void load(void);
};
@@ -441,19 +447,19 @@ public:
/*
* IndoorWorld - Indoor settings stored in a World class
*/
-
+
class IndoorWorld : public World {
public:
IndoorWorld(void);
~IndoorWorld(void);
-
+
void generate(unsigned int width); // Generates a flat world of width 'width'
void draw(Player *p); // Draws the world (ignores layers)
};
/**
* The arena class - creates an arena.
- *
+ *
* This world, when created, expects a pointer to a Mob. This mob will be
* transported to a temporary world with the player, and the Mob will be
* killed upon exiting the arena.
@@ -476,18 +482,18 @@ public:
*/
Arena( World *leave, Player *p, Mob *m );
-
+
/**
* Frees resources taken by the arena.
*/
-
+
~Arena( void );
-
+
/**
* Attempts to exit the world, returning the player to the world they were
* last in.
*/
-
+
World *exitArena( Player *p );
};