SANDAL2
A SDL2 Wrapper in C
Classes | Typedefs | Functions
Action.h File Reference

Contains all structures related to actions on element. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Action
 
struct  ListAction
 
struct  ActionNode
 

Typedefs

typedef struct Action Action
 
typedef struct ListAction ListAction
 
typedef struct ActionNode ActionNode
 

Functions

ListActioninitAction (void(*action)(struct Element *, void *, double), double timing)
 Create an action based on its behavior and the time it should take. More...
 
ListActionsetDataAction (ListAction *action, void *data, int shouldBeFreed)
 Set the data bound to an action, if the action list contains more than one action, this call will fail. More...
 
void freeListAction (ListAction *action)
 Free the memory of a list action. More...
 
int executeListAction (ListAction *action, struct Element *e, double time)
 Execute a list action. More...
 
ListActiongenerateChainedAction (ListAction *action,...)
 Generate a list of chained action (the nth action execute after the (n - 1)th ended) More...
 
ListActiongenerateParallelAction (ListAction *action,...)
 Generate a list of parallel action. More...
 
ListActionsetForeverAction (ListAction *action, int isForever)
 Tells that the action should run forever or not (by default, an action does not run forever) More...
 
long long addActionAtEndAction (ListAction *action, ListAction *toAdd)
 add an action at the end of another one More...
 
int delActionToAction (ListAction *action, long long index)
 remove an action inside another More...
 
void moveByActionFunction (struct Element *e, void *data, double spentTime)
 function used by moveByAction() and left public to be used in self made action functions More...
 
void moveToActionFunction (struct Element *e, void *data, double spentTime)
 function used by moveToAction() and left public to be used in self made action functions More...
 
void scaleByActionFunction (struct Element *e, void *data, double spentTime)
 function used by scaleByAction() and left public to be used in self made action functions More...
 
void scaleToActionFunction (struct Element *e, void *data, double spentTime)
 function used by scaleToAction() and left public to be used in self made action functions More...
 
void rotateByActionFunction (struct Element *e, void *data, double spentTime)
 function used by rotateByAction() and left public to be used in self made action functions More...
 
void rotateToActionFunction (struct Element *e, void *data, double spentTime)
 function used by rotateToAction() and left public to be used in self made action functions More...
 
void fadeInActionFunction (struct Element *e, void *data, double spentTime)
 function used by fadeInAction() and left public to be used in self made action functions More...
 
void fadeOutActionFunction (struct Element *e, void *data, double spentTime)
 function used by fadeOutAction() and left public to be used in self made action functions More...
 
ListActionmoveByAction (double x, double y, double time)
 Generate a ListAction doing a translation during a given time. More...
 
ListActionmoveToAction (double x, double y, double time)
 Generate a ListAction doing a translation during a given time. More...
 
ListActionscaleByAction (double x, double y, double time)
 Generate a ListAction doing a scale XY (only X if y == 0, only Y if x == 0) during a given time. More...
 
ListActionscaleToAction (double w, double h, double time)
 Generate a ListAction doing a scale XY (only X if y == 0, only Y if x == 0) during a given time. More...
 
ListActionrotateByAction (double angle, double time)
 Generate a ListAction doing a rotation during a given time. More...
 
ListActionrotateToAction (double angle, double time)
 Generate a ListAction doing a rotation during a given time. More...
 
ListActionfadeInAction (int alpha, double time)
 Generate a ListAction doing a fade in during a given time. More...
 
ListActionfadeOutAction (int alpha, double time)
 Generate a ListAction doing a fade out during a given time. More...
 

Detailed Description

Contains all structures related to actions on element.

Author
Baptiste PRUNIER (KLEVH)

Function Documentation

◆ addActionAtEndAction()

long long addActionAtEndAction ( ListAction action,
ListAction toAdd 
)

add an action at the end of another one

Parameters
action: action to add another one to
toAdd: action to be added, it will be freed if the add succeeded
Returns
the index of the action added in the action list if it was added, -1 if it could not

◆ delActionToAction()

int delActionToAction ( ListAction action,
long long  index 
)

remove an action inside another

Parameters
action: action to be modified
index: index of the action to be removed
Returns
1 if it failed, 0 if not

◆ executeListAction()

int executeListAction ( ListAction action,
struct Element e,
double  time 
)

Execute a list action.

Parameters
action: list to be executed
e: element to call actions on
time: time elapsed since last call of this function
Returns
1 if the action list is finished, 0 if not

◆ fadeInAction()

ListAction* fadeInAction ( int  alpha,
double  time 
)

Generate a ListAction doing a fade in during a given time.

Parameters
alpha: value to reduce the element's alpha of
time: duration of the action
Returns
the list action generated

◆ fadeInActionFunction()

void fadeInActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by fadeInAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 2 casted to void*. It MUST have the following format: [the delta to decrement alpha with, -1] the last value MUST be set to -1 before the first call, it will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ fadeOutAction()

ListAction* fadeOutAction ( int  alpha,
double  time 
)

Generate a ListAction doing a fade out during a given time.

Parameters
alpha: value to increase the element's alpha of
time: duration of the action
Returns
the list action generated

◆ fadeOutActionFunction()

void fadeOutActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by fadeOutAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 2 casted to void*. It MUST have the following format: [the delta to increment alpha with, -1] the last value MUST be set to -1 before the first call, it will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ freeListAction()

void freeListAction ( ListAction action)

Free the memory of a list action.

Parameters
action: list to be freed

◆ generateChainedAction()

ListAction* generateChainedAction ( ListAction action,
  ... 
)

Generate a list of chained action (the nth action execute after the (n - 1)th ended)

Parameters
action...: all list action of the list, needs to end by NULL
Returns
the first action passed as parameter of action... after setting its chained actions

◆ generateParallelAction()

ListAction* generateParallelAction ( ListAction action,
  ... 
)

Generate a list of parallel action.

Parameters
action...: all list action of the list, needs to end by NULL
Returns
the first action passed as parameter of action... after setting its parallel actions

◆ initAction()

ListAction* initAction ( void(*)(struct Element *, void *, double)  action,
double  timing 
)

Create an action based on its behavior and the time it should take.

Parameters
action: behavior of the action, takes 3 parameters : the element on which it will be applied, the data of the action and the total time elapsed since its beginning (in percent from 0 to 1)
timing: duration of the action, it needs to be greater than 0
Returns
the created action (NULL on failure)

◆ moveByAction()

ListAction* moveByAction ( double  x,
double  y,
double  time 
)

Generate a ListAction doing a translation during a given time.

Parameters
x: x offset
y: y offset
time: duration of the action
Returns
the list action generated

◆ moveByActionFunction()

void moveByActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by moveByAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 7 casted to void*. It MUST have the following format: [the x delta, the y delta, 0, 0, 0, 0, 0] the last values MUST be set to 0 before the first call, they will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ moveToAction()

ListAction* moveToAction ( double  x,
double  y,
double  time 
)

Generate a ListAction doing a translation during a given time.

Parameters
x: new x value
y: new y value
time: duration of the action
Returns
the list action generated

◆ moveToActionFunction()

void moveToActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by moveToAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 4 casted to void*. It MUST have the following format: [the x new value, the y new value, 0, 0] the last two values MUST be set to 0 before the first call, they will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ rotateByAction()

ListAction* rotateByAction ( double  angle,
double  time 
)

Generate a ListAction doing a rotation during a given time.

Parameters
angle: angle offset
time: duration of the action
Returns
the list action generated

◆ rotateByActionFunction()

void rotateByActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by rotateByAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 2 casted to void*. It MUST have the following format: [the angle delta, 0, 0, 0] the last values MUST be set to 0 before the first call, it will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ rotateToAction()

ListAction* rotateToAction ( double  angle,
double  time 
)

Generate a ListAction doing a rotation during a given time.

Parameters
angle: new angle
time: duration of the action
Returns
the list action generated

◆ rotateToActionFunction()

void rotateToActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by rotateToAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 2 casted to void*. It MUST have the following format: [the new angle, 0] the last value MUST be set to 0 before the first call, it will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ scaleByAction()

ListAction* scaleByAction ( double  x,
double  y,
double  time 
)

Generate a ListAction doing a scale XY (only X if y == 0, only Y if x == 0) during a given time.

Parameters
x: scale value of x (percentage of modification with 1.0 == +100%)
y: scale value of y (percentage of modification with 1.0 == +100%)
time: duration of the action
Returns
the list action generated

◆ scaleByActionFunction()

void scaleByActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by scaleByAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 4 casted to void*. It MUST have the following format: [the x scale value, the y scale value, 0, 0] the last two values MUST be set to 0 before the first call, they will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ scaleToAction()

ListAction* scaleToAction ( double  w,
double  h,
double  time 
)

Generate a ListAction doing a scale XY (only X if y == 0, only Y if x == 0) during a given time.

Parameters
w: new value of width
h: new value of height
time: duration of the action
Returns
the list action generated

◆ scaleToActionFunction()

void scaleToActionFunction ( struct Element e,
void *  data,
double  spentTime 
)

function used by scaleToAction() and left public to be used in self made action functions

Parameters
e: element on which the action is called
data: a double* array of size 4 casted to void*. It MUST have the following format: [the x scale value, the y scale value, 0, 0] the last two values MUST be set to 0 before the first call, they will be modified inside the function those modifications NEEDS to be saved for the following calls
spentTime: total spent time since the beginning of the action (in percent from 0 to 1)

◆ setDataAction()

ListAction* setDataAction ( ListAction action,
void *  data,
int  shouldBeFreed 
)

Set the data bound to an action, if the action list contains more than one action, this call will fail.

Parameters
action: action to bind data to
data: data to be bound to the action
shouldBeFreed: flag to tell whether or not the data should be freed
Returns
the action passed as first parameter

◆ setForeverAction()

ListAction* setForeverAction ( ListAction action,
int  isForever 
)

Tells that the action should run forever or not (by default, an action does not run forever)

Parameters
action: action to be modified
isForever: flag to set to the action
Returns
the action parameter