Alchemy
Loading...
Searching...
No Matches

effect_vertical.h

Go to the documentation of this file.
1#include "types.h"
2#include "field_obj.h"
3#include "field_effect.h"
4#include "field_scene.h"
5#include "fixed_math.h"
6
7// Vale and its home, storm and Babi scenes, Sol Sanctum's eruption, the world
8// map and Venus Lighthouse's aerie: the pair of rising particles that
9// WorldMap_CreateLinkedEffects attaches to a glowing actor, each an update
10// hook that lives 32 frames.
11
12/// Rises beside the linked actor, expanding and shrinking over half a sine
13/// wave.
14static void Effect_AnimateVerticalPositive(union FieldObject *object) {
15 struct FieldActor *self = &object->actor;
16 struct FieldActor *anchor;
17 s32 frame;
18 s32 amplitude;
19
20 anchor = self->linkedObject;
21 self->timer = (self->timer + 1);
22 frame = self->timer;
23
24 if (frame > 31) {
26 return;
27 }
28
29 amplitude = Engine_MathSin(frame << 10);
30 self->scaleX = amplitude;
31 self->scaleY = amplitude;
32 self->x.fixed = anchor->x.fixed;
33 self->y.fixed += PIXELS(1);
34 self->z.fixed = anchor->z.fixed + (Q16_ONE - amplitude) * 5 + PIXELS(8);
35}
36
37/// Mirrors the rising particle vertically and passes behind the linked actor.
38static void Effect_AnimateVerticalNegative(union FieldObject *object) {
39 struct FieldActor *self = &object->actor;
40 struct FieldActor *anchor;
41 s32 frame;
42 s32 amplitude;
43
44 anchor = self->linkedObject;
45 self->timer = (self->timer + 1);
46 frame = self->timer;
47
48 if (frame > 31) {
50 return;
51 }
52
53 amplitude = Engine_MathSin(frame << 10);
54 self->scaleX = amplitude;
55 self->scaleY = -amplitude;
56 self->x.fixed = anchor->x.fixed;
57 self->y.fixed += PIXELS(1);
58 self->z.fixed = anchor->z.fixed - (Q16_ONE - amplitude) * 5 + PIXELS(16);
59}
static void Effect_AnimateVerticalPositive(union FieldObject *object)
Rises beside the linked actor, expanding and shrinking over half a sine wave.
static void Effect_AnimateVerticalNegative(union FieldObject *object)
Mirrors the rising particle vertically and passes behind the linked actor.
Field effects, their scripts and the flags that spawn them.
s32 Engine_MathSin(s32 angle)
void Engine_ObjectDispatchRelease(struct FieldActor *object)
Field objects and actors, and the scene transition styles.
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define PIXELS(value)
16.16 fixed-point constants, sine and cosine, and the library division.
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
Definition fixed_math.h:10
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s16 timer
The parameter its action script reads (a follow distance or an angle to face), the player's frames to...
Definition field_obj.h:109
struct FieldActor * linkedObject
The object its action script follows or faces.
Definition field_obj.h:114
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition field_obj.h:39
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition field_obj.h:40
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.