The Game Engine  1
fns.cpp File Reference
#include "fns.h"
#include <SDL/SDL_image.h>
#include <math.h>
#include <iostream>
+ Include dependency graph for fns.cpp:

Go to the source code of this file.

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)
 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, float max)
 Retrieves a random floating-point number between 0 and 1. More...
 
vector< string > splitString (string s, char delim, int rep)
 Splits strings on delimiter. More...
 

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,
int  rep 
)

Splits strings on delimiter.

Definition at line 130 of file fns.cpp.