Dragonfly  4.3
A text-based game engine
Namespaces | Classes | Enumerations | Functions | Variables
df Namespace Reference

Namespaces

 Keyboard
 
 Mouse
 

Classes

class  Box
 
class  Button
 
class  Circle
 
class  Clock
 
class  Config
 
struct  coord_struct
 
class  DisplayManager
 
class  Event
 
class  EventCollision
 
class  EventKeyboard
 
class  EventMouse
 
class  EventOut
 
class  EventPath
 
class  EventStep
 
class  EventView
 
class  Firework
 
class  Frame
 
class  Fraps
 
class  GameManager
 
class  InputManager
 
class  Line
 
class  LogManager
 
class  Manager
 
class  Music
 
struct  node_struct
 
class  Object
 
class  ObjectList
 
class  ObjectListIterator
 
class  Particle
 
class  Path
 
class  PathFind
 
class  PathManager
 
class  Pause
 
class  Precipitation
 
class  ResourceManager
 
class  SceneGraph
 
class  Shape
 
class  Sound
 
class  Splash
 
class  SplashDragonfly
 
class  Sprite
 
class  State
 
class  StateMachine
 
class  TextEntry
 
class  Vector
 
class  ViewObject
 
class  WorldManager
 

Enumerations

enum  ButtonAttribute { HIGHLIGHT_COLOR, DEFAULT_COLOR }
 
enum  Color {
  UNDEFINED_COLOR = -1, BLACK = 0, RED, GREEN,
  YELLOW, BLUE, MAGENTA, CYAN,
  WHITE, CUSTOM
}
 
enum  Justification { LEFT_JUSTIFIED, CENTER_JUSTIFIED, RIGHT_JUSTIFIED }
 
enum  EventKeyboardAction { UNDEFINED_KEYBOARD_ACTION = -1, KEY_PRESSED, KEY_RELEASED, KEY_DOWN }
 
enum  EventMouseAction { UNDEFINED_MOUSE_ACTION = -1, CLICKED, PRESSED, MOVED }
 
enum  SearchResult { NOT_FOUND, INCOMPLETE, FOUND }
 
enum  Solidness { HARD, SOFT, SPECTRAL }
 
enum  ObjectAttribute {
  ID, ACTIVE, VISIBLE, EVENTS,
  BOX, POSITION, TYPE, SPRITE,
  ALTITUDE, SOLIDNESS, NO_SOFT, SPEED,
  DIRECTION, ACCELERATION, SHAPE, PATH,
  FOLLOW_PATH, AVOID_COLLISIONS
}
 
enum  ParticleType {
  UNDEFINED_PARTICLE_TYPE = -1, SMOKE, SPARKS, RINGS,
  FIREWORKS
}
 
enum  ParticleClass { UNDEFINED_PARTICLE_CLASS = -1, PARTICLE, FIREWORK }
 
enum  Direction {
  UNDEFINED_DIRECTION = -1, UP, DOWN, LEFT,
  RIGHT
}
 
enum  PrecipitationType { UNDEFINED_PRECIPITATION_TYPE = -1, SNOW, RAIN, STARFIELD }
 
enum  ShapeType { UNDEFINED_SHAPE = -1, CIRCLE, SQUARE, TRIANGLE }
 
enum  TextEntryAttribute {
  TEXT, LIMIT, CURSOR, CURSOR_CHAR,
  BLINK_RATE, NUMBERS_ONLY
}
 
enum  ViewObjectAttribute {
  VIEW_STRING, VALUE, BORDER, COLOR,
  LOCATION, DRAW_VALUE
}
 
enum  ViewObjectLocation {
  UNDEFINED =-1, TOP_LEFT, TOP_CENTER, TOP_RIGHT,
  CENTER_LEFT, CENTER_CENTER, CENTER_RIGHT, BOTTOM_LEFT,
  BOTTOM_CENTER, BOTTOM_RIGHT
}
 

Functions

float charHeight (void)
 
float charWidth (void)
 
Vector spacesToPixels (Vector spaces)
 
Vector pixelsToSpaces (Vector pixels)
 
bool valueInRange (float value, float min, float max)
 
Box getWorldBox (const Object *p_o)
 
Box getWorldBox (const Object *p_o, Vector where)
 
float distance (Vector p1, Vector p2)
 
float distance (Object *p_o1, Object *p_o2)
 
bool boxContainsPosition (Box b, Vector p)
 
bool lineIntersectsLine (Line line1, Line line2)
 
bool lineIntersectsBox (Line line, Box b)
 
bool boxIntersectsBox (Box box1, Box box2)
 
bool circleIntersectsBox (Circle circle, Box b)
 
int splash ()
 
char * getTimeString ()
 
Vector worldToView (Vector world_pos)
 
Vector viewToWorld (Vector view_pos)
 
std::string toString (int i)
 
std::string toString (float f)
 
std::string toString (char c)
 
std::string toString (bool b)
 
std::string toString (Shape shape)
 
std::string toString (Path path)
 
std::string toString (Keyboard::Key key_val)
 
std::string match (std::string str, std::string find)
 
int addParticles (int count, int count_spread, Vector position, float position_spread, Vector direction, float direction_spread, float size, float size_spread, float speed, float speed_spread, int age, int age_spread, unsigned char opacity, char opacity_spread, unsigned char r, unsigned char g, unsigned char b, unsigned char color_spread, ParticleClass particle_class=PARTICLE)
 
int addParticles (ParticleType type, Vector position, float scale=1.0, Color color=CUSTOM)
 
int addParticles (PrecipitationType type, Direction direction, float scale=1.0, Color color=CUSTOM)
 
void colorToRGB (Color color, unsigned char &r, unsigned char &g, unsigned char &b)
 
sf::Color colorToSFML (Color color)
 
Vector getNormal (const Object *p_o1, const Object *p_o2)
 

Variables

const int BATTR_COUNT = 2
 
const Color COLOR_DEFAULT = WHITE
 
const int WINDOW_HORIZONTAL_PIXELS_DEFAULT = 1024
 
const int WINDOW_VERTICAL_PIXELS_DEFAULT = 768
 
const int WINDOW_HORIZONTAL_CHARS_DEFAULT = 80
 
const int WINDOW_VERTICAL_CHARS_DEFAULT = 24
 
const int WINDOW_STYLE_DEFAULT = sf::Style::Titlebar|sf::Style::Close
 
const Color WINDOW_BACKGROUND_COLOR_DEFAULT = BLACK
 
const std::string WINDOW_TITLE_DEFAULT = "Dragonfly"
 
const std::string FONT_FILE_DEFAULT = "df-font.ttf"
 
const float FONT_SCALE_DEFAULT = 2.0
 
const std::string UNDEFINED_EVENT = "df::undefined"
 
const std::string COLLISION_EVENT = "df::collision"
 
const std::string KEYBOARD_EVENT = "df::keyboard"
 
const std::string MOUSE_EVENT = "df::mouse"
 
const std::string OUT_EVENT = "df::out"
 
const std::string PATH_EVENT = "df::path"
 
const std::string STEP_EVENT = "df::step"
 
const std::string VIEW_EVENT = "df::view"
 
const std::string FRAPS_STRING = "fps"
 
const std::string FRAPS_FILENAME = "fraps"
 
const std::string CONFIG_FILENAME = "df-config.txt"
 
const int FRAME_TIME_DEFAULT = 33
 
const std::string LOGFILE_DEFAULT = "dragonfly.log"
 
const int MAX_EVENTS = 100
 
const int MAX_OBJ_EVENTS = 100
 
const int ATTR_COUNT = 18
 
const int NO_SPREAD =0
 
const std::string FRAMES_TOKEN = "frames"
 
const std::string HEIGHT_TOKEN = "height"
 
const std::string WIDTH_TOKEN = "width"
 
const std::string COLOR_TOKEN = "color"
 
const std::string END_FRAME_TOKEN = "end"
 
const std::string END_SPRITE_TOKEN = "eof"
 
const int MAX_SPRITES = 1000
 
const int MAX_SOUNDS = 128
 
const int MAX_MUSICS = 128
 
const int MAX_ALTITUDE = 4
 
const std::string UNDEFINED_STATE = "__undefined state__"
 
const int TATTR_COUNT = 6
 
const int VATTR_COUNT = 6
 

Detailed Description

A 2-d bounding box.

The view object.

A 2d (x,y) vector.

A basic TextEntry.

A finite state machine.

State.h.

The sprite.

Dragonfly for splash screen.

Text for splash screen.

The sound.

A single-space, 2d shape for drawing.

A scene graph.

A precipitation particle.

An A* pathfinding class.

A particle.

An iterator for ObjectLists.

A list of Objects.

The base game world object.

The music.

The base manager.

A line segment.

Fraps (FRAmes Per Second) recorder.

A sprite frame.

A firework particle.

A "view" event.

A "step" event, generated once per game loop.

An "pathfinding" event.

An "out of bounds" event.

A "mouse" event.

A "keyboard" event.

A "collision" event.

The base event.

Colors for Dragonfly.

The clock, for timing.

A 2d circle.

A basic button.

Invokes callback() when clicked. Changes to highlight color on mouse over.

< Objects have a bounding box. < Objects can handle events. < Objects can seek along path. Objects can do pathfinding. Objects can have simple drawing shapes. < Objects (often) have sprites. Objects need a float location.

Enumeration Type Documentation

Categories of button attributes that indicate modification.

enum df::Color

Colors Dragonfly recognizes.

Directions.

Types of keyboard actions Dragonfly recognizes.

Enumerator
UNDEFINED_KEYBOARD_ACTION 

Undefined.

KEY_PRESSED 

Was down.

KEY_RELEASED 

Was released.

KEY_DOWN 

Is down.

Set of mouse actions recognized by Dragonfly.

String justifications.

Categories of attributes that indicate modification.

Particle classes.

Particle types.

Precipitation types.

Types of solidness of Object.

Enumerator
HARD 

Object causes collisions and impedes.

SOFT 

Object causes collision, but doesn't impede.

SPECTRAL 

Object doesn't cause collisions.

Categories of text entry attributes that indicate modification.

Categories of view object attributes that indicate modification.

General location of ViewObject on screen.

Function Documentation

int df::addParticles ( int  count,
int  count_spread,
Vector  position,
float  position_spread,
Vector  direction,
float  direction_spread,
float  size,
float  size_spread,
float  speed,
float  speed_spread,
int  age,
int  age_spread,
unsigned char  opacity,
char  opacity_spread,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  color_spread,
ParticleClass  particle_class = PARTICLE 
)

Add particles.

Each parameter has average and spread. count - number to add position - location direction - direction to move [(0,0) for random] size - size (pixels) speed - speed (spaces/tick) age - age (ticks) opacity - how "see through" [0-255, 0 is transparent] r, g, b - color in RGB values Particle class - class to add (default is PARTICLE). Return 0 if ok, else -1.

int df::addParticles ( ParticleType  type,
Vector  position,
float  scale = 1.0,
Color  color = CUSTOM 
)

Add particles of specific type.

type - type of particle: SMOKE, SPARKS, RINGS, FIREWORKS. position - location scale - scale size (default 1.0) color - dragonfly color to use (default 'built-in') Return 0 if ok, else -1.

int df::addParticles ( PrecipitationType  type,
Direction  direction,
float  scale = 1.0,
Color  color = CUSTOM 
)

Add environment particles of specific type.

type - type of particle: RAIN, SNOW, STARFIELD. scale - scale size (default 1.0) color - dragonfly color to use (default 'built-in') Return 0 if ok, else -1.

bool df::boxContainsPosition ( Box  b,
Vector  p 
)

Return true of position is within Box.

bool df::boxIntersectsBox ( Box  box1,
Box  box2 
)

Return true if Boxes intersect.

float df::charHeight ( void  )

Compute character height, based on window size and font.

float df::charWidth ( void  )

Compute character width, based on window size and font.

bool df::circleIntersectsBox ( Circle  circle,
Box  b 
)

Return true if Circle intersects or contains Box.

void df::colorToRGB ( Color  color,
unsigned char &  r,
unsigned char &  g,
unsigned char &  b 
)

Set RGB color based on DF color.

sf::Color df::colorToSFML ( Color  color)

Return SFML color based on DF color.

float df::distance ( Vector  p1,
Vector  p2 
)

Return distance between any two positions.

float df::distance ( Object p_o1,
Object p_o2 
)

Return distance between any two Objects.

Return -1.0 if error.

Vector df::getNormal ( const Object p_o1,
const Object p_o2 
)

Return normal between two colliding Objects.

Object 1 caused collision with Object 2. Return (0,0) if no normal (no collision or Object 1 inside Object 2).

char* df::getTimeString ( )

Returns pretty-formatted time as char * string.

Box df::getWorldBox ( const Object p_o)

Convert relative bounding Box for Object to absolute world Box.

Box df::getWorldBox ( const Object p_o,
Vector  where 
)

Convert relative bounding Box for Object to absolute world Box at postion where.

bool df::lineIntersectsBox ( Line  line,
Box  b 
)

Return true if Line segment intersects Box.

bool df::lineIntersectsLine ( Line  line1,
Line  line2 
)

Return true if Line segments intersect.

(Parallel line segments don't intersect). (Co-linear lines will NOT intersect).

std::string df::match ( std::string  str,
std::string  find 
)

Match key:value pair in string in str, returning value.

Pairs separated by commas (,). If str is empty, use previously parsed string str. All whitespace is ignored. Return empty string if no match.

Vector df::pixelsToSpaces ( Vector  pixels)

Convert window pixels (x,y) to ASCII spaces (x,y).

Vector df::spacesToPixels ( Vector  spaces)

Convert ASCII spaces (x,y) to window pixels (x,y).

int df::splash ( )

Launch splash screen. Return 0 if ok, else -1.

std::string df::toString ( int  i)

Convert integer to string, returning string.

std::string df::toString ( float  f)

Convert float to string, returning string.

std::string df::toString ( char  c)

Convert character to string, returning string.

std::string df::toString ( bool  b)

Convert boolean to string, returning string.

std::string df::toString ( Shape  shape)

Convert Dragonfly Shape to string, returning string.

std::string df::toString ( Path  path)

Convert Path nodes (not index) to string.

std::string df::toString ( Keyboard::Key  key_val)

Convert Dragonfly key to string.

bool df::valueInRange ( float  value,
float  min,
float  max 
)

Return true if value is between min and max (inclusive).

Vector df::viewToWorld ( Vector  view_pos)

Convert view position to world position.

Vector df::worldToView ( Vector  world_pos)

Convert world position to view position.

Variable Documentation

const int df::ATTR_COUNT = 18

Count of number of modified attribute categories.

const int df::BATTR_COUNT = 2

Count of number of button modified attribute categories.

const Color df::COLOR_DEFAULT = WHITE

If color not specified, will use this.

const std::string df::CONFIG_FILENAME = "df-config.txt"

Dragonfly cofiguration file.

const int df::FRAME_TIME_DEFAULT = 33

Default frame time (game loop time) in milliseconds (33 ms == 30 f/s).

const int df::MAX_EVENTS = 100

Max number of different events.

const int df::MAX_OBJ_EVENTS = 100

Max number of events Object can be interested in.

const int df::NO_SPREAD =0

Constants.

const int df::TATTR_COUNT = 6

Count of number of text entry modified attribute categories.

const int df::VATTR_COUNT = 6

Count of number of view object modified attribute categories.

const int df::WINDOW_HORIZONTAL_PIXELS_DEFAULT = 1024

Defaults for SFML window.