The Game Engine  1
fns.h File Reference
#include <SDL/SDL.h>
#include <string>
#include <iostream>
#include <sstream>
#include <GL/gl.h>
#include <vector>
#include "Texture.h"
#include <math.h>
+ Include dependency graph for fns.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Point2D
 2D position or vector placed here because of general access More...
 
class  Size2D
 Just for more logical names for sizes of objects. More...
 

Macros

#define foritr(a, b)   for(auto a=b.begin(),end=b.end();a!=end;++a)
 This allows you to iterate over things with iterators without too much pain. More...
 
#define foritrNoInc(a, b)   for(auto a=b.begin(),end=b.end();a!=end;)
 This allows you to iterate over things with iterators but does not actuall increment the iterator allowing the user to iterate instead. More...
 

Typedefs

typedef void(* Behavior )()
 Behaviors use functions that take nothing and return nothing. More...
 
typedef bool(* Condition )()
 A function that determines state of level completion. More...
 

Enumerations

enum  FontType { English =0, Japanese, JapaneseWithRuby }
 The types that our fonts can be. More...
 

Functions

SDL_Surface * LoadImage (std::string filename)
 Loads supported images. More...
 
unsigned int nextPow2 (unsigned int i)
 Rounds a number to the next power of two. More...
 
Point2D getVector (double angle, double speed)
 Gets direction and length for a vector. More...
 
int randInt (int max=RAND_MAX)
 Retrieves a random integer less than the given maximum. More...
 
int randInt (int min, int max)
 Retrieves a random integer great than or equal to the minimum and less than the given maximum. More...
 
float randFloat (float min=0, float max=1)
 Retrieves a random floating-point number between 0 and 1. More...
 
vector< string > splitString (string s, char delim='\n', int rep=0)
 Splits strings on delimiter. More...
 
template<typename NumTy >
string ToString (const NumTy &Num)
 

Variables

const double DEG_IN_RAD = (PI/180.)
 deg/rad More...
 

Macro Definition Documentation

#define foritr (   a,
 
)    for(auto a=b.begin(),end=b.end();a!=end;++a)

This allows you to iterate over things with iterators without too much pain.

Parameters
aThe variable name to contain the iterated object
bThe object to iterate over

Definition at line 47 of file fns.h.

#define foritrNoInc (   a,
 
)    for(auto a=b.begin(),end=b.end();a!=end;)

This allows you to iterate over things with iterators but does not actuall increment the iterator allowing the user to iterate instead.

Parameters
aThe variable name to contain the iterated object
bThe object to iterate over

Definition at line 54 of file fns.h.

Typedef Documentation

typedef void(* Behavior)()

Behaviors use functions that take nothing and return nothing.

Definition at line 32 of file fns.h.

typedef bool(* Condition)()

A function that determines state of level completion.

Definition at line 34 of file fns.h.

Enumeration Type Documentation

enum FontType

The types that our fonts can be.

Enumerator
English 
Japanese 
JapaneseWithRuby 

Definition at line 59 of file fns.h.

Function Documentation

Point2D getVector ( double  angle,
double  speed 
)

Gets direction and length for a vector.

Parameters
anglethe angle in radians
speedthe speed of the object

Definition at line 107 of file fns.cpp.

+ Here is the caller graph for this function:

SDL_Surface* LoadImage ( std::string  filename)

Loads supported images.

< check to see if a filename was provided.

< if not exit the function

Load the image using our new IMG_Load function from sdl-Image1.2

< check to see if it loaded properly

the image loaded fine so we can now convert it to the current display depth

Destroy the old copy

return a pointer to the newly created display compatible image

Definition at line 11 of file fns.cpp.

+ Here is the caller graph for this function:

unsigned int nextPow2 ( unsigned int  i)

Rounds a number to the next power of two.

Definition at line 96 of file fns.cpp.

+ Here is the caller graph for this function:

float randFloat ( float  min = 0,
float  max = 1 
)

Retrieves a random floating-point number between 0 and 1.

Parameters
minthe lower bound
maxthe upper bound
Returns
A random floating-point number between 0 and 1.

Definition at line 124 of file fns.cpp.

+ Here is the caller graph for this function:

int randInt ( int  max = RAND_MAX)

Retrieves a random integer less than the given maximum.

The integer returned will be greater than or equal to 0 and less than the maximum.

    int diceroll = This.Game.RandInt(6)+1;
Parameters
maxThe value that the generated random number must be less than.
Returns
A random integer in the specified range.

Definition at line 114 of file fns.cpp.

+ Here is the caller graph for this function:

int randInt ( int  min,
int  max 
)

Retrieves a random integer great than or equal to the minimum and less than the given maximum.

Parameters
minThe value that the generated random number must be greater than or equal to.
maxThe value that the generated random number must be less than.
Returns
A random integer in the specified range.

Definition at line 119 of file fns.cpp.

vector<string> splitString ( string  s,
char  delim = '\n',
int  rep = 0 
)

Splits strings on delimiter.

Definition at line 130 of file fns.cpp.

template<typename NumTy >
string ToString ( const NumTy &  Num)

Definition at line 197 of file fns.h.

Variable Documentation

const double DEG_IN_RAD = (PI/180.)

deg/rad

Definition at line 40 of file fns.h.