Dragonfly 4.20
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  Debris
 
class  DisplayManager
 
class  Event
 
class  EventCollision
 
class  EventKeyboard
 
class  EventKeyboardNetwork
 
class  EventMouse
 
class  EventMouseNetwork
 
class  EventNetwork
 
class  EventNetworkCreate
 
class  EventNetworkCustom
 
class  EventNetworkDelete
 
class  EventNetworkGameOver
 
class  EventNetworkSync
 
class  EventOut
 
class  EventPath
 
class  EventStep
 
class  EventView
 
class  Fader
 
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  TextBox
 
class  TextEntry
 
class  Vector
 
class  ViewObject
 
class  WorldManager
 

Typedefs

typedef std::tuple< int, int > Cell
 
using delayedMessage = std::tuple< int, char *, size_t >
 
using delayQueue = std::queue< delayedMessage >
 

Enumerations

enum class  ButtonAttribute : unsigned int { APPEARANCE = 1 << (ViewObjectAttributeMax + 0) }
 
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 class  NetworkEventLabel {
  UNDEFINED = -1 , ACCEPT , CONNECT , CLOSE ,
  DATA
}
 
enum  SearchResult { NOT_FOUND , INCOMPLETE , FOUND }
 
enum class  MessageType {
  UNDEFINED_MESSAGE =-1 , SYNC_OBJECT , DELETE_OBJECT , SET_GAME_OVER ,
  KEYBOARD_INPUT , MOUSE_INPUT , CUSTOM_MESSAGE
}
 
enum  Solidness { HARD , SOFT , SPECTRAL }
 
enum class  ObjectAttribute : unsigned int {
  ID = 1 << 0 , ACTIVE = 1 << 1 , VISIBLE = 1 << 2 , EVENTS = 1 << 3 ,
  BOX = 1 << 4 , POSITION = 1 << 5 , TYPE = 1 << 6 , ANIMATION = 1 << 7 ,
  ALTITUDE = 1 << 8 , SOLIDNESS = 1 << 9 , NO_SOFT = 1 << 10 , SPEED = 1 << 11 ,
  DIRECTION = 1 << 12 , ACCELERATION = 1 << 13 , SHAPE = 1 << 14 , PATH = 1 << 15 ,
  FOLLOW_PATH = 1 << 16 , AVOID_COLLISIONS = 1 << 17
}
 
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 class  TextBoxAttribute : unsigned int { TEXT = 1 << (ViewObjectAttributeMax + 0) , APPEARANCE = 1 << (ViewObjectAttributeMax + 1) }
 
enum class  TextEntryAttribute : unsigned int { TEXT = 1 << (ViewObjectAttributeMax + 0) , APPEARANCE = 1 << (ViewObjectAttributeMax + 1) }
 
enum class  ViewObjectAttribute : unsigned int { VALUE = 1 << (ObjectAttributeMax + 0) , APPEARANCE = 1 << (ObjectAttributeMax + 1) }
 
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 (Color color)
 
std::string toString (Path path)
 
std::string toString (Keyboard::Key key_val)
 
std::string toString (Solidness solid)
 
std::string toString (ViewObjectLocation location)
 
std::string toString (MessageType message)
 
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)
 
std::string maskToString (unsigned int mask)
 
int explode (const Sprite *p_sprite, int index, Vector position, int age, float speed, float rotate)
 
float vectorToAngle (df::Vector v)
 

Variables

const int ButtonAttributeMax = ViewObjectAttributeMax + 1
 
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 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 NETWORK_CREATE_EVENT = "df-network-create"
 
const std::string NETWORK_CUSTOM_EVENT = "df-custom-network"
 
const std::string NETWORK_DELETE_EVENT = "df-network-delete"
 
const std::string NETWORK_GAME_OVER_EVENT = "df-network-game-over"
 
const std::string NETWORK_SYNC_EVENT = "df-network-sync"
 
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 ObjectAttributeMax = 18
 
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 TextBoxAttributeMax = ViewObjectAttributeMax + 2
 
const int TextEntryAttributeMax = ViewObjectAttributeMax + 2
 
const int ViewObjectAttributeMax = ObjectAttributeMax + 2
 

Detailed Description

An animation for a sprite.

The view object.

A 2d (x,y) vector.

A basic TextEntry.

A basic TextBox, with word wrap and scrolling.

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 "collision" event.

The base event.

A debris particle.

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

enum class df::ButtonAttribute : unsigned int
strong

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

enum class df::ObjectAttribute : unsigned int
strong

Categories of Object 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.

◆ TextBoxAttribute

enum class df::TextBoxAttribute : unsigned int
strong

Categories of TextBox attributes that indicate modification.

◆ TextEntryAttribute

enum class df::TextEntryAttribute : unsigned int
strong

Categories of TextEntry attributes that indicate modification.

◆ ViewObjectAttribute

enum class df::ViewObjectAttribute : unsigned int
strong

Categories of ViewObject attributes that indicate modification.

◆ ViewObjectLocation

General location 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.

◆ explode()

int df::explode ( const Sprite p_sprite,
int  index,
Vector  position,
int  age,
float  speed,
float  rotate 
)

"Explode" a sprite frame into small, Particles.

index - frame index position - location of frame position - location of frame age - how long it should last (in ticks) speed - speed (in spaces per tick) (negative to "implode") rotate - degrees to spin (per tick) Return 0 if ok, else -1.

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

◆ maskToString()

std::string df::maskToString ( unsigned int  mask)

Return bitmask as string.

◆ 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/9]

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

Convert boolean to string, returning string.

◆ toString() [2/9]

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

Convert character to string, returning string.

◆ toString() [3/9]

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

Convert Dragonfly Color to string, returning string.

◆ toString() [4/9]

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

Convert float to string, returning string.

◆ toString() [5/9]

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

Convert integer to string, returning string.

◆ toString() [6/9]

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

Convert Dragonfly key to string, returning string.

◆ toString() [7/9]

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

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

◆ toString() [8/9]

std::string df::toString ( Solidness  solid)

Convert Solidness to string, returning string.

◆ toString() [9/9]

std::string df::toString ( ViewObjectLocation  location)

Convert ViewObjectLocation 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

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

◆ WINDOW_HORIZONTAL_PIXELS_DEFAULT

const int df::WINDOW_HORIZONTAL_PIXELS_DEFAULT = 1024

Defaults for SFML window.