Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
effects.h File Reference

Jo Engine Function prototypes special effects (Laser beam, fire, smoke, flash, shake, etc). More...

Go to the source code of this file.

Data Structures

struct  jo_homing_laser
 Homing laser effect definition. More...
struct  jo_effect_def
 Definition of an effect (shared by the effects of the same kind). More...

Macros

#define JO_EFFECT_MAX
 Effects at the same time (the oldest one is reused).
#define JO_EFFECT_MAX_FRAMES
 Frames of the animation of an effect at most.
#define JO_EFFECT_HALF_TRANSPARENT
 The sprite is mixed with what is behind (VDP1 half transparency: costly, for small sprites only).
#define JO_EFFECT_STANDING
 The sprite stands on its position (else it is centered on it).
#define JO_EFFECT_RANDOM_FLIP
 The sprite is flipped at random (the effects don't look the same).

Functions

void jo_init_homing_laser (jo_homing_laser *const homing_laser, const int sprite_id, const unsigned short thickness, const int z, const unsigned short nb_sections)
 Init jo_homing_laser struct.
void jo_draw_homing_laser (jo_homing_laser *const homing_laser)
 Draw homing laser effect.
void jo_effect_add (const jo_effect_def *const def, const jo_pos3D_fixed *const position, const int delay)
 Add an effect.
void jo_effects_clear (void)
 Remove all the effects, the flash and the shake.
void jo_effects_update (void)
 Animate the effects, the flash and the shake: once per frame of the game.
int jo_effects_draw (void)
 Draw the effects (in the world: the camera matrix is the current matrix, see jo_3d_set_depth_bias()).
void jo_effect_flash (const int r, const int g, const int b, const int frames)
 Flash of the screen: the color offset of the VDP2 is added to all the screens, it fades to 0.
void jo_effect_fade (const int darkness, const int frames)
 Fade of the screen to black (or back): the color offset of the VDP2 (see jo_effect_flash()).
bool jo_effect_is_fading (void)
 Check if the fade is not finished (see jo_effect_fade()).
void jo_effect_shake (const int amount, const int frames)
 Shake of the camera.
void jo_effect_get_shake (jo_pos3D_fixed *const offset)
 Offset of the camera of the shake (add it to the position of the eyes).

Detailed Description

Jo Engine Function prototypes special effects (Laser beam, fire, smoke, flash, shake, etc).

Author
Johannes Fetz
Bug
No known bugs.

Data Structure Documentation

◆ jo_homing_laser

struct jo_homing_laser

Homing laser effect definition.

Data Fields
bool center_sprites_according_to_thickness
jo_fixed horizontal_thickness
jo_vector_fixed intermediate_point_a
jo_vector_fixed intermediate_point_b
jo_fixed length
jo_fixed section_step
jo_vector_fixed source
int sprite_id
jo_vector_fixed target
bool use_intermediate_point_a
bool use_intermediate_point_b
jo_fixed vertical_thickness

◆ jo_effect_def

struct jo_effect_def

Definition of an effect (shared by the effects of the same kind).

Data Fields
unsigned char __pad
short __pad2
unsigned char flags
unsigned char frame_count
unsigned char life
short rise
short size_end
short size_start
short sprites[(4)]

Macro Definition Documentation

◆ JO_EFFECT_HALF_TRANSPARENT

#define JO_EFFECT_HALF_TRANSPARENT

The sprite is mixed with what is behind (VDP1 half transparency: costly, for small sprites only).

◆ JO_EFFECT_MAX

#define JO_EFFECT_MAX

Effects at the same time (the oldest one is reused).

◆ JO_EFFECT_MAX_FRAMES

#define JO_EFFECT_MAX_FRAMES

Frames of the animation of an effect at most.

◆ JO_EFFECT_RANDOM_FLIP

#define JO_EFFECT_RANDOM_FLIP

The sprite is flipped at random (the effects don't look the same).

◆ JO_EFFECT_STANDING

#define JO_EFFECT_STANDING

The sprite stands on its position (else it is centered on it).

Function Documentation

◆ jo_draw_homing_laser()

void jo_draw_homing_laser ( jo_homing_laser *const homing_laser)

Draw homing laser effect.

Parameters
homing_laserHoming laser definition
Remarks
source, intermediate_point_a, intermediate_point_b, target and length must be set before this call

◆ jo_effect_add()

void jo_effect_add ( const jo_effect_def *const def,
const jo_pos3D_fixed *const position,
const int delay )

Add an effect.

Parameters
defDefinition (it must stay in memory)
positionCenter (or foot: JO_EFFECT_STANDING), world space
delayFrames before the effect starts (an explosion is a group of fireballs that start one after the other)

◆ jo_effect_fade()

void jo_effect_fade ( const int darkness,
const int frames )

Fade of the screen to black (or back): the color offset of the VDP2 (see jo_effect_flash()).

Parameters
darkness0 (no fade) to 255 (black)
framesFrames of the game to reach it (see jo_effects_update()), 0: now
Remarks
A change of level: fade to black, load, fade back. jo_effects_clear() doesn't change the fade

◆ jo_effect_flash()

void jo_effect_flash ( const int r,
const int g,
const int b,
const int frames )

Flash of the screen: the color offset of the VDP2 is added to all the screens, it fades to 0.

Parameters
rRed (0 to 255: added to the colors)
gGreen
bBlue
framesFrames of the game until it is gone
Remarks
The registers are written during the VBLANK (no line of the screen with half of the flash). A brighter flash than the current one replaces it

◆ jo_effect_get_shake()

void jo_effect_get_shake ( jo_pos3D_fixed *const offset)

Offset of the camera of the shake (add it to the position of the eyes).

Parameters
offsetOffset (output, world units Q16.16), 0 when nothing shakes

◆ jo_effect_is_fading()

bool jo_effect_is_fading ( void )

Check if the fade is not finished (see jo_effect_fade()).

◆ jo_effect_shake()

void jo_effect_shake ( const int amount,
const int frames )

Shake of the camera.

Parameters
amountAmplitude (world units). A stronger shake than the current one replaces it
framesFrames of the game until it is gone

◆ jo_effects_clear()

void jo_effects_clear ( void )

Remove all the effects, the flash and the shake.

◆ jo_effects_draw()

int jo_effects_draw ( void )

Draw the effects (in the world: the camera matrix is the current matrix, see jo_3d_set_depth_bias()).

Returns
Number of VDP1 commands (sprites) drawn

◆ jo_effects_update()

void jo_effects_update ( void )

Animate the effects, the flash and the shake: once per frame of the game.

◆ jo_init_homing_laser()

void jo_init_homing_laser ( jo_homing_laser *const homing_laser,
const int sprite_id,
const unsigned short thickness,
const int z,
const unsigned short nb_sections )

Init jo_homing_laser struct.

Parameters
homing_laserHoming laser definition
sprite_idSprite ID
thicknessHorizontal Laser thickness (1 to 256)
zDefault z index (500 for example)
nb_sectionsNumber of section in the curve aka smoothness (4 to 64 and must be a multiple of 2).
Remarks
nb_sections=20 Should be enough for most case