Skip to content

Commit

Permalink
Merge pull request #102 from GearChicken/release/1.0
Browse files Browse the repository at this point in the history
Updated headers in include/
  • Loading branch information
JenniferPylko committed Jul 18, 2014
2 parents 659678e + 8c295e5 commit 4d57bba
Show file tree
Hide file tree
Showing 22 changed files with 519 additions and 496 deletions.
50 changes: 24 additions & 26 deletions include/MINX/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ freely, subject to the following restrictions:
>
*/

#ifndef MINX_GAME_HPP_
#define MINX_GAME_HPP_

#include "API.hpp"

#include <ft2build.h>
Expand All @@ -47,54 +50,51 @@ freely, subject to the following restrictions:
#include <thread>
#include <mutex>

#ifndef MINX_GAME_HPP_
#define MINX_GAME_HPP_

namespace MINX
{
/** The class that handles everything.
* When using the library, your code will probably construct, Initialize() and Run() your subclass of Game.
* When using the library, your code will probably construct and Run() your subclass of Games
*/
class MINX_API Game
{
public:
/** The constructor, which handles some of the initialization code for the Game.
/** The constructor, which handles some of the initialization code for the Game
*/
Game();

/** This handles the rest of the initialization code for the game.
/** This handles the rest of the initialization code for the game
*/
virtual void Initialize();

/** Loads content used by the game.
/** Loads content used by the game
*/
virtual void LoadContent();

/** Updates the game state.
* Should be extended when you create a subclass of Game.
* @param gameTime the GameTime to use when updating.
/** Updates the game state
* Should be extended when you create a subclass of Game
* @param gameTime the GameTime to use when updating
*/
virtual void Update(GameTime* gameTime);

/** Unloads content used by the game.
/** Unloads content used by the game
*/
virtual void UnloadContent();

/** Draws the state of the game every frame.
* This method is called by a different thread than Update(), so it is ok to use sleeps in Update() and not worry about freezing the drawing, or vice versa.
* @param gameTime the GameTime to use when drawing.
/** Draws the state of the game every frame
* This method is called by a different thread than Update(), so it is ok to use sleeps in Update() and not worry about freezing the drawing, or vice versa
* @param gameTime the GameTime to use when drawing
*/
virtual void Draw(GameTime* gameTime);

/** Handles Update()ing, Draw()ing, and event handling.
/** Handles Update()ing, Draw()ing, and event handling
*/
void Run();

/** A pointer to the window used by the game.
/** A pointer to the window used by the game
*/
Graphics::GameWindow* gameWindow;

/** A pointer to a vector of pointers to the GameComponents used in the game.
/** A pointer to a vector of pointers to the GameComponents used in the game
*/
std::vector<GameComponent*>* Components;

Expand All @@ -117,21 +117,19 @@ namespace MINX
*/
bool isRunning;

/** Set's the Game's RenderTarget and clears to the clearColor.
*/
void SetRenderTarget(Graphics::RenderTarget* target, Graphics::Color clearColor);

/** Set's the Game's RenderTarget and clears to cornflower blue.
/** Set's the Game's RenderTarget and clears to the clearColor
* @param target The RenderTarget to render to, defaults to NULL, if null the entire window is used
* @param clearColor The color to clear the RenderTarget to, defaults to CornflowerBlue
*/
void SetRenderTarget(Graphics::RenderTarget* target);
void SetRenderTarget(Graphics::RenderTarget* target = NULL, Graphics::Color clearColor = Graphics::Color::CornflowerBlue);

protected:
/** An instance of freetype used to draw text
*/
FT_Library freeTypeLibrary;

private:
/** A pointer to the GameTime being used by the game.
/** A pointer to the GameTime being used by the game
*/
GameTime* gameTime;

Expand All @@ -155,8 +153,8 @@ namespace MINX
*/
static Graphics::RenderTarget* activeRenderTarget;

friend class MINX::Graphics::Font;
friend class MINX::Graphics::TextureBatch;
friend class MINX::Graphics::Font;
friend class MINX::Graphics::TextureBatch;
};
}
#endif
18 changes: 9 additions & 9 deletions include/MINX/GameComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ freely, subject to the following restrictions:
>
*/

#ifndef MINX_GAMECOMPONENT_HPP_
#define MINX_GAMECOMPONENT_HPP_

#include "API.hpp"

#include "GameTime.hpp"

#ifndef MINX_GAMECOMPONENT_HPP_
#define MINX_GAMECOMPONENT_HPP_

namespace MINX
{
class MINX_API Game; //forward declaration to avoid circular dependency problems
Expand All @@ -41,28 +41,28 @@ namespace MINX
{
public:
/** Creates the GameComponent
* @param attachTo A pointer to the Game to attach to.
* @param attachTo A pointer to the Game to attach to
*/
GameComponent(Game* attachTo);

/** Destructs a GameComponent
*/
virtual ~GameComponent();

/** Initializes the GameComponent.
/** Initializes the GameComponent
*/
virtual void Initialize();

/** Update()s the GameComponent.
* @param gameTime the GameTime to update the GameComponent with.
/** Update()s the GameComponent
* @param gameTime the GameTime to update the GameComponent with
*/
virtual void Update(GameTime* gameTime);

/** Whether or not this GameComponent is enabled.
/** Whether or not this GameComponent is enabled
*/
bool enabled;

/** A pointer to the Game that this GameComponent is attached to.
/** A pointer to the Game that this GameComponent is attached to
*/
Game* game;
};
Expand Down
12 changes: 8 additions & 4 deletions include/MINX/GameTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ freely, subject to the following restrictions:
>
*/

#ifndef MINX_GAMETIME_HPP_
#define MINX_GAMETIME_HPP_

#include "API.hpp"

#include <thread>
#include <chrono>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

#ifndef MINX_GAMETIME_HPP_
#define MINX_GAMETIME_HPP_

namespace MINX
{
class MINX_API Game;
Expand Down Expand Up @@ -69,8 +69,12 @@ namespace MINX
float GetDeltaTimeSecondsF();

/** Limits the updates per second of the current thread by delaying
* @param desiredFPS the FPS to limit to
*/
inline void LimitFPS(unsigned int desiredFPS){std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<long>(1000/desiredFPS-(GetDeltaTimeSeconds()))));}
inline void LimitFPS(unsigned int desiredFPS)
{
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<long>(1000/desiredFPS-(GetDeltaTimeSeconds()))));
}

private:
/** Constructs a GameTime
Expand Down
33 changes: 16 additions & 17 deletions include/MINX/Graphics/Color.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

/*
# MINX
Copyright (c) 2013-2014 Liam Middlebrook, Benjamin Pylko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
arising from the use of this software
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
Expand All @@ -15,13 +14,13 @@ freely, subject to the following restrictions:
> 1\. The origin of this software must not be misrepresented; you must not
> claim that you wrote the original software. If you use this software
> in a product, an acknowledgment in the product documentation would be
> appreciated but is not required.
> appreciated but is not required
>
> 2\. Altered source versions must be plainly marked as such, and must not be
> misrepresented as being the original software.
> misrepresented as being the original software
>
> 3\. This notice may not be removed or altered from any source
> distribution.
> distribution
>
*/

Expand All @@ -34,39 +33,39 @@ namespace MINX
{
namespace Graphics
{
/** A struct representing a color.
/** A struct representing a color
*/
struct MINX_API Color
{
/** The red component of the color.
/** The red component of the color
*/
double R;

/** The green component of the color.
/** The green component of the color
*/
double G;

/** The blue component of the color.
/** The blue component of the color
*/
double B;

/** The alpha component of the color.
/** The alpha component of the color
*/
double A;

/** Constructs the Color with a default value of White
*/
Color();

/** Constructs a color with the given red, green, blue, and alpha values.
*/
Color(double r, double g, double b, double a);

/** Constructs a color with the given red, green, and blue values.
/** Constructs a color with the given red, green, blue, and alpha values
* @param r The red value of the color
* @param g The green value of the color
* @param b The blue value of the color
* @param a The alpha (opacity) value of the color, defaults to 255.0 (opaque)
*/
Color(double r, double g, double b);
Color(double r, double g, double b, double a = 255.0);

/** Tests equality between two Colors.
/** Tests equality between two Colors
*/
bool operator==(const Color& compareTo);

Expand Down
48 changes: 24 additions & 24 deletions include/MINX/Graphics/Font.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

/*
# MINX
Copyright (c) 2013-2014 Liam Middlebrook, Benjamin Pylko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
arising from the use of this software
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
Expand All @@ -15,15 +14,15 @@ freely, subject to the following restrictions:
> 1\. The origin of this software must not be misrepresented; you must not
> claim that you wrote the original software. If you use this software
> in a product, an acknowledgment in the product documentation would be
> appreciated but is not required.
> appreciated but is not required
>
> 2\. Altered source versions must be plainly marked as such, and must not be
> misrepresented as being the original software.
> misrepresented as being the original software
>
> 3\. This notice may not be removed or altered from any source
> distribution.
> distribution
>
*/
*/

#ifndef MINX_FONT_HPP_
#define MINX_FONT_HPP_
Expand Down Expand Up @@ -56,43 +55,44 @@ namespace MINX
Font(Game* gameHandle, char* fileLocation, GLuint shaderProgram);

/** Renders Text Onto the Screen using a string from the C++ standard library
* @param text The text to render to the screen.
* @param x The X component of the screen to draw the text to.
* @param y The Y component of the screen to draw the text to.
* @param fontSixe The size in points (pt.) to draw the font.
* @param text The text to render to the screen
* @param x The X component of the screen to draw the text to
* @param y The Y component of the screen to draw the text to
* @param fontSixe The size in points (pt.) to draw the font
*/
void RenderText(std::string text, float x, float y, int fontSize);

/** Renders Text Onto the Screen using a c-string (char*)
* @param text The text to render to the screen.
* @param x The X component of the screen to draw the text to.
* @param y The Y component of the screen to draw the text to.
* @param fontSixe The size in points (pt.) to draw the font.
* @param text The text to render to the screen
* @param x The X component of the screen to draw the text to
* @param y The Y component of the screen to draw the text to
* @param fontSixe The size in points (pt.) to draw the font
*/
void RenderText(const char* text, float x, float y, int fontSize);

/** Renders Text Onto the Screen using a string from the C++ standard library
* @param text The text to render to the screen.
* @param x The X component of the screen to draw the text to.
* @param y The Y component of the screen to draw the text to.
* @param fontSixe The size in points (pt.) to draw the font.
* @param text The text to render to the screen
* @param x The X component of the screen to draw the text to
* @param y The Y component of the screen to draw the text to
* @param fontSixe The size in points (pt.) to draw the font
*/
void RenderText(std::string text, float x, float y, int fontSize, Color color);

/** Renders Text Onto the Screen using a c-string (char*)
* @param text The text to render to the screen.
* @param x The X component of the screen to draw the text to.
* @param y The Y component of the screen to draw the text to.
* @param fontSixe The size in points (pt.) to draw the font.
* @param text The text to render to the screen
* @param x The X component of the screen to draw the text to
* @param y The Y component of the screen to draw the text to
* @param fontSize The size in points (pt.) to draw the font
*/
void RenderText(const char* text, float x, float y, int fontSize, Color color);

/** Gets the size of the text if it were to be rendered
* @param text The text to check the size of.
* @param fontSize The size in points (pt.) to check the size of.
* @param text The text to check the size of
* @param fontSize The size in points (pt.) to check the size of
* @return The Size of the Text as a Vector2 with the width as the X component and the height as the Y component
*/
Vector2 TextSize(const char *text, int fontSize);

private:
float getMaxHeightGap(const char *text, int fontSize);
GLuint shaderProgram;
Expand Down
Loading

0 comments on commit 4d57bba

Please sign in to comment.