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

Namespaces

namespace  Keyboard
 
namespace  Mouse
 

Classes

class  Animation
 
class  Box
 
class  Button
 
class  Circle
 
class  Clock
 
class  Config
 
struct  coord_struct
 
class  DisplayManager
 
class  Event
 
class  EventCollision
 
class  EventCustomNetwork
 
class  EventKeyboard
 
class  EventKeyboardNetwork
 
class  EventMouse
 
class  EventMouseNetwork
 
class  EventNetwork
 
class  EventOut
 
class  EventPath
 
class  EventStep
 
class  EventView
 
class  Firework
 
class  Frame
 
class  Fraps
 
class  GameManager
 
class  Grid
 
class  InputManager
 
class  Line
 
class  LogManager
 
class  Manager
 
class  Music
 
class  NetworkManager
 
class  NetworkNode
 
struct  node_struct
 
class  Object
 
class  ObjectList
 
class  ObjectListIterator
 
class  Particle
 
class  Path
 
class  PathFind
 
class  PathManager
 
class  Pause
 
class  Precipitation
 
class  QuadtreeNode
 
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
 

Typedefs

typedef std::tuple< int, int > Cell
 

Enumerations

enum  ButtonAttribute { ALL_BUTTON , MODIFIED_BUTTON , 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  MessageType {
  UNDEFINED_MESSAGE =-1 , SYNC_OBJECT , DELETE_OBJECT , SET_GAME_OVER ,
  KEYBOARD_INPUT , MOUSE_INPUT , CUSTOM_MESSAGE
}
 
enum  Solidness { HARD , SOFT , SPECTRAL }
 
enum  ObjectAttribute {
  ID , ACTIVE , VISIBLE , EVENTS ,
  BOX , POSITION , TYPE , ANIMATION ,
  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 {
  ALL_TEXT , MODIFIED_TEXT , 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 boxContainsBox (Box b1, Box b2)
 
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 (Color color)
 
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 = 4
 
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 NETWORK_CUSTOM_EVENT = "df-custom-network"
 
const std::string KEYBOARD_EVENT = "df-keyboard"
 
const std::string NETWORK_KEYBOARD_EVENT = "df-keyboard-network"
 
const std::string MSE_EVENT = "df-mouse"
 
const std::string NETWORK_MSE_EVENT = "df-mouse-network"
 
const std::string NETWORK_EVENT = "df-network"
 
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 int GRID_WIDTH_DEFAULT = 20
 
const int GRID_HEIGHT_DEFAULT = 8
 
const std::string LOGFILE_DEFAULT = "dragonfly.log"
 
const int MAX_EVENTS = 100
 
const std::string DRAGONFLY_PORT = "9876"
 
const int MAX_OBJ_EVENTS = 100
 
const int ATTR_COUNT = 18
 
const int NO_SPREAD =0
 
const int QUADTREE_THRESH_DEFAULT = 1
 
const int QUADTREE_MAX_DEPTH = 10
 
const int MAX_SPRITES = 1000
 
const int MAX_SOUNDS = 100
 
const int MAX_MUSICS = 50
 
const int MAX_ALTITUDE = 4
 
const std::string UNDEFINED_STATE = "__undefined state__"
 
const int TATTR_COUNT = 8
 
const int VATTR_COUNT = 6
 

Detailed Description

An animation for a sprite.

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 precipitation particle.

PathFind.

A particle.

An iterator for ObjectLists.

A list of Objects.

The base game world object.

NetworkNode.h.

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 over the network.

A "mouse" event.

A "keyboard" event over the network.

A "keyboard" event.

A "custom" event over the network.

A "collision" event.

The base event.

Colors for Dragonfly.

The clock, for timing.

A 2d circle.

A basic button.

A 2-d bounding box.

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

Handle incoming network messages.

< Objects (often) have animated sprites. < 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 need a float location.

An A* pathfinding class.

Enumeration Type Documentation

◆ ButtonAttribute

Categories of button attributes that indicate modification.

◆ Color

enum df::Color

Colors Dragonfly recognizes.

◆ Direction

Directions.

◆ EventKeyboardAction

Types of keyboard actions Dragonfly recognizes.

Enumerator
UNDEFINED_KEYBOARD_ACTION 

Undefined.

KEY_PRESSED 

Was down.

KEY_RELEASED 

Was released.

KEY_DOWN 

Is down.

◆ EventMouseAction

Set of mouse actions recognized by Dragonfly.

◆ Justification

String justifications.

◆ ObjectAttribute

Categories of attributes that indicate modification.

◆ ParticleClass

Particle classes.

◆ ParticleType

Particle types.

◆ PrecipitationType

Precipitation types.

◆ Solidness

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.

◆ TextEntryAttribute

Categories of text entry attributes that indicate modification.

◆ ViewObjectAttribute

Categories of view object attributes that indicate modification.

◆ ViewObjectLocation

General location of ViewObject on screen.

Function Documentation

◆ addParticles() [1/3]

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.

◆ addParticles() [2/3]

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.

◆ addParticles() [3/3]

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. direction - direction particle travels: UP, DOWN, LEFT, RIGHT. scale - scale size (default 1.0) color - dragonfly color to use (default 'built-in') Return 0 if ok, else -1.

◆ boxContainsBox()

bool df::boxContainsBox ( Box  b1,
Box  b2 
)

Return true if Box 1 completely contains Box 2.

◆ boxContainsPosition()

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

Return true of position is within Box.

◆ boxIntersectsBox()

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

Return true if Boxes intersect.

◆ charHeight()

float df::charHeight ( void  )

Compute character height in pixels, based on window size.

◆ charWidth()

float df::charWidth ( void  )

Compute character width in pixels, based on window size.

◆ circleIntersectsBox()

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

Return true if Circle intersects or contains Box.

◆ colorToRGB()

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

Set RGB color based on DF color.

◆ colorToSFML()

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

Return SFML color based on DF color.

◆ distance() [1/2]

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

Return distance between any two Objects.

Return -1.0 if error.

◆ distance() [2/2]

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

Return distance between any two positions.

◆ getNormal()

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).

◆ getTimeString()

char * df::getTimeString ( )

Returns pretty-formatted time as char * string.

◆ getWorldBox() [1/2]

Box df::getWorldBox ( const Object p_o)

Convert relative bounding Box for Object to absolute world Box.

◆ getWorldBox() [2/2]

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

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

◆ lineIntersectsBox()

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

Return true if Line segment intersects Box.

◆ lineIntersectsLine()

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).

◆ match()

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.

◆ pixelsToSpaces()

Vector df::pixelsToSpaces ( Vector  pixels)

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

◆ spacesToPixels()

Vector df::spacesToPixels ( Vector  spaces)

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

◆ splash()

int df::splash ( )

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

◆ toString() [1/8]

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

Convert boolean to string, returning string.

◆ toString() [2/8]

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

Convert character to string, returning string.

◆ toString() [3/8]

std::string df::toString ( Color  color)

Convert Dragonfly Color to string, returning string.

◆ toString() [4/8]

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

Convert float to string, returning string.

◆ toString() [5/8]

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

Convert integer to string, returning string.

◆ toString() [6/8]

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

Convert Dragonfly key to string, returning string.

◆ toString() [7/8]

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

Convert Path nodes (not index) to string, returning string.

◆ toString() [8/8]

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

Convert Dragonfly Shape to string, returning string.

◆ valueInRange()

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

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

◆ viewToWorld()

Vector df::viewToWorld ( Vector  view_pos)

Convert view position to world position.

◆ worldToView()

Vector df::worldToView ( Vector  world_pos)

Convert world position to view position.

Variable Documentation

◆ ATTR_COUNT

const int df::ATTR_COUNT = 18

Count of number of modified attribute categories.

◆ BATTR_COUNT

const int df::BATTR_COUNT = 4

Count of number of button modified attribute categories.

◆ COLOR_DEFAULT

const Color df::COLOR_DEFAULT = WHITE

If color not specified, will use this.

◆ CONFIG_FILENAME

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

Default Dragonfly cofiguration file.

Override with DRAGONFLY_CONFIG environment variable.

◆ FRAME_TIME_DEFAULT

const int df::FRAME_TIME_DEFAULT = 33

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

◆ LOGFILE_DEFAULT

const std::string df::LOGFILE_DEFAULT = "dragonfly.log"

Default Dragonfly logfile.

Override with DRAGONFLY_LOG environment variable.

◆ MAX_EVENTS

const int df::MAX_EVENTS = 100

Max number of different events.

◆ MAX_OBJ_EVENTS

const int df::MAX_OBJ_EVENTS = 100

Max number of events Object can be interested in.

◆ NO_SPREAD

const int df::NO_SPREAD =0

Constants.

◆ TATTR_COUNT

const int df::TATTR_COUNT = 8

Count of number of text entry modified attribute categories.

◆ VATTR_COUNT

const int df::VATTR_COUNT = 6

Count of number of view object modified attribute categories.

◆ WINDOW_HORIZONTAL_PIXELS_DEFAULT

const int df::WINDOW_HORIZONTAL_PIXELS_DEFAULT = 1024

Defaults for SFML window.