Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Animation Class Reference

Class in control of animating a sprite. More...

#include <Animation.h>

Public Member Functions

 Animation (const int x_, const int y_, const int spriteWidth_, const int spriteHeight_, const int numberOfImages_, const bool loop_)
 The constructor. More...
 
 ~Animation ()
 The destructor.
 
void update (SDL_Rect &clip_, const double dt_)
 Updates the animation clip. More...
 
void changeAnimation (const int x_, const int y_, const int numberOfImages_, const bool loop_, const double totalTime_)
 Changes the animation to another. More...
 

Private Member Functions

void updateClip (SDL_Rect &clip_, const int x_, const int y_)
 Updates the clip to a new position. More...
 

Private Attributes

int x
 The position on x axis on the sprite. More...
 
int y
 The position on x axis on the sprite. More...
 
int initialX
 Where to start/restart the animation on x. More...
 
int initialY
 Where to start/restart the animation on y. More...
 
int spriteWidth
 The sprite width. More...
 
int spriteHeight
 The sprite height. More...
 
int numberOfImages
 The number of images to animate inside the spritesheet. More...
 
bool loop
 Whether to loop or not. More...
 
double totalElapsedTime
 
                      Total time elapsed on the animation, to check if the

frame changed. More...

 
double totalTime
 Total time for each animation loop. More...
 

Static Private Attributes

static int animationCount = 0
 

Detailed Description

Class in control of animating a sprite.

Constructor & Destructor Documentation

Animation::Animation ( const int  x_,
const int  y_,
const int  spriteWidth_,
const int  spriteHeight_,
const int  numberOfImages_,
const bool  loop_ 
)

The constructor.

Initializes all attributes.

Parameters
x_: The x position on the spritesheet.
y_: The y position on the spritesheet.
spriteWidth_: The width of the sprite to animate.
spriteHeight_: The height of the sprite to animate.
numberOfImages_: The number of images to animate inside the spritesheet.
loop_: Whether to loop or not.

Member Function Documentation

void Animation::changeAnimation ( const int  x_,
const int  y_,
const int  numberOfImages_,
const bool  loop_,
const double  totalTime_ 
)

Changes the animation to another.

Note
See Animation::Animation for the parameters descriptions.
void Animation::update ( SDL_Rect &  clip_,
const double  dt_ 
)

Updates the animation clip.

Parameters
clip_: Reference to the clip of whatever object the animation is a part of.
dt_: Delta time. Time elapsed between one frame and the other, independent of processing speed.
totalTime_: How much time each frame should have. Affects the speed on which the animation changes.
void Animation::updateClip ( SDL_Rect &  clip_,
const int  x_,
const int  y_ 
)
private

Updates the clip to a new position.

Parameters
clip_: The clip to update.
x_: New x position.
y_: New y position.

Member Data Documentation

int Animation::initialX
private

Where to start/restart the animation on x.

int Animation::initialY
private

Where to start/restart the animation on y.

bool Animation::loop
private

Whether to loop or not.

int Animation::numberOfImages
private

The number of images to animate inside the spritesheet.

int Animation::spriteHeight
private

The sprite height.

int Animation::spriteWidth
private

The sprite width.

double Animation::totalElapsedTime
private

                      Total time elapsed on the animation, to check if the

frame changed.

double Animation::totalTime
private

Total time for each animation loop.

int Animation::x
private

The position on x axis on the sprite.

int Animation::y
private

The position on x axis on the sprite.


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