Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
scripts.h File Reference

Header file defining macros, structures, and functions for script management in a game engine. More...

#include <io/input.h>
#include <scripts/signals.h>
Include dependency graph for scripts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  BehaviorAttribute
 Union representing different types of behavior attributes. More...
 
struct  Script
 Structure representing a script with a function and a name. More...
 

Macros

#define NODE_FUNC_PARAMS   struct Node *this, va_list args
 Macro to define the parameters for a node function.
 
#define NODE_FUNC_RETURN   void
 Macro to define the return type for a node function.
 
#define GET_READY_PARAMETERS()   float delta = (float) GET_PARAMETER(double); (void) delta
 Macro to retrieve the delta parameter from the variable argument list.
 
#define GET_SIGNAL()   Signal signal = (Signal) GET_PARAMETER(int); (void) signal
 Macro to retrieve the signal parameter from the variable argument list.
 
#define GET_PARAMETER(type)   va_arg(args, type)
 Macro to retrieve a parameter of a specified type from the variable argument list.
 
#define GET_AREA_SIGNAL_PARAMETERS()   ;int sigId = GET_PARAMETER(int); Node *other = (Node *) GET_PARAMETER(Node *); float distance = (float) GET_PARAMETER(double); float *impactPoint = (float *) GET_PARAMETER(float *); int offset = GET_PARAMETER(int); (void) sigId; (void) other; (void) distance; (void) impactPoint; (void) offset;
 Macro to retrieve parameters for an area signal from the variable argument list.
 
#define MALLOC_ATTRIBUTE(node, x)
 Macro to allocate memory for node attributes if not already allocated.
 
#define SET_ATTRIBUTES_COUNT(x)   MALLOC_ATTRIBUTE(this, x)
 Macro to set the number of attributes for the current node.
 
#define NEW_SCRIPT(script_name)   NODE_FUNC_RETURN script_name(NODE_FUNC_PARAMS) {
 Macro to define a new script function.
 
#define END_SCRIPT(script_name)
 Macro to end a script function and register it in the game engine.
 

Typedefs

typedef NODE_FUNC_RETURN(* ScriptFunc) (NODE_FUNC_PARAMS)
 Function pointer type for script functions.
 
typedef ScriptFunc Behavior[BEHAVIOR_SCRIPT_COUNT]
 Array of script functions for different behavior scripts.
 

Enumerations

enum  BehaviorScripts { BEHAVIOR_SCRIPT_READY , BEHAVIOR_SCRIPT_UPDATE , BEHAVIOR_SCRIPT_SIGNAL , BEHAVIOR_SCRIPT_COUNT }
 Enumeration of different behavior script types. More...
 

Variables

int __scriptIndex__
 Global index for tracking the number of registered scripts.
 

Detailed Description

Header file defining macros, structures, and functions for script management in a game engine.

This file contains macros for handling script parameters, memory allocation for node attributes, and script registration. It also defines structures and types for behavior attributes, scripts, and behavior scripts enumeration.

Macro Definition Documentation

◆ NODE_FUNC_PARAMS

#define NODE_FUNC_PARAMS   struct Node *this, va_list args

Macro to define the parameters for a node function.

◆ NODE_FUNC_RETURN

#define NODE_FUNC_RETURN   void

Macro to define the return type for a node function.

◆ GET_READY_PARAMETERS

#define GET_READY_PARAMETERS ( )    float delta = (float) GET_PARAMETER(double); (void) delta

Macro to retrieve the delta parameter from the variable argument list.

◆ GET_SIGNAL

#define GET_SIGNAL ( )    Signal signal = (Signal) GET_PARAMETER(int); (void) signal

Macro to retrieve the signal parameter from the variable argument list.

◆ GET_PARAMETER

#define GET_PARAMETER (   type)    va_arg(args, type)

Macro to retrieve a parameter of a specified type from the variable argument list.

Parameters
typeThe type of the parameter to retrieve.

◆ GET_AREA_SIGNAL_PARAMETERS

#define GET_AREA_SIGNAL_PARAMETERS ( )    ;int sigId = GET_PARAMETER(int); Node *other = (Node *) GET_PARAMETER(Node *); float distance = (float) GET_PARAMETER(double); float *impactPoint = (float *) GET_PARAMETER(float *); int offset = GET_PARAMETER(int); (void) sigId; (void) other; (void) distance; (void) impactPoint; (void) offset;

Macro to retrieve parameters for an area signal from the variable argument list.

◆ MALLOC_ATTRIBUTE

#define MALLOC_ATTRIBUTE (   node,
 
)
Value:
if (!node->attribute) { \
node->attribute = malloc(sizeof(BehaviorAttribute) * x); \
POINTER_CHECK(node->attribute); \
node->attributes_count = x; \
for (int i = 0; i < x; i++) memset(&node->attribute[i], 0, sizeof(union BehaviorAttribute)); \
}
Union representing different types of behavior attributes.
Definition scripts.h:87

Macro to allocate memory for node attributes if not already allocated.

Parameters
nodeThe node for which to allocate attributes.
xThe number of attributes to allocate.

◆ SET_ATTRIBUTES_COUNT

#define SET_ATTRIBUTES_COUNT (   x)    MALLOC_ATTRIBUTE(this, x)

Macro to set the number of attributes for the current node.

Parameters
xThe number of attributes to set.

◆ NEW_SCRIPT

#define NEW_SCRIPT (   script_name)    NODE_FUNC_RETURN script_name(NODE_FUNC_PARAMS) {

Macro to define a new script function.

Parameters
script_nameThe name of the script function.

◆ END_SCRIPT

#define END_SCRIPT (   script_name)
Value:
}; \
static __attribute__((constructor)) void __anon_ctor_##script_name(void) {\
Game.scripts = realloc(Game.scripts, sizeof(Script) * (__scriptIndex__ + 1));\
Game.scripts[__scriptIndex__].name = #script_name;\
Game.scripts[__scriptIndex__++].script = script_name;\
}
struct RaptiquaX_t Game
Definition raptiquax.c:61
int __scriptIndex__
Global index for tracking the number of registered scripts.
Definition scripts.c:1
struct Script * scripts
Definition raptiquax.h:39
Structure representing a script with a function and a name.
Definition scripts.h:105
char * name
Definition scripts.h:107
ScriptFunc script
Definition scripts.h:106

Macro to end a script function and register it in the game engine.

Parameters
script_nameThe name of the script function.

Typedef Documentation

◆ ScriptFunc

ScriptFunc

Function pointer type for script functions.

◆ Behavior

Behavior

Array of script functions for different behavior scripts.

Enumeration Type Documentation

◆ BehaviorScripts

Enumeration of different behavior script types.

Enumerator
BEHAVIOR_SCRIPT_READY 

Ready script

BEHAVIOR_SCRIPT_UPDATE 

Update script

BEHAVIOR_SCRIPT_SIGNAL 

Signal script

BEHAVIOR_SCRIPT_COUNT 

Total count of behavior scripts

Variable Documentation

◆ __scriptIndex__

int __scriptIndex__
extern

Global index for tracking the number of registered scripts.