The Game Engine  1
Text Class Reference

On-screen text. More...

#include <Text.h>

+ Inheritance diagram for Text:
+ Collaboration diagram for Text:

Public Member Functions

 Text (string name, string t, int size=24, Color c=Color::WHITE, int w=600, int h=150, Point2D pos=Point2D())
 Creates a Text with the given name and text with the correct color and size. More...
 
 Text (string filename, string sectionName, FontType t, int size=24, Color c=Color::WHITE, int w=600, int h=150, Point2D pos=Point2D())
 Creates a Text with the given name and text with the correct color and size. More...
 
 ~Text ()
 
void draw ()
 Draw the object. More...
 
void update ()
 What the text should do on update (currently unimplemented) More...
 
void setStartLine (unsigned int line)
 Sets the start line if possible. More...
 
int getLastLine ()
 Gets the last line that was drawn. More...
 
Point2D getBasePos ()
 Obtain Base Pos for drawing. More...
 
Point2D getCenterPos ()
 Obtain Center Pos for Collisions. More...
 
virtual WorldObjectType getType ()
 This provides a simple interface to determine types of objects. More...
 
void wrap ()
 This wraps the text as well as I can guess. More...
 
- Public Member Functions inherited from WorldObject
 WorldObject (std::string name, Point2D pos=Point2D(), int z=0)
 
virtual void drawCollisions ()
 Draws CollisionObject data for the Object. More...
 
void drawCollisions (vector< CollisionObject * > &vec, const Point2D &pos)
 Draws CollisionObject data for the Object. More...
 
virtual void runBehavior ()
 Behavior that WorldObject follows. More...
 
void setPosition (double x, double y)
 Sets the WorldObject's x an y coordinate. More...
 
void setPosition (Point2D pos)
 Sets the WorldObject's x an y coordinate. More...
 
void setBasePosition (double x, double y)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setBasePosition (Point2D pos)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setCenterPosition (double x, double y)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setCenterPosition (Point2D pos)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void move (double dx=0.0, double dy=0.0)
 Move by given amount NOTE: This is an instantaneous movement by a given amount and does not correspond to physics which is set to do the updated amount per second. More...
 
virtual void move (Point2D direction)
 Moves the WorldObject relative to the current pos. More...
 
virtual void moveTowards (Point2D direction)
 Move towards a given coordinate (path finding) More...
 
Point2D getPosition ()
 Gets the WorldObject's position. More...
 
void setTransparency (float f)
 Sets the WorldObject's transparency. More...
 
float getTransparency ()
 Gets the WorldObject's transparency. More...
 
void setAngle (float a)
 Sets the WorldObject's angle in degrees. More...
 
float getAngle ()
 Gets the WorldObject's angle. More...
 
void setVelocity (Point2D vel)
 Sets the WorldObject's velocity as a vector (will set MaxVelocity if needed) More...
 
void setVelocity (double xVel, double yVel)
 Sets the WorldObject's velocity from coordinates (will set MaxVelocity if needed) More...
 
Point2D getVelocity ()
 Gets the WorldObject's Velocity. More...
 
void setMaxVelocity (Point2D vel)
 Sets the WorldObject's MaxVelocity (magnitude) from (x,y) and transforms into a magnitude. More...
 
void setMaxVelocity (double vel, Point2D dir)
 Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More...
 
void setMaxSpeed (double vel)
 Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More...
 
Point2D getMaxVelocity ()
 Gets the WorldObject's Max Velocity. More...
 
double getMaxSpeed ()
 Gets the WorldObject's Max Speed. More...
 
double getMaxSpeedSquared ()
 Gets the WorldObject's Max Speed Squared (cheaper operation). More...
 
void setAcceleration (Point2D accel)
 Sets the WorldObject's Acceleration in (x,y) coords. More...
 
Point2D getAcceleration ()
 Gets the WorldObject's Acceleration. More...
 
void setZOrder (int i)
 
int getZOrder ()
 
std::string getName ()
 returns the WorldObject's name More...
 
bool operator< (WorldObject &rhs)
 Sort worldObjects. More...
 

Public Attributes

FontmFont
 Pointer to the font that this text uses. More...
 
vector< string > lines
 The lines of text to be rendered. More...
 
Color color
 Color to displaty the text. More...
 
int width
 The width to draw the text. More...
 
int height
 Height of the text object. More...
 

Protected Attributes

int startline
 The first line to draw when rendering. More...
 
int lastline
 The last line drawn (for scrolling text boxes) More...
 
- Protected Attributes inherited from WorldObject
std::string mName
 WorldObject's name. More...
 
Point2D mPos
 The current (x,y) position. More...
 
Point2D mVelocity
 The current velocity vector. More...
 
Point2D mMaxVelocity
 The max velocity is the max possible velocity where lengthis the speed. More...
 
double mMaxSpeed
 The max Speed if MaxVelocity is 0 to store val. More...
 
Point2D mAcceleration
 The current acceleration vector. More...
 
bool mVisible
 Determine if Object should be visible. More...
 
float mTransparency
 Transparency! More...
 
float mAngle
 Angle of rotation. More...
 
float mScale
 Scale for the sprit. More...
 
int ZOrder
 Stacking order. Determines what draws on top. (subsorted by position) More...
 
long mLastUpdate
 Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More...
 
long mLastDraw
 Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More...
 
bool mUnused
 Determines whether or not this object's update function should run. More...
 
Behavior mBehavior
 Behavior to act each loop if !mUnused. More...
 

Additional Inherited Members

- Public Types inherited from WorldObject
enum  WorldObjectType {
  SPRITE, BACKGROUND, MENU, TEXT,
  PARTICLESYSTEM
}
 This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency. More...
 

Detailed Description

On-screen text.

This class is tasked with the following:

  • displaying text on screen.

    • wrapping text (eventually)

    Note: This should always be created and destroyed by some object.

Definition at line 22 of file Text.h.

Constructor & Destructor Documentation

Text::Text ( string  name,
string  t,
int  size = 24,
Color  c = Color::WHITE,
int  w = 600,
int  h = 150,
Point2D  pos = Point2D() 
)

Creates a Text with the given name and text with the correct color and size.

Parameters
nameName for the text
ttext to be drawn to the screen
sizeSize of the font
cColor for the font
wWidth of the text box
hHeight of the text box
posPosition of the top left of the text

Definition at line 73 of file Text.cpp.

+ Here is the call graph for this function:

Text::Text ( string  filename,
string  sectionName,
FontType  t,
int  size = 24,
Color  c = Color::WHITE,
int  w = 600,
int  h = 150,
Point2D  pos = Point2D() 
)

Creates a Text with the given name and text with the correct color and size.

Parameters
filenameThe name of the yaml file to parse w/o path nor extension
sectionNameName of the section within a yaml doc
ttext to be drawn to the screen
sizeSize of the font
cColor for the font
wWidth of the text box
hHeight of the text box
posPosition of the top left of the text
Todo:
move this to TextBox or some other class. This really shoudln't be a constructor for Text

Definition at line 13 of file Text.cpp.

+ Here is the call graph for this function:

Text::~Text ( )

Definition at line 88 of file Text.cpp.

+ Here is the call graph for this function:

Member Function Documentation

void Text::draw ( )
virtual

Draw the object.

Todo:
split the strings and then add an entry like \t at the end of each'page' to denote difference between same text or a new blob of text.

Implements WorldObject.

Definition at line 93 of file Text.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Point2D Text::getBasePos ( )
inlinevirtual

Obtain Base Pos for drawing.

Implements WorldObject.

Definition at line 83 of file Text.h.

Point2D Text::getCenterPos ( )
inlinevirtual

Obtain Center Pos for Collisions.

Implements WorldObject.

Definition at line 88 of file Text.h.

int Text::getLastLine ( )

Gets the last line that was drawn.

Definition at line 177 of file Text.cpp.

virtual WorldObjectType Text::getType ( )
inlinevirtual

This provides a simple interface to determine types of objects.

Returns the name of the Class and Descendants i.e. Something inheriting from Sprite would look like Sprite:Thing

Implements WorldObject.

Definition at line 93 of file Text.h.

void Text::setStartLine ( unsigned int  line)

Sets the start line if possible.

Parameters
lineline to begin

Definition at line 172 of file Text.cpp.

void Text::update ( )
virtual

What the text should do on update (currently unimplemented)

Reimplemented from WorldObject.

Definition at line 166 of file Text.cpp.

+ Here is the call graph for this function:

void Text::wrap ( )

This wraps the text as well as I can guess.

Todo:
implement it sometime add one char at a time until the next char would make it too long and wrap like that (will probably break for jap but that's the best I can come up with for now)

Definition at line 182 of file Text.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

Color Text::color

Color to displaty the text.

Definition at line 60 of file Text.h.

int Text::height

Height of the text object.

Definition at line 72 of file Text.h.

int Text::lastline
protected

The last line drawn (for scrolling text boxes)

Definition at line 105 of file Text.h.

vector<string> Text::lines

The lines of text to be rendered.

Definition at line 57 of file Text.h.

Font* Text::mFont

Pointer to the font that this text uses.

Definition at line 54 of file Text.h.

int Text::startline
protected

The first line to draw when rendering.

Definition at line 102 of file Text.h.

int Text::width

The width to draw the text.

Definition at line 69 of file Text.h.


The documentation for this class was generated from the following files: