Gamedev Framework (gf)  0.5.0
A C++11 framework for 2D games
Classes | Typedefs | Enumerations | Functions
Game classes

All the classes related to game systems and game entities. More...

Classes

class  gf::ValueActivity
 An activity for a simple float value. More...
 
class  gf::RotateToActivity
 An activity for a change of angle. More...
 
class  gf::MoveToActivity
 An activity for a change of position. More...
 
class  gf::ColorActivity
 An activity for a change of color. More...
 
class  gf::CallbackActivity
 An activity for calling a function once. More...
 
class  gf::DelayActivity
 An activity to wait for a predefined duration. More...
 
class  gf::SequenceActivity
 An activity to run several activities sequentially. More...
 
class  gf::RepeatActivity
 An activity to run an activity several times. More...
 
class  gf::ParallelActivity
 An activity to run several activities in parallel. More...
 
class  gf::Activity
 A game activity. More...
 
class  gf::AssetManager
 An asset manager. More...
 
struct  gf::Penetration
 Data about the collision between two objects. More...
 
class  gf::Entity
 A game entity. More...
 
class  gf::EntityContainer
 A collection of entities. More...
 
class  gf::Bresenham
 State for the Bresenham's line algorithm. More...
 
struct  gf::Message
 The base class for all messages. More...
 
class  gf::MessageManager
 A message manager. More...
 
class  gf::Model
 A game object that can be updated. More...
 
class  gf::ModelContainer
 A collection of models. More...
 
class  gf::FixedTimestepModel
 Fixed timestep model. More...
 
class  gf::PhysicsBody
 A physics body. More...
 
class  gf::PhysicsGeometry
 The geometry of a physics body. More...
 
class  gf::PhysicsModel
 A model for physics simulation. More...
 
class  gf::ResourceCache< T >
 A generic cache for resources. More...
 
class  gf::ResourceManager
 A resource manager. More...
 
class  gf::TextureAtlas
 A collection of sub-texture. More...
 
class  gf::Tween< T >
 An interpolation between two values. More...
 

Typedefs

using gf::MessageHandler = std::function< MessageStatus(Id, Message *)>
 A message handler. More...
 
using gf::MessageHandlerId = uint64_t
 An identifier for a message handler. More...
 

Enumerations

enum  gf::ActivityStatus {
  gf::ActivityStatus::Running,
  gf::ActivityStatus::Finished
}
 Status of an activity. More...
 
enum  gf::MessageStatus {
  gf::MessageStatus::Keep,
  gf::MessageStatus::Die
}
 A message status. More...
 

Functions

std::vector< Vector2igf::generateLine (Vector2i p0, Vector2i p1)
 Generate a line between two positions. More...
 
std::vector< Vector2fgf::midpointDisplacement1D (Vector2f p0, Vector2f p1, Random &random, unsigned iterations, Vector2f direction, float initialFactor=1.0f, float reductionFactor=0.5f)
 1D midpoint displacement More...
 
std::vector< Vector2fgf::midpointDisplacement1D (Vector2f p0, Vector2f p1, Random &random, unsigned iterations, float initialFactor=1.0f, float reductionFactor=0.5f)
 1D midpoint displacement More...
 

Detailed Description

All the classes related to game systems and game entities.

Typedef Documentation

◆ MessageHandler

using gf::MessageHandler = typedef std::function<MessageStatus(Id, Message *)>

A message handler.

gf::MessageHandler is a function that can be called when a message is sent in a message handler. It can be a free function:

gf::MessageStatus onHeroPosition(gf::Id type, gf::Message *msg) {
assert(type == HeroPosition::type);
auto heroPosition = static_cast<HeroPosition*>(msg);
// do something with heroPosition->position ...
}
// ...
gf::MessageHandler handler = onHeroPosition;

It can also be a member function (which is, in fact, the most probable use case).

struct Foo {
gf::MessageStatus onHeroPosition(gf::Id type, gf::Message *msg) {
assert(type == HeroPosition::type);
auto heroPosition = static_cast<HeroPosition*>(msg);
// do something with heroPosition->position ...
}
};
// ...
Foo foo;
gf::MessageHandler handler = std::bind(&Foo::onHeroPosition, &foo);
See also
gf::MessageManager, gf::Message, gf::Id

◆ MessageHandlerId

using gf::MessageHandlerId = typedef uint64_t

An identifier for a message handler.

See also
gf::MessageHandler

Enumeration Type Documentation

◆ ActivityStatus

enum gf::ActivityStatus
strong

Status of an activity.

See also
gf::Activity
Enumerator
Running 

The activity is still running.

Finished 

The activity is finished.

◆ MessageStatus

enum gf::MessageStatus
strong

A message status.

gf::MessageStatus indicates if a handler should be kept by the message manager or can be removed so that it will not receive any more messages.

See also
gf::MessageManager, gf::MessageHandler
Enumerator
Keep 

The handler must be kept

Die 

The handler can be removed

Function Documentation

◆ generateLine()

std::vector<Vector2i> gf::generateLine ( Vector2i  p0,
Vector2i  p1 
)

Generate a line between two positions.

This function uses Bresenham's line algorithm.

Parameters
p0The first point of the line
p1The last point of the line
Returns
A series of point beginning at the first point and ending just before the last point
See also
gf::Bresenham

◆ midpointDisplacement1D() [1/2]

std::vector<Vector2f> gf::midpointDisplacement1D ( Vector2f  p0,
Vector2f  p1,
Random random,
unsigned  iterations,
Vector2f  direction,
float  initialFactor = 1.0f,
float  reductionFactor = 0.5f 
)

1D midpoint displacement

Parameters
p0The first end point
p1The second end point
randomA random engine
iterationsThe number of iterations
directionThe direction to make a displacement
initialFactorThe initial factor to apply to the displacement
reductionFactorThe factor to apply at each iteration

◆ midpointDisplacement1D() [2/2]

std::vector<Vector2f> gf::midpointDisplacement1D ( Vector2f  p0,
Vector2f  p1,
Random random,
unsigned  iterations,
float  initialFactor = 1.0f,
float  reductionFactor = 0.5f 
)

1D midpoint displacement

The direction is perpendicular to the segment \( [P_0 P_1] \)

Parameters
p0The first end point
p1The second end point
randomA random engine
iterationsThe number of iterations
initialFactorThe initial factor to apply to the displacement
reductionFactorThe factor to apply at each iteration