Don't redefine standard complex macro; use a new cmplx typedef

This also introduces `float32`, `float64`, and `real` typedefs to be
used in place of `float` and `double` later. `real` is for game code and
other places where we don't particularly care about the precision and
format of the underlying type, and is currently defined to `double`.
`float32` and `float64` should replace `float` and `double` respectively
This commit is contained in:
Andrei Alexeyev 2019-11-22 05:37:11 +02:00
parent 78191b3015
commit 80b1026d08
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
68 changed files with 520 additions and 494 deletions

View file

@ -31,7 +31,7 @@ typedef struct SpellBonus {
static void calc_spell_bonus(Attack *a, SpellBonus *bonus);
Boss* create_boss(char *name, char *ani, complex pos) {
Boss* create_boss(char *name, char *ani, cmplx pos) {
Boss *boss = calloc(1, sizeof(Boss));
boss->name = strdup(name);
@ -401,7 +401,7 @@ static void draw_spell_warning(Font *font, float y_pos, float f, float opacity)
float flash = 0.2 + 0.8 * pow(psin(M_PI + 5 * M_PI * f), 0.5);
f = 0.15 * f + 0.85 * (0.5 * pow(2 * f - 1, 3) + 0.5);
opacity *= 1 - 2 * fabs(f - 0.5);
complex pos = (VIEWPORT_W + msg_width) * f - msg_width * 0.5 + I * y_pos;
cmplx pos = (VIEWPORT_W + msg_width) * f - msg_width * 0.5 + I * y_pos;
draw_boss_text(ALIGN_CENTER, creal(pos), cimag(pos), msg, font, color_mul_scalar(RGBA(1, flash, flash, 1), opacity));
}
@ -409,12 +409,12 @@ static void draw_spell_warning(Font *font, float y_pos, float f, float opacity)
static void draw_spell_name(Boss *b, int time, bool healthbar_radial) {
Font *font = get_font("standard");
complex x0 = VIEWPORT_W/2+I*VIEWPORT_H/3.5;
cmplx x0 = VIEWPORT_W/2+I*VIEWPORT_H/3.5;
float f = clamp((time - 40.0) / 60.0, 0, 1);
float f2 = clamp(time / 80.0, 0, 1);
float y_offset = 26 + healthbar_radial * -15;
float y_text_offset = 5 - font_get_metrics(font)->descent;
complex x = x0 + ((VIEWPORT_W - 10) + I*(y_offset + y_text_offset) - x0) * f*(f+1)*0.5;
cmplx x = x0 + ((VIEWPORT_W - 10) + I*(y_offset + y_text_offset) - x0) * f*(f+1)*0.5;
int strw = text_width(font, b->current->name, 0);
float opacity_noplr = b->hud.spell_opacity * b->hud.global_opacity;
@ -810,8 +810,8 @@ static void boss_rule_extra(Boss *boss, float alpha) {
for(int i = 0; i < cnt; ++i) {
float a = i*2*M_PI/cnt + global.frames / 100.0;
complex dir = cexp(I*(a+global.frames/50.0));
complex vel = dir * 3;
cmplx dir = cexp(I*(a+global.frames/50.0));
cmplx vel = dir * 3;
float v = max(0, alpha - 1);
float psina = psin(a);

View file

@ -76,7 +76,7 @@ typedef struct AttackInfo {
BossRule rule;
BossRule draw_rule;
complex pos_dest;
cmplx pos_dest;
int bonus_rank;
} AttackInfo;
@ -105,7 +105,7 @@ typedef struct Attack {
typedef struct Boss {
ENTITY_INTERFACE_NAMED(struct Boss, ent);
complex pos;
cmplx pos;
Attack *attacks;
Attack *current;
@ -149,7 +149,7 @@ typedef struct Boss {
} hud;
} Boss;
Boss* create_boss(char *name, char *ani, complex pos) attr_nonnull(1, 2) attr_returns_nonnull;
Boss* create_boss(char *name, char *ani, cmplx pos) attr_nonnull(1, 2) attr_returns_nonnull;
void free_boss(Boss *boss) attr_nonnull(1);
void process_boss(Boss **boss) attr_nonnull(1);

View file

@ -8,7 +8,6 @@
#include "taisei.h"
#include <stdio.h>
#include "color.h"
#define COLOR_OP(c1, op, c2) do { \

View file

@ -57,8 +57,8 @@ static void fix_pos0_visual(Enemy *e) {
e->pos0_visual = x + y * I;
}
Enemy *create_enemy_p(EnemyList *enemies, complex pos, float hp, EnemyVisualRule visual_rule, EnemyLogicRule logic_rule,
complex a1, complex a2, complex a3, complex a4) {
Enemy *create_enemy_p(EnemyList *enemies, cmplx pos, float hp, EnemyVisualRule visual_rule, EnemyLogicRule logic_rule,
cmplx a1, cmplx a2, cmplx a3, cmplx a4) {
if(IN_DRAW_CODE) {
log_fatal("Tried to spawn an enemy while in drawing code");
}
@ -142,21 +142,21 @@ void delete_enemies(EnemyList *enemies) {
alist_foreach(enemies, _delete_enemy, NULL);
}
static complex enemy_visual_pos(Enemy *enemy) {
static cmplx enemy_visual_pos(Enemy *enemy) {
double t = (global.frames - enemy->birthtime) / 30.0;
if(t >= 1 || enemy->hp == ENEMY_IMMUNE) {
return enemy->pos;
}
complex p = enemy->pos - enemy->pos0;
cmplx p = enemy->pos - enemy->pos0;
p += t * enemy->pos0 + (1 - t) * enemy->pos0_visual;
return p;
}
static void call_visual_rule(Enemy *e, bool render) {
complex tmp = e->pos;
cmplx tmp = e->pos;
e->pos = enemy_visual_pos(e);
e->visual_rule(e, global.frames - e->birthtime, render);
e->pos = tmp;
@ -216,7 +216,7 @@ int enemy_flare(Projectile *p, int t) { // a[0] velocity, a[1] ref to enemy
void BigFairy(Enemy *e, int t, bool render) {
if(!render) {
if(!(t % 5)) {
complex offset = (frand()-0.5)*30 + (frand()-0.5)*20.0*I;
cmplx offset = (frand()-0.5)*30 + (frand()-0.5)*20.0*I;
PARTICLE(
.sprite = "smoothdot",

View file

@ -36,9 +36,9 @@ enum {
struct Enemy {
ENTITY_INTERFACE_NAMED(Enemy, ent);
complex pos;
complex pos0;
complex pos0_visual;
cmplx pos;
cmplx pos0;
cmplx pos0_visual;
long birthtime;
@ -51,7 +51,7 @@ struct Enemy {
float spawn_hp;
float hp;
complex args[RULE_ARGC];
cmplx args[RULE_ARGC];
float alpha;
#ifdef ENEMY_DEBUG
@ -65,8 +65,8 @@ struct Enemy {
#define create_enemy1c(p,h,d,l,a1) create_enemy_p(&global.enemies,p,h,d,l,a1,0,0,0)
Enemy *create_enemy_p(
EnemyList *enemies, complex pos, float hp, EnemyVisualRule draw_rule, EnemyLogicRule logic_rule,
complex a1, complex a2, complex a3, complex a4
EnemyList *enemies, cmplx pos, float hp, EnemyVisualRule draw_rule, EnemyLogicRule logic_rule,
cmplx a1, cmplx a2, cmplx a3, cmplx a4
);
#ifdef ENEMY_DEBUG

View file

@ -185,7 +185,7 @@ DamageResult ent_damage(EntityInterface *ent, const DamageInfo *damage) {
return res;
}
void ent_area_damage(complex origin, float radius, const DamageInfo *damage, EntityAreaDamageCallback callback, void *callback_arg) {
void ent_area_damage(cmplx origin, float radius, const DamageInfo *damage, EntityAreaDamageCallback callback, void *callback_arg) {
for(Enemy *e = global.enemies.first; e; e = e->next) {
if(
cabs(origin - e->pos) < radius &&

View file

@ -82,7 +82,7 @@ typedef void (*EntityDrawFunc)(EntityInterface *ent);
typedef bool (*EntityPredicate)(EntityInterface *ent);
typedef DamageResult (*EntityDamageFunc)(EntityInterface *target, const DamageInfo *damage);
typedef void (*EntityDrawHookCallback)(EntityInterface *ent, void *arg);
typedef void (*EntityAreaDamageCallback)(EntityInterface *ent, complex ent_origin, void *arg);
typedef void (*EntityAreaDamageCallback)(EntityInterface *ent, cmplx ent_origin, void *arg);
#define ENTITY_INTERFACE_BASE(typename) struct { \
LIST_INTERFACE(typename); \
@ -144,7 +144,7 @@ void ent_register(EntityInterface *ent, EntityType type) attr_nonnull(1);
void ent_unregister(EntityInterface *ent) attr_nonnull(1);
void ent_draw(EntityPredicate predicate);
DamageResult ent_damage(EntityInterface *ent, const DamageInfo *damage) attr_nonnull(1, 2);
void ent_area_damage(complex origin, float radius, const DamageInfo *damage, EntityAreaDamageCallback callback, void *callback_arg) attr_nonnull(3);
void ent_area_damage(cmplx origin, float radius, const DamageInfo *damage, EntityAreaDamageCallback callback, void *callback_arg) attr_nonnull(3);
void ent_area_damage_ellipse(Ellipse ellipse, const DamageInfo *damage, EntityAreaDamageCallback callback, void *callback_arg) attr_nonnull(2);
void ent_hook_pre_draw(EntityDrawHookCallback callback, void *arg);

View file

@ -11,6 +11,7 @@
#include "eventloop_private.h"
#include "events.h"
#include "global.h"
#include <emscripten.h>
static FrameTimes frame_times;

View file

@ -20,7 +20,7 @@ void fpscounter_reset(FPSCounter *fps) {
fps->frametimes[i] = frametime;
}
fps->fps = HRTIME_RESOLUTION / (long double)frametime;
fps->fps = HRTIME_RESOLUTION / (float64x)frametime;
fps->frametime = frametime;
fps->last_update_time = time_get();
}
@ -38,7 +38,7 @@ void fpscounter_update(FPSCounter *fps) {
avg += fps->frametimes[i];
}
fps->fps = HRTIME_RESOLUTION / (avg / (long double)log_size);
fps->fps = HRTIME_RESOLUTION / (avg / (float64x)log_size);
fps->frametime = avg / log_size;
fps->last_update_time = time_get();
}

View file

@ -12,6 +12,7 @@
#include "taisei.h"
#include <SDL.h>
#include "events.h"
#include "config.h"

View file

@ -46,7 +46,7 @@ static const char* item_indicator_sprite_name(ItemType type) {
[ITEM_SURGE - ITEM_FIRST] = NULL,
[ITEM_VOLTAGE - ITEM_FIRST] = "item/voltage_indicator",
};
uint index = type - 1;
assert(index < ARRAY_SIZE(map));
@ -69,7 +69,7 @@ static void ent_draw_item(EntityInterface *ent) {
Item *i = ENT_CAST(ent, Item);
const int indicator_display_y = 6;
float y = cimag(i->pos);
if(y < 0) {
Sprite *s = item_indicator_sprite(i->type);
@ -85,12 +85,12 @@ static void ent_draw_item(EntityInterface *ent) {
}
}
float alpha = 1;
if(i->type == ITEM_PIV && !i->auto_collect) {
alpha *= clamp(2.0 - (global.frames - i->birthtime) / 60.0, 0.1, 1.0);
}
Color *c = RGBA_MUL_ALPHA(1, 1, 1, alpha);
r_draw_sprite(&(SpriteParams) {
@ -101,7 +101,7 @@ static void ent_draw_item(EntityInterface *ent) {
}
Item* create_item(complex pos, complex v, ItemType type) {
Item* create_item(cmplx pos, cmplx v, ItemType type) {
if((creal(pos) < 0 || creal(pos) > VIEWPORT_W)) {
// we need this because we clamp the item position to the viewport boundary during motion
// e.g. enemies that die offscreen shouldn't spawn any items inside the viewport
@ -135,7 +135,7 @@ void delete_item(Item *item) {
objpool_release(stage_object_pools.items, alist_unlink(&global.items, item));
}
Item *create_clear_item(complex pos, uint clear_flags) {
Item *create_clear_item(cmplx pos, uint clear_flags) {
ItemType type = ITEM_PIV;
if(clear_flags & CLEAR_HAZARDS_SPAWN_VOLTAGE) {
@ -166,23 +166,23 @@ void delete_items(void) {
}
}
static complex move_item(Item *i) {
static cmplx move_item(Item *i) {
int t = global.frames - i->birthtime;
complex lim = 0 + 2.0*I;
cmplx lim = 0 + 2.0*I;
complex oldpos = i->pos;
cmplx oldpos = i->pos;
if(i->auto_collect && i->collecttime <= global.frames && global.frames - i->birthtime > 20) {
i->pos -= (7+i->auto_collect)*cexp(I*carg(i->pos - global.plr.pos));
} else {
i->pos = i->pos0 + log(t/5.0 + 1)*5*(i->v + lim) + lim*t;
complex v = i->pos - oldpos;
cmplx v = i->pos - oldpos;
double half = item_sprite(i->type)->w/2.0;
bool over = false;
if((over = creal(i->pos) > VIEWPORT_W-half) || creal(i->pos) < half) {
complex normal = over ? -1 : 1;
cmplx normal = over ? -1 : 1;
v -= 2 * normal * (creal(normal)*creal(v));
v = 1.5*creal(v) - I*fabs(cimag(v));
@ -280,7 +280,7 @@ void process_items(void) {
}
}
complex deltapos = move_item(item);
cmplx deltapos = move_item(item);
int v = may_collect ? collision_item(item) : 0;
if(v == 1) {
@ -346,7 +346,7 @@ int collision_item(Item *i) {
return 0;
}
static void spawn_item_internal(complex pos, ItemType type, float collect_value) {
static void spawn_item_internal(cmplx pos, ItemType type, float collect_value) {
tsrand_fill(2);
Item *i = create_item(pos, (12 + 6 * afrand(0)) * (cexp(I*(3*M_PI/2 + anfrand(1)*M_PI/11))) - 3*I, type);
@ -355,15 +355,15 @@ static void spawn_item_internal(complex pos, ItemType type, float collect_value)
}
}
void spawn_item(complex pos, ItemType type) {
void spawn_item(cmplx pos, ItemType type) {
spawn_item_internal(pos, type, -1);
}
void spawn_and_collect_item(complex pos, ItemType type, float collect_value) {
void spawn_and_collect_item(cmplx pos, ItemType type, float collect_value) {
spawn_item_internal(pos, type, collect_value);
}
static void spawn_items_internal(complex pos, float collect_value, SpawnItemsArgs groups[]) {
static void spawn_items_internal(cmplx pos, float collect_value, SpawnItemsArgs groups[]) {
for(SpawnItemsArgs *g = groups; g->type > 0; ++g) {
for(uint i = 0; i < g->count; ++i) {
spawn_item_internal(pos, g->type, collect_value);
@ -372,12 +372,12 @@ static void spawn_items_internal(complex pos, float collect_value, SpawnItemsArg
}
#undef spawn_items
void spawn_items(complex pos, SpawnItemsArgs groups[]) {
void spawn_items(cmplx pos, SpawnItemsArgs groups[]) {
spawn_items_internal(pos, -1, groups);
}
#undef spawn_and_collect_items
void spawn_and_collect_items(complex pos, float collect_value, SpawnItemsArgs groups[]) {
void spawn_and_collect_items(cmplx pos, float collect_value, SpawnItemsArgs groups[]) {
spawn_items_internal(pos, collect_value, groups);
}

View file

@ -42,35 +42,35 @@ struct Item {
int birthtime;
int collecttime;
complex pos;
complex pos0;
cmplx pos;
cmplx pos0;
int auto_collect;
ItemType type;
float pickup_value;
complex v;
cmplx v;
};
Item *create_item(complex pos, complex v, ItemType type);
Item *create_item(cmplx pos, cmplx v, ItemType type);
void delete_item(Item *item);
void delete_items(void);
Item* create_clear_item(complex pos, uint clear_flags);
Item* create_clear_item(cmplx pos, uint clear_flags);
int collision_item(Item *p);
void process_items(void);
void spawn_item(complex pos, ItemType type);
void spawn_and_collect_item(complex pos, ItemType type, float collect_value);
void spawn_item(cmplx pos, ItemType type);
void spawn_and_collect_item(cmplx pos, ItemType type, float collect_value);
typedef struct SpawnItemsArgs {
ItemType type;
int count;
} SpawnItemsArgs;
void spawn_items(complex pos, SpawnItemsArgs groups[]);
void spawn_and_collect_items(complex pos, float collect_value, SpawnItemsArgs groups[]);
void spawn_items(cmplx pos, SpawnItemsArgs groups[]);
void spawn_and_collect_items(cmplx pos, float collect_value, SpawnItemsArgs groups[]);
#define spawn_items(pos, ...) \
spawn_items(pos, ((SpawnItemsArgs[]) { __VA_ARGS__, { 0 } }))

View file

@ -134,7 +134,7 @@ void lasers_free(void) {
static void ent_draw_laser(EntityInterface *ent);
Laser *create_laser(complex pos, float time, float deathtime, const Color *color, LaserPosRule prule, LaserLogicRule lrule, complex a0, complex a1, complex a2, complex a3) {
Laser *create_laser(cmplx pos, float time, float deathtime, const Color *color, LaserPosRule prule, LaserLogicRule lrule, cmplx a0, cmplx a1, cmplx a2, cmplx a3) {
Laser *l = alist_push(&global.lasers, (Laser*)objpool_acquire(stage_object_pools.lasers));
l->birthtime = global.frames;
@ -173,12 +173,12 @@ Laser *create_laser(complex pos, float time, float deathtime, const Color *color
return l;
}
Laser *create_laserline(complex pos, complex dir, float charge, float dur, const Color *clr) {
Laser *create_laserline(cmplx pos, cmplx dir, float charge, float dur, const Color *clr) {
return create_laserline_ab(pos, (pos)+(dir)*VIEWPORT_H*1.4/cabs(dir), cabs(dir), charge, dur, clr);
}
Laser *create_laserline_ab(complex a, complex b, float width, float charge, float dur, const Color *clr) {
complex m = (b-a)*0.005;
Laser *create_laserline_ab(cmplx a, cmplx b, float width, float charge, float dur, const Color *clr) {
cmplx m = (b-a)*0.005;
return create_laser(a, 200, dur, clr, las_linear, static_laser, m, charge + I*width, 0, 0);
}
@ -272,8 +272,8 @@ static void draw_laser_curve_generic(Laser *l) {
r_vertex_buffer_invalidate(lasers.vbuf);
for(uint i = 0; i < instances; ++i) {
complex pos = l->prule(l, i * 0.5 + timeshift);
complex delta = pos - l->prule(l, i * 0.5 + timeshift - 0.1);
cmplx pos = l->prule(l, i * 0.5 + timeshift);
cmplx delta = pos - l->prule(l, i * 0.5 + timeshift - 0.1);
LaserInstancedAttribs attr;
attr.pos[0] = creal(pos);
@ -438,7 +438,7 @@ void process_lasers(void) {
if(!((global.frames - laser->birthtime) % 2) || kill_now) {
double t = max(0, (global.frames - laser->birthtime)*laser->speed - laser->timespan + laser->timeshift);
complex p = laser->prule(laser, t);
cmplx p = laser->prule(laser, t);
double x = creal(p);
double y = cimag(p);
@ -570,7 +570,7 @@ bool laser_intersects_circle(Laser *l, Circle circle) {
return laser_intersects_ellipse(l, ellipse);
}
complex las_linear(Laser *l, float t) {
cmplx las_linear(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/linear");
l->collision_step = max(3, l->timespan/10);
@ -580,7 +580,7 @@ complex las_linear(Laser *l, float t) {
return l->pos + l->args[0]*t;
}
complex las_accel(Laser *l, float t) {
cmplx las_accel(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/accelerated");
l->collision_step = max(3, l->timespan/10);
@ -590,7 +590,7 @@ complex las_accel(Laser *l, float t) {
return l->pos + l->args[0]*t + 0.5*l->args[1]*t*t;
}
complex las_weird_sine(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
cmplx las_weird_sine(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
// XXX: this used to be called "las_sine", but it's actually not a proper sine wave
// do we even still need this?
@ -603,7 +603,7 @@ complex las_weird_sine(Laser *l, float t) { // [0] = velocity; [1] =
return l->pos + cexp(I * (carg(l->args[0]) + l->args[1] * sin(s) / s)) * t * cabs(l->args[0]);
}
complex las_sine(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
cmplx las_sine(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
// this is actually shaped like a sine wave
if(t == EVENT_BIRTH) {
@ -611,18 +611,18 @@ complex las_sine(Laser *l, float t) { // [0] = velocity; [1] = sin
return 0;
}
complex line_vel = l->args[0];
complex line_dir = line_vel / cabs(line_vel);
complex line_normal = cimag(line_dir) - I*creal(line_dir);
complex sine_amp = l->args[1];
complex sine_freq = l->args[2];
complex sine_phase = l->args[3];
cmplx line_vel = l->args[0];
cmplx line_dir = line_vel / cabs(line_vel);
cmplx line_normal = cimag(line_dir) - I*creal(line_dir);
cmplx sine_amp = l->args[1];
cmplx sine_freq = l->args[2];
cmplx sine_phase = l->args[3];
complex sine_ofs = line_normal * sine_amp * sin(sine_freq * t + sine_phase);
cmplx sine_ofs = line_normal * sine_amp * sin(sine_freq * t + sine_phase);
return l->pos + t * line_vel + sine_ofs;
}
complex las_sine_expanding(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
cmplx las_sine_expanding(Laser *l, float t) { // [0] = velocity; [1] = sine amplitude; [2] = sine frequency; [3] = sine phase
// XXX: this is also a "weird" one
if(t == EVENT_BIRTH) {
@ -630,7 +630,7 @@ complex las_sine_expanding(Laser *l, float t) { // [0] = velocity; [1] = sine am
return 0;
}
complex velocity = l->args[0];
cmplx velocity = l->args[0];
double amplitude = creal(l->args[1]);
double frequency = creal(l->args[2]);
double phase = creal(l->args[3]);
@ -642,14 +642,14 @@ complex las_sine_expanding(Laser *l, float t) { // [0] = velocity; [1] = sine am
return l->pos + cexp(I * (angle + amplitude * sin(s))) * t * speed;
}
complex las_turning(Laser *l, float t) { // [0] = vel0; [1] = vel1; [2] r: turn begin time, i: turn end time
cmplx las_turning(Laser *l, float t) { // [0] = vel0; [1] = vel1; [2] r: turn begin time, i: turn end time
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/turning");
return 0;
}
complex v0 = l->args[0];
complex v1 = l->args[1];
cmplx v0 = l->args[0];
cmplx v1 = l->args[1];
float begin = creal(l->args[2]);
float end = cimag(l->args[2]);
@ -657,12 +657,12 @@ complex las_turning(Laser *l, float t) { // [0] = vel0; [1] = vel1; [2] r: turn
a = 1.0 - (0.5 + 0.5 * cos(a * M_PI));
a = 1.0 - pow(1.0 - a, 2);
complex v = v1 * a + v0 * (1 - a);
cmplx v = v1 * a + v0 * (1 - a);
return l->pos + v * t;
}
complex las_circle(Laser *l, float t) {
cmplx las_circle(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/circle");
return 0;

View file

@ -19,14 +19,14 @@
typedef struct Laser Laser;
typedef LIST_ANCHOR(Laser) LaserList;
typedef complex (*LaserPosRule)(Laser* l, float time);
typedef cmplx (*LaserPosRule)(Laser* l, float time);
typedef void (*LaserLogicRule)(Laser* l, int time);
struct Laser {
ENTITY_INTERFACE_NAMED(Laser, ent);
complex pos;
complex args[4];
cmplx pos;
cmplx args[4];
ShaderProgram *shader;
LaserPosRule prule;
@ -56,10 +56,10 @@ struct Laser {
void lasers_preload(void);
void lasers_free(void);
Laser *create_laserline(complex pos, complex dir, float charge, float dur, const Color *clr);
Laser *create_laserline_ab(complex a, complex b, float width, float charge, float dur, const Color *clr);
Laser *create_laserline(cmplx pos, cmplx dir, float charge, float dur, const Color *clr);
Laser *create_laserline_ab(cmplx a, cmplx b, float width, float charge, float dur, const Color *clr);
Laser *create_laser(complex pos, float time, float deathtime, const Color *color, LaserPosRule prule, LaserLogicRule lrule, complex a0, complex a1, complex a2, complex a3);
Laser *create_laser(cmplx pos, float time, float deathtime, const Color *color, LaserPosRule prule, LaserLogicRule lrule, cmplx a0, cmplx a1, cmplx a2, cmplx a3);
void delete_lasers(void);
void process_lasers(void);
@ -67,13 +67,13 @@ bool laser_is_active(Laser *l);
bool laser_is_clearable(Laser *l);
bool clear_laser(Laser *l, uint flags);
complex las_linear(Laser *l, float t);
complex las_accel(Laser *l, float t);
complex las_sine(Laser *l, float t);
complex las_weird_sine(Laser *l, float t);
complex las_sine_expanding(Laser *l, float t);
complex las_turning(Laser *l, float t);
complex las_circle(Laser *l, float t);
cmplx las_linear(Laser *l, float t);
cmplx las_accel(Laser *l, float t);
cmplx las_sine(Laser *l, float t);
cmplx las_weird_sine(Laser *l, float t);
cmplx las_sine_expanding(Laser *l, float t);
cmplx las_turning(Laser *l, float t);
cmplx las_circle(Laser *l, float t);
float laser_charge(Laser *l, int t, float charge, float width);
void static_laser(Laser *l, int t);

View file

@ -9,6 +9,7 @@
#include "taisei.h"
#include <stdio.h>
#include "menu.h"
#include "common.h"
#include "options.h"

View file

@ -8,7 +8,6 @@
#include "taisei.h"
#include <time.h>
#include "global.h"
#include "menu.h"
#include "options.h"

View file

@ -8,7 +8,6 @@
#include "taisei.h"
#include <time.h>
#include "savereplay.h"
#include "mainmenu.h"
#include "global.h"

View file

@ -126,13 +126,13 @@ bool player_add_power(Player *plr, short pdelta) {
return player_set_power(plr, plr->power + plr->power_overflow + pdelta);
}
void player_move(Player *plr, complex delta) {
void player_move(Player *plr, cmplx delta) {
delta *= player_property(plr, PLR_PROP_SPEED);
complex lastpos = plr->pos;
cmplx lastpos = plr->pos;
double x = clamp(creal(plr->pos) + creal(delta), PLR_MIN_BORDER_DIST, VIEWPORT_W - PLR_MIN_BORDER_DIST);
double y = clamp(cimag(plr->pos) + cimag(delta), PLR_MIN_BORDER_DIST, VIEWPORT_H - PLR_MIN_BORDER_DIST);
plr->pos = x + y*I;
complex realdir = plr->pos - lastpos;
cmplx realdir = plr->pos - lastpos;
if(cabs(realdir)) {
plr->lastmovedir = realdir / cabs(realdir);
@ -450,7 +450,7 @@ static int powersurge_trail(Projectile *p, int t) {
return ACTION_ACK;
}
complex v = (global.plr.pos - p->pos) * 0.05;
cmplx v = (global.plr.pos - p->pos) * 0.05;
p->args[0] += (v - p->args[0]) * (1 - t / p->timeout);
p->pos += p->args[0];
@ -1202,7 +1202,7 @@ static bool player_applymovement_gamepad(Player *plr) {
return false;
}
complex direction = (
cmplx direction = (
gamepad_normalize_axis_value(plr->axis_lr) +
gamepad_normalize_axis_value(plr->axis_ud) * I
);
@ -1277,7 +1277,7 @@ void player_applymovement(Player *plr) {
return;
}
complex direction = 0;
cmplx direction = 0;
if(up) direction -= 1.0*I;
if(down) direction += 1.0*I;
@ -1333,7 +1333,7 @@ void player_fix_input(Player *plr) {
}
}
void player_graze(Player *plr, complex pos, int pts, int effect_intensity, const Color *color) {
void player_graze(Player *plr, cmplx pos, int pts, int effect_intensity, const Color *color) {
if(++plr->graze >= PLR_MAX_GRAZE) {
log_debug("Graze counter overflow");
plr->graze = PLR_MAX_GRAZE;
@ -1452,7 +1452,7 @@ static void scoretext_update(StageText *txt, int t, float a) {
#define SCORETEXT_PIV_BIT ((uintptr_t)1 << ((sizeof(uintptr_t) * 8) - 1))
static StageText *find_scoretext_combination_candidate(complex pos, bool is_piv) {
static StageText *find_scoretext_combination_candidate(cmplx pos, bool is_piv) {
for(StageText *stxt = stagetext_list_head(); stxt; stxt = stxt->next) {
if(
stxt->custom.update == scoretext_update &&
@ -1467,7 +1467,7 @@ static StageText *find_scoretext_combination_candidate(complex pos, bool is_piv)
return NULL;
}
static void add_score_text(Player *plr, complex location, uint points, bool is_piv) {
static void add_score_text(Player *plr, cmplx location, uint points, bool is_piv) {
float rnd = nfrand();
StageText *stxt = find_scoretext_combination_candidate(location, is_piv);
@ -1527,7 +1527,7 @@ static void add_score_text(Player *plr, complex location, uint points, bool is_p
}
}
void player_add_points(Player *plr, uint points, complex location) {
void player_add_points(Player *plr, uint points, cmplx location) {
plr->points += points;
while(plr->points >= plr->extralife_threshold) {
@ -1538,7 +1538,7 @@ void player_add_points(Player *plr, uint points, complex location) {
add_score_text(plr, location, points, false);
}
void player_add_piv(Player *plr, uint piv, complex location) {
void player_add_piv(Player *plr, uint piv, cmplx location) {
uint v = plr->point_item_value + piv;
if(v > PLR_MAX_PIV || v < plr->point_item_value) {
@ -1579,7 +1579,7 @@ void player_register_damage(Player *plr, EntityInterface *target, const DamageIn
return;
}
complex pos = NAN;
cmplx pos = NAN;
if(target != NULL) {
switch(target->type) {
@ -1669,9 +1669,9 @@ void player_preload(void) {
// FIXME: where should this be?
complex plrutil_homing_target(complex org, complex fallback) {
cmplx plrutil_homing_target(cmplx org, cmplx fallback) {
double mindst = INFINITY;
complex target = fallback;
cmplx target = fallback;
if(global.boss && boss_is_vulnerable(global.boss)) {
target = global.boss->pos;

View file

@ -92,10 +92,10 @@ typedef struct PowerSurgeBonus {
struct Player {
ENTITY_INTERFACE_NAMED(Player, ent);
complex pos;
complex velocity;
complex deathpos;
complex lastmovedir;
cmplx pos;
cmplx velocity;
cmplx deathpos;
cmplx lastmovedir;
struct PlayerMode *mode;
AniPlayer ani;
@ -190,11 +190,11 @@ bool player_should_shoot(Player *plr, bool extra);
bool player_set_power(Player *plr, short npow);
bool player_add_power(Player *plr, short pdelta);
void player_move(Player*, complex delta);
void player_move(Player*, cmplx delta);
void player_realdeath(Player*);
void player_death(Player*);
void player_graze(Player *plr, complex pos, int pts, int effect_intensity, const Color *color);
void player_graze(Player *plr, cmplx pos, int pts, int effect_intensity, const Color *color);
void player_event(Player *plr, uint8_t type, uint16_t value, bool *out_useful, bool *out_cheat);
bool player_event_with_replay(Player *plr, uint8_t type, uint16_t value);
@ -205,8 +205,8 @@ void player_add_life_fragments(Player *plr, int frags);
void player_add_bomb_fragments(Player *plr, int frags);
void player_add_lives(Player *plr, int lives);
void player_add_bombs(Player *plr, int bombs);
void player_add_points(Player *plr, uint points, complex location);
void player_add_piv(Player *plr, uint piv, complex location);
void player_add_points(Player *plr, uint points, cmplx location);
void player_add_piv(Player *plr, uint piv, cmplx location);
void player_add_voltage(Player *plr, uint voltage);
bool player_drain_voltage(Player *plr, uint voltage);
void player_extend_powersurge(Player *plr, float pos, float neg);
@ -233,6 +233,6 @@ void player_damage_hook(Player *plr, EntityInterface *target, DamageInfo *dmg);
void player_preload(void);
// FIXME: where should this be?
complex plrutil_homing_target(complex org, complex fallback);
cmplx plrutil_homing_target(cmplx org, cmplx fallback);
#endif // IGUARD_player_h

View file

@ -102,7 +102,7 @@ static void draw_masterspark_ring(int t, float width) {
});
}
static void draw_masterspark_beam(complex origin, complex size, float angle, int t, float alpha) {
static void draw_masterspark_beam(cmplx origin, cmplx size, float angle, int t, float alpha) {
r_mat_mv_push();
r_mat_mv_translate(creal(origin), cimag(origin), 0);
r_mat_mv_rotate(angle, 0, 0, 1);

View file

@ -24,8 +24,8 @@ void marisa_common_shot(Player *plr, float dmg);
void marisa_common_slave_visual(Enemy *e, int t, bool render);
typedef struct MarisaBeamInfo {
complex origin;
complex size;
cmplx origin;
cmplx size;
float angle;
int t;
} MarisaBeamInfo;

View file

@ -20,16 +20,16 @@ static int _laser_renderer_ref;
typedef struct MarisaLaserData {
struct {
complex first;
complex last;
cmplx first;
cmplx last;
} trace_hit;
complex prev_pos;
cmplx prev_pos;
float lean;
} MarisaLaserData;
static void draw_laser_beam(complex src, complex dst, double size, double step, double t, Texture *tex, Uniform *u_length) {
complex dir = dst - src;
complex center = (src + dst) * 0.5;
static void draw_laser_beam(cmplx src, cmplx dst, double size, double step, double t, Texture *tex, Uniform *u_length) {
cmplx dir = dst - src;
cmplx center = (src + dst) * 0.5;
r_mat_mv_push();
@ -49,7 +49,7 @@ static void draw_laser_beam(complex src, complex dst, double size, double step,
r_mat_mv_pop();
}
static void trace_laser(Enemy *e, complex vel, float damage) {
static void trace_laser(Enemy *e, cmplx vel, float damage) {
ProjCollisionResult col;
ProjectileList lproj = { .first = NULL };
@ -323,7 +323,7 @@ static void marisa_laser_flash_draw(Projectile *p, int t) {
Color *c = color_mul_scalar(COLOR_COPY(&p->color), 1 - t / p->timeout);
c->r *= (1 - t / p->timeout);
complex pos = p->pos;
cmplx pos = p->pos;
pos += p->args[0] * 10;
r_draw_sprite(&(SpriteParams) {
@ -355,11 +355,11 @@ static int marisa_laser_slave(Enemy *e, int t) {
return 1;
}
complex target_pos = global.plr.pos + (1 - global.plr.focus/30.0)*e->pos0 + (global.plr.focus/30.0)*e->args[0];
cmplx target_pos = global.plr.pos + (1 - global.plr.focus/30.0)*e->pos0 + (global.plr.focus/30.0)*e->args[0];
e->pos += (target_pos - e->pos) * 0.5;
MarisaLaserData *ld = REF(e->args[3]);
complex pdelta = e->pos - ld->prev_pos;
cmplx pdelta = e->pos - ld->prev_pos;
ld->prev_pos = e->pos;
ld->lean += (-0.01 * creal(pdelta) - ld->lean) * 0.2;
@ -369,7 +369,7 @@ static int marisa_laser_slave(Enemy *e, int t) {
f = smoothreclamp(f, 0, 1, 0, 1);
float factor = (1.0 + 0.7 * psin(t/15.0)) * -(1-f) * !!angle;
complex dir = -cexp(I*(angle*factor + ld->lean + M_PI/2));
cmplx dir = -cexp(I*(angle*factor + ld->lean + M_PI/2));
trace_laser(e, 5 * dir, creal(e->args[1]));
PARTICLE(
@ -429,8 +429,8 @@ static void masterspark_damage(Enemy *e) {
float r = 96 * masterspark_width();
float growth = 0.25;
complex v = e->args[0] * cexp(-I*M_PI*0.5);
complex p = global.plr.pos - 30 * I + r * v;
cmplx v = e->args[0] * cexp(-I*M_PI*0.5);
cmplx p = global.plr.pos - 30 * I + r * v;
Rect vp_rect, seg_rect;
vp_rect.top_left = 0;
@ -447,7 +447,7 @@ static void masterspark_damage(Enemy *e) {
r *= 1 + growth;
growth *= 0.75;
complex o = (1 + I);
cmplx o = (1 + I);
seg_rect.top_left = p - o * r;
seg_rect.bottom_right = p + o * r;
@ -472,14 +472,14 @@ static int masterspark(Enemy *e, int t2) {
return 1;
e->args[0] *= cexp(I*(0.005*creal(global.plr.velocity) + nfrand() * 0.005));
complex diroffset = e->args[0];
cmplx diroffset = e->args[0];
float t = player_get_bomb_progress(&global.plr);
if(t >= 3.0/4.0) {
global.shake_view = 8 * (1 - t * 4 + 3);
} else if(t2 % 2 == 0) {
complex dir = -cexp(1.5*I*sin(t2*M_PI*1.12))*I;
cmplx dir = -cexp(1.5*I*sin(t2*M_PI*1.12))*I;
Color *c = HSLA(-t*5.321,1,0.5,0.5*frand());
uint flags = PFLAG_NOREFLECT;
@ -557,7 +557,7 @@ static void marisa_laser_bomb(Player *plr) {
e->ent.draw_layer = LAYER_PLAYER_FOCUS - 1;
}
static Enemy* marisa_laser_spawn_slave(Player *plr, complex pos, complex a0, complex a1, complex a2, complex a3) {
static Enemy* marisa_laser_spawn_slave(Player *plr, cmplx pos, cmplx a0, cmplx a1, cmplx a2, cmplx a3) {
Enemy *e = create_enemy_p(&plr->slaves, pos, ENEMY_IMMUNE, marisa_laser_slave_visual, marisa_laser_slave, a0, a1, a2, a3);
e->pos = plr->pos;
return e;

View file

@ -57,7 +57,7 @@ static int marisa_star_projectile(Projectile *p, int t) {
}
double centerfac = tanh(t/10.); // interpolate between player center and slave center
complex center = global.plr.pos*(1-centerfac) + e->args[2]*centerfac;
cmplx center = global.plr.pos*(1-centerfac) + e->args[2]*centerfac;
double brightener = -1/(1+sqrt(0.03*fabs(creal(p->pos-center))));
p->color = *RGBA(0.3+(1-focus)*0.7+brightener,0.8+brightener,1.0-(1-focus)*0.7+brightener,0.2+brightener);
@ -88,7 +88,7 @@ static int marisa_star_slave(Enemy *e, int t) {
for(int i = 0; i < 2; ++i) {
if(player_should_shoot(&global.plr, true) && !((global.frames+2*i) % 5)) {
float fac = e->args[0]/M_PI/2;
complex v = (1-2*i);
cmplx v = (1-2*i);
v = creal(v)/cabs(v);
v *= 1-0.9*fac;
v -= I*0.04*t*(4-3*fac);
@ -115,7 +115,7 @@ static int marisa_star_slave(Enemy *e, int t) {
e->ent.draw_layer = LAYER_PLAYER_SLAVE;
}
complex d = global.plr.pos-e->args[2];
cmplx d = global.plr.pos-e->args[2];
e->args[2] += (2+2*!global.plr.focus)*d/(cabs(d)+2);
e->pos = e->args[2] + 80*sin(angle)+45*I;
@ -158,7 +158,7 @@ static int marisa_star_orbit(Enemy *e, int t) {
}
double r = 100*pow(tanh(t/20.),2);
complex dir = e->args[1]*r*cexp(I*(sqrt(1000+t*t+0.03*t*t*t))*0.04);
cmplx dir = e->args[1]*r*cexp(I*(sqrt(1000+t*t+0.03*t*t*t))*0.04);
e->pos = global.plr.pos+dir;
float fadetime = 3./4;
@ -258,7 +258,7 @@ static void marisa_star_bomb(Player *plr) {
play_sound("bomb_marisa_b");
for(int i = 0; i < NUM_MARISTAR_SLAVES; i++) {
complex dir = cexp(2*I*M_PI/NUM_MARISTAR_SLAVES*i);
cmplx dir = cexp(2*I*M_PI/NUM_MARISTAR_SLAVES*i);
Enemy *e = create_enemy2c(plr->pos, ENEMY_BOMB, marisa_star_orbit_visual, marisa_star_orbit, i ,dir);
e->ent.draw_layer = LAYER_PLAYER_FOCUS - 1;
}

View file

@ -154,7 +154,7 @@ static int reimu_spirit_homing(Projectile *p, int t) {
p->args[3] = plrutil_homing_target(p->pos, p->args[3]);
double v = cabs(p->args[0]);
complex aimdir = cexp(I*carg(p->args[3] - p->pos));
cmplx aimdir = cexp(I*carg(p->args[3] - p->pos));
double aim = reimu_spirit_homing_aimfactor(t, p->args[1]);
p->args[0] += v * 0.25 * aim * aimdir;
@ -174,10 +174,10 @@ static Color *reimu_spirit_orb_color(Color *c, int i) {
}
static void reimu_spirit_bomb_orb_visual(Projectile *p, int t) {
complex pos = p->pos;
cmplx pos = p->pos;
for(int i = 0; i < 3; i++) {
complex offset = (10 + pow(t, 0.5)) * cexp(I * (2 * M_PI / 3*i + sqrt(1 + t * t / 300.0)));
cmplx offset = (10 + pow(t, 0.5)) * cexp(I * (2 * M_PI / 3*i + sqrt(1 + t * t / 300.0)));
Color c;
r_draw_sprite(&(SpriteParams) {
@ -307,21 +307,21 @@ static int reimu_spirit_bomb_orb(Projectile *p, int t) {
play_sound("redirect");
}
complex target_circle = global.plr.pos + 10 * sqrt(t) * p->args[0]*(1 + 0.1 * sin(0.2*t));
cmplx target_circle = global.plr.pos + 10 * sqrt(t) * p->args[0]*(1 + 0.1 * sin(0.2*t));
p->args[0] *= cexp(I*0.12);
double circlestrength = 1.0 / (1 + exp(t-circletime));
p->args[3] = plrutil_homing_target(p->pos, p->args[3]);
complex target_homing = p->args[3];
complex homing = target_homing - p->pos;
complex v = 0.3 * (circlestrength * (target_circle - p->pos) + 0.2 * (1-circlestrength) * (homing + 2*homing/(cabs(homing)+0.01)));
cmplx target_homing = p->args[3];
cmplx homing = target_homing - p->pos;
cmplx v = 0.3 * (circlestrength * (target_circle - p->pos) + 0.2 * (1-circlestrength) * (homing + 2*homing/(cabs(homing)+0.01)));
p->args[2] += (v - p->args[2]) * 0.1;
p->pos += p->args[2];
for(int i = 0; i < 3 /*&& circlestrength < 1*/; i++) {
complex trail_pos = p->pos + 10 * cexp(I*2*M_PI/3*(i+t*0.1));
complex trail_vel = global.plr.pos - trail_pos;
cmplx trail_pos = p->pos + 10 * cexp(I*2*M_PI/3*(i+t*0.1));
cmplx trail_vel = global.plr.pos - trail_pos;
trail_vel *= 3 * circlestrength / cabs(trail_vel);
PARTICLE(
@ -439,7 +439,7 @@ static void reimu_spirit_slave_shot(Enemy *e, int t) {
.shader = "sprite_default",
);
} else if(!(st % 12)) {
complex v = -10 * I * cexp(I*cimag(e->args[0]));
cmplx v = -10 * I * cexp(I*cimag(e->args[0]));
PROJECTILE(
.proto = pp_ofuda,
@ -546,7 +546,7 @@ static void reimu_spirit_yinyang_unfocused_visual(Enemy *e, int t, bool render)
}
}
static inline Enemy* reimu_spirit_spawn_slave(Player *plr, complex pos, complex a0, complex a1, complex a2, complex a3, EnemyVisualRule visual) {
static inline Enemy* reimu_spirit_spawn_slave(Player *plr, cmplx pos, cmplx a0, cmplx a1, cmplx a2, cmplx a3, EnemyVisualRule visual) {
Enemy *e = create_enemy_p(&plr->slaves, pos, ENEMY_IMMUNE, visual, reimu_spirit_slave, a0, a1, a2, a3);
e->ent.draw_layer = LAYER_PLAYER_SLAVE;
return e;
@ -565,10 +565,10 @@ static void reimu_spirit_kill_slaves(EnemyList *slaves) {
}
}
static void reimu_spirit_respawn_slaves(Player *plr, short npow, complex param) {
static void reimu_spirit_respawn_slaves(Player *plr, short npow, cmplx param) {
double dmg_homing = 120 - 12 * plr->power / 100; // every 12 frames
double dmg_needle = 92 - 10 * plr->power / 100; // every 3 frames
complex dmg = dmg_homing + I * dmg_needle;
cmplx dmg = dmg_homing + I * dmg_needle;
EnemyVisualRule visual;
if(plr->inputflags & INFLAG_FOCUS) {

View file

@ -27,7 +27,7 @@
static Enemy *gap_renderer;
static complex reimu_dream_gap_target_pos(Enemy *e) {
static cmplx reimu_dream_gap_target_pos(Enemy *e) {
double x, y;
if(creal(e->pos0)) {
@ -156,7 +156,7 @@ static int reimu_dream_gap(Enemy *e, int t) {
reimu_dream_gap_bomb(e, t + cimag(e->args[3]));
}
complex new_pos = reimu_dream_gap_target_pos(e);
cmplx new_pos = reimu_dream_gap_target_pos(e);
if(t == 0) {
e->pos = new_pos;
@ -190,7 +190,7 @@ static void reimu_dream_gap_draw_lights(int time, double strength) {
FOR_EACH_GAP(gap) {
const float len = GAP_LENGTH * 3 * sqrt(log(strength + 1) / 0.693);
complex center = gap->pos - gap->pos0 * (len * 0.5 - GAP_WIDTH * 0.6);
cmplx center = gap->pos - gap->pos0 * (len * 0.5 - GAP_WIDTH * 0.6);
r_mat_mv_push();
r_mat_mv_translate(creal(center), cimag(center), 0);
@ -253,7 +253,7 @@ static void reimu_dream_gap_renderer_visual(Enemy *e, int t, bool render) {
FOR_EACH_GAP(gap) {
r_mat_mv_push();
r_mat_mv_translate(creal(gap->pos), cimag(gap->pos), 0);
complex stretch_vector = gap->args[0];
cmplx stretch_vector = gap->args[0];
for(float ofs = -0.5; ofs <= 0.5; ofs += 1) {
r_draw_sprite(&(SpriteParams) {
@ -329,7 +329,7 @@ static void reimu_dream_bomb_bg(Player *p) {
}
static void reimu_dream_spawn_warp_effect(complex pos, bool exit) {
static void reimu_dream_spawn_warp_effect(cmplx pos, bool exit) {
PARTICLE(
.sprite = "myon",
.pos = pos,
@ -359,7 +359,7 @@ static void reimu_dream_bullet_warp(Projectile *p, int t) {
}
double p_long_side = max(creal(p->size), cimag(p->size));
complex half = 0.5 * (1 + I);
cmplx half = 0.5 * (1 + I);
Rect p_bbox = { p->pos - p_long_side * half, p->pos + p_long_side * half };
FOR_EACH_GAP(gap) {
@ -370,14 +370,14 @@ static void reimu_dream_bullet_warp(Projectile *p, int t) {
}
Rect gap_bbox, overlap;
complex gap_size = (GAP_LENGTH + I * GAP_WIDTH) * cexp(I*carg(gap->args[0]));
complex p0 = gap->pos - gap_size * 0.5;
complex p1 = gap->pos + gap_size * 0.5;
cmplx gap_size = (GAP_LENGTH + I * GAP_WIDTH) * cexp(I*carg(gap->args[0]));
cmplx p0 = gap->pos - gap_size * 0.5;
cmplx p1 = gap->pos + gap_size * 0.5;
gap_bbox.top_left = min(creal(p0), creal(p1)) + I * min(cimag(p0), cimag(p1));
gap_bbox.bottom_right = max(creal(p0), creal(p1)) + I * max(cimag(p0), cimag(p1));
if(rect_rect_intersection(p_bbox, gap_bbox, true, false, &overlap)) {
complex o = (overlap.top_left + overlap.bottom_right) / 2;
cmplx o = (overlap.top_left + overlap.bottom_right) / 2;
double fract;
if(creal(gap_size) > cimag(gap_size)) {
@ -404,7 +404,7 @@ static int reimu_dream_ofuda(Projectile *p, int t) {
reimu_dream_bullet_warp(p, t);
}
complex ov = p->args[0];
cmplx ov = p->args[0];
double s = cabs(ov);
p->args[0] *= clamp(s * (1.5 - t / 10.0), s*1.0, 1.5*s) / s;
int r = reimu_common_ofuda(p, t);
@ -450,8 +450,8 @@ static void reimu_dream_shot(Player *p) {
if(!(global.frames % 6)) {
for(int i = -1; i < 2; i += 2) {
complex shot_dir = i * ((p->inputflags & INFLAG_FOCUS) ? 1 : I);
complex spread_dir = shot_dir * cexp(I*M_PI*0.5);
cmplx shot_dir = i * ((p->inputflags & INFLAG_FOCUS) ? 1 : I);
cmplx spread_dir = shot_dir * cexp(I*M_PI*0.5);
for(int j = -1; j < 2; j += 2) {
PROJECTILE(
@ -492,8 +492,8 @@ static int reimu_dream_slave(Enemy *e, int t) {
// double a = M_PI * psin(t * 0.1) + creal(e->args[0]) + M_PI/2;
double a = t * -0.1 + creal(e->args[0]) + M_PI/2;
complex ofs = e->pos0;
complex shotdir = e->args[1];
cmplx ofs = e->pos0;
cmplx shotdir = e->args[1];
if(global.plr.inputflags & INFLAG_FOCUS) {
ofs = cimag(ofs) + I * creal(ofs);
@ -505,7 +505,7 @@ static int reimu_dream_slave(Enemy *e, int t) {
} else {
double x = creal(ofs);
double y = cimag(ofs);
complex tpos = global.plr.pos + x * sin(a) + y * I * cos(a);
cmplx tpos = global.plr.pos + x * sin(a) + y * I * cos(a);
e->pos += (tpos - e->pos) * 0.5;
}
@ -527,7 +527,7 @@ static int reimu_dream_slave(Enemy *e, int t) {
return ACTION_NONE;
}
static Enemy* reimu_dream_spawn_slave(Player *plr, complex pos, complex a0, complex a1, complex a2, complex a3) {
static Enemy* reimu_dream_spawn_slave(Player *plr, cmplx pos, cmplx a0, cmplx a1, cmplx a2, cmplx a3) {
Enemy *e = create_enemy_p(&plr->slaves, pos, ENEMY_IMMUNE, reimu_dream_slave_visual, reimu_dream_slave, a0, a1, a2, a3);
e->ent.draw_layer = LAYER_PLAYER_SLAVE;
return e;
@ -560,7 +560,7 @@ static void reimu_dream_power(Player *p, short npow) {
}
}
static Enemy* reimu_dream_spawn_gap(Player *plr, complex pos, complex a0, complex a1, complex a2, complex a3) {
static Enemy* reimu_dream_spawn_gap(Player *plr, cmplx pos, cmplx a0, cmplx a1, cmplx a2, cmplx a3) {
Enemy *gap = create_enemy_p(&plr->slaves, pos, ENEMY_IMMUNE, NULL, reimu_dream_gap, a0, a1, a2, a3);
gap->ent.draw_layer = LAYER_PLAYER_SLAVE;
return gap;

View file

@ -35,9 +35,9 @@ static int myon_particle_rule(Projectile *p, int t) {
return ACTION_NONE;
}
static complex myon_tail_dir(void) {
static cmplx myon_tail_dir(void) {
double angle = carg(MYON->args[0]);
complex dir = cexp(I*(0.1 * sin(global.frames * 0.05) + angle));
cmplx dir = cexp(I*(0.1 * sin(global.frames * 0.05) + angle));
float f = abs(global.plr.focus) / 30.0;
return f * f * dir;
}
@ -65,7 +65,7 @@ static void myon_draw_trail(Projectile *p, int t) {
youmu_common_draw_proj(p, &c, fadein * (2-s) * p->args[1]);
}
static void spawn_stardust(complex pos, float myon_color_f, int timeout, complex v) {
static void spawn_stardust(cmplx pos, float myon_color_f, int timeout, cmplx v) {
PARTICLE(
.sprite = "stardust",
.pos = pos+5*frand()*cexp(2.0*I*M_PI*frand()),
@ -81,9 +81,9 @@ static void spawn_stardust(complex pos, float myon_color_f, int timeout, complex
static void myon_spawn_trail(Enemy *e, int t) {
float a = global.frames * 0.07;
complex pos = e->pos + 3 * (cos(a) + I * sin(a));
cmplx pos = e->pos + 3 * (cos(a) + I * sin(a));
complex stardust_v = 3 * myon_tail_dir() * cexp(I*M_PI/16*sin(1.33*t));
cmplx stardust_v = 3 * myon_tail_dir() * cexp(I*M_PI/16*sin(1.33*t));
float f = abs(global.plr.focus) / 30.0;
stardust_v = f * stardust_v + (1 - f) * -I;
@ -173,8 +173,8 @@ static void myon_proj_draw(Projectile *p, int t) {
youmu_common_draw_proj(p, &p->color, 1);
}
static Projectile* youmu_mirror_myon_proj(ProjPrototype *proto, complex pos, double speed, double angle, double aoffs, double upfactor, float dmg) {
complex dir = cexp(I*(M_PI/2 + aoffs)) * upfactor + cexp(I * (angle + aoffs)) * (1 - upfactor);
static Projectile* youmu_mirror_myon_proj(ProjPrototype *proto, cmplx pos, double speed, double angle, double aoffs, double upfactor, float dmg) {
cmplx dir = cexp(I*(M_PI/2 + aoffs)) * upfactor + cexp(I * (angle + aoffs)) * (1 - upfactor);
dir = dir / cabs(dir);
// float f = ((global.plr.inputflags & INFLAG_FOCUS) == INFLAG_FOCUS);
@ -252,8 +252,8 @@ static int youmu_mirror_myon(Enemy *e, int t) {
}
}
complex target = plr->pos + e->pos0;
complex v = cexp(I*carg(target - e->pos)) * min(10, followfactor * max(0, cabs(target - e->pos) - VIEWPORT_W * 0.5 * nfocus));
cmplx target = plr->pos + e->pos0;
cmplx v = cexp(I*carg(target - e->pos)) * min(10, followfactor * max(0, cabs(target - e->pos) - VIEWPORT_W * 0.5 * nfocus));
float s = sign(creal(e->pos) - creal(global.plr.pos));
if(!s) {
@ -321,19 +321,19 @@ static int youmu_mirror_self_proj(Projectile *p, int t) {
return ACTION_ACK;
}
complex v0 = p->args[0];
complex v1 = p->args[1];
cmplx v0 = p->args[0];
cmplx v1 = p->args[1];
double f = creal(p->args[2]) ? clamp(t / p->args[2], 0, 1) : 1;
complex v = v1*f + v0*(1-f);
cmplx v = v1*f + v0*(1-f);
complex diff = p->pos0 + v * t - p->pos;
cmplx diff = p->pos0 + v * t - p->pos;
p->pos += diff;
p->angle = carg(diff ? diff : v);
return 1;
}
static Projectile* youmu_mirror_self_shot(Player *plr, complex ofs, complex vel, float dmg, double turntime) {
static Projectile* youmu_mirror_self_shot(Player *plr, cmplx ofs, cmplx vel, float dmg, double turntime) {
return PROJECTILE(
.proto = pp_youmu,
.pos = plr->pos + ofs,
@ -371,7 +371,7 @@ static void youmu_mirror_shot(Player *plr) {
}
}
static void youmu_mirror_bomb_damage_callback(EntityInterface *victim, complex victim_origin, void *arg) {
static void youmu_mirror_bomb_damage_callback(EntityInterface *victim, cmplx victim_origin, void *arg) {
victim_origin += cexp(I*M_PI*2*frand()) * 15 * frand();
PARTICLE(
@ -418,10 +418,10 @@ static int youmu_mirror_bomb_controller(Enemy *e, int t) {
}
MYON->pos = e->pos;
complex myonpos = MYON->pos;
cmplx myonpos = MYON->pos;
e->pos += e->args[0];
complex aim = (global.plr.pos - e->pos) * 0.01;
cmplx aim = (global.plr.pos - e->pos) * 0.01;
double accel_max = 1;
if(cabs(aim) > accel_max) {
@ -480,7 +480,7 @@ static bool youmu_mirror_shader(Framebuffer *fb) {
r_shader_ptr(shader);
r_uniform_float("tbomb", t);
complex myonpos = MYON->pos;
cmplx myonpos = MYON->pos;
float f = max(0,1 - 10*t);
r_uniform_vec2("myon", creal(myonpos)/VIEWPORT_W, 1-cimag(myonpos)/VIEWPORT_H);
r_uniform_vec4("fill_overlay", f, f, f, f);

View file

@ -12,7 +12,7 @@
#include "plrmodes.h"
#include "youmu.h"
static complex youmu_homing_target(complex org, complex fallback) {
static cmplx youmu_homing_target(cmplx org, cmplx fallback) {
return plrutil_homing_target(org, fallback);
}
@ -64,7 +64,7 @@ static float youmu_trap_charge(int t) {
return pow(clamp(t / 60.0, 0, 1), 1.5);
}
static Projectile* youmu_homing_trail(Projectile *p, complex v, int to) {
static Projectile* youmu_homing_trail(Projectile *p, cmplx v, int to) {
return PARTICLE(
.sprite_ptr = p->sprite,
.pos = p->pos,
@ -108,7 +108,7 @@ static int youmu_homing(Projectile *p, int t) { // a[0]: velocity, a[1]: aim (r:
p->args[3] = youmu_homing_target(p->pos, p->args[3]);
double v = cabs(p->args[0]);
complex aimdir = cexp(I*carg(p->args[3] - p->pos));
cmplx aimdir = cexp(I*carg(p->args[3] - p->pos));
p->args[0] += creal(p->args[1]) * aimdir;
// p->args[0] = v * cexp(I*carg(p->args[0])) + cimag(p->args[1]) * aimdir;
@ -128,7 +128,7 @@ static int youmu_homing(Projectile *p, int t) { // a[0]: velocity, a[1]: aim (r:
return 1;
}
static Projectile* youmu_trap_trail(Projectile *p, complex v, int t, bool additive) {
static Projectile* youmu_trap_trail(Projectile *p, cmplx v, int t, bool additive) {
Projectile *trail = youmu_homing_trail(p, v, t);
trail->draw_rule = youmu_trap_draw_trail;
// trail->args[3] = global.frames - p->birthtime;
@ -192,12 +192,12 @@ static int youmu_trap(Projectile *p, int t) {
int cnt = round(creal(p->args[2]));
int dmg = cimag(p->args[2]);
complex aim = p->args[3];
cmplx aim = p->args[3];
for(int i = 0; i < cnt; ++i) {
int dur = 120; // 55 + 20 * nfrand();
float a = (i / (float)cnt) * M_PI * 2;
complex dir = cexp(I*(a));
cmplx dir = cexp(I*(a));
PROJECTILE(
.proto = pp_youmu,
@ -247,7 +247,7 @@ static void youmu_particle_slice_draw(Projectile *p, int t) {
r_mat_mv_pop();
double slicelen = 500;
complex slicepos = p->pos-(tt>0.1)*slicelen*I*cexp(I*p->angle)*(5*pow(tt-0.1,1.1)-0.5);
cmplx slicepos = p->pos-(tt>0.1)*slicelen*I*cexp(I*p->angle)*(5*pow(tt-0.1,1.1)-0.5);
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = aniplayer_get_frame(&global.plr.ani),
@ -283,7 +283,7 @@ static int youmu_particle_slice_logic(Projectile *p, int t) {
p->color = *RGBA(a, a, a, 0);
complex phase = cexp(p->angle * I);
cmplx phase = cexp(p->angle * I);
if(t%5 == 0) {
tsrand_fill(4);
@ -331,7 +331,7 @@ static int youmu_slash(Enemy *e, int t) {
TIMER(&t);
FROM_TO(0,10000,3) {
complex pos = cexp(I*_i)*(100+10*_i*_i*0.01);
cmplx pos = cexp(I*_i)*(100+10*_i*_i*0.01);
PARTICLE(
.sprite = "youmu_slice",
.color = RGBA(1, 1, 1, 0),
@ -373,7 +373,7 @@ static void youmu_haunting_power_shot(Player *plr, int p) {
float np = (float)p / (2 * plr->power / 100);
for(int sign = -1; sign < 2; sign += 2) {
complex dir = cexp(I*carg(sign*p*spread-speed*I));
cmplx dir = cexp(I*carg(sign*p*spread-speed*I));
PROJECTILE(
.proto = pp_hghost,
@ -399,7 +399,7 @@ static void youmu_haunting_shot(Player *plr) {
if(!(global.frames % (45 - 4 * pwr))) {
int pcnt = 11 + pwr * 4;
int pdmg = 120 - 18 * 4 * (1 - pow(1 - pwr / 4.0, 1.5));
complex aim = 0.15*I;
cmplx aim = 0.15*I;
PROJECTILE(
.proto = pp_youhoming,

View file

@ -12,6 +12,7 @@
#include "taisei.h"
#include <SDL.h>
#include "ending.h"
#define PROGRESS_FILE "storage/progress.dat"

View file

@ -170,14 +170,14 @@ void projectile_set_prototype(Projectile *p, ProjPrototype *proto) {
p->proto = proto;
}
complex projectile_graze_size(Projectile *p) {
cmplx projectile_graze_size(Projectile *p) {
if(
p->type == PROJ_ENEMY &&
!(p->flags & (PFLAG_NOGRAZE | PFLAG_NOCOLLISION)) &&
p->graze_counter < 3 &&
global.frames >= p->graze_cooldown
) {
complex s = (p->size * 420 /* graze it */) / (2 * p->graze_counter + 1);
cmplx s = (p->size * 420 /* graze it */) / (2 * p->graze_counter + 1);
return sqrt(creal(s)) + sqrt(cimag(s)) * I;
}
@ -1003,7 +1003,7 @@ void Petal(Projectile *p, int t) {
r_mat_mv_pop();
}
void petal_explosion(int n, complex pos) {
void petal_explosion(int n, cmplx pos) {
for(int i = 0; i < n; i++) {
tsrand_fill(6);
float t = frand();

View file

@ -70,12 +70,12 @@ typedef struct ProjPrototype ProjPrototype;
struct Projectile {
ENTITY_INTERFACE_NAMED(Projectile, ent);
complex pos;
complex pos0;
complex prevpos; // used to lerp trajectory for collision detection; set this to pos if you intend to "teleport" the projectile in the rule!
complex size; // affects out-of-viewport culling and grazing
complex collision_size; // affects collision with player (TODO: make this work for player projectiles too?)
complex args[RULE_ARGC];
cmplx pos;
cmplx pos0;
cmplx prevpos; // used to lerp trajectory for collision detection; set this to pos if you intend to "teleport" the projectile in the rule!
cmplx size; // affects out-of-viewport culling and grazing
cmplx collision_size; // affects collision with player (TODO: make this work for player projectiles too?)
cmplx args[RULE_ARGC];
ProjRule rule;
ProjDrawRule draw_rule;
ShaderProgram *shader;
@ -116,11 +116,11 @@ typedef struct ProjArgs {
const ShaderCustomParams *shader_params;
ProjectileList *dest;
ProjRule rule;
complex args[RULE_ARGC];
cmplx args[RULE_ARGC];
ProjDrawRule draw_rule;
complex pos;
complex size; // affects default draw order, out-of-viewport culling, and grazing
complex collision_size; // affects collision with player (TODO: make this work for player projectiles too?)
cmplx pos;
cmplx size; // affects default draw order, out-of-viewport culling, and grazing
cmplx collision_size; // affects collision with player (TODO: make this work for player projectiles too?)
ProjType type;
ProjFlags flags;
BlendMode blend;
@ -161,7 +161,7 @@ typedef enum ProjCollisionType {
typedef struct ProjCollisionResult {
ProjCollisionType type;
bool fatal; // for the projectile
complex location;
cmplx location;
DamageInfo damage;
EntityInterface *entity;
} ProjCollisionResult;
@ -215,13 +215,13 @@ void ScaleFade(Projectile *p, int t);
void ScaleSquaredFade(Projectile *p, int t);
void Petal(Projectile *p, int t);
void petal_explosion(int n, complex pos);
void petal_explosion(int n, cmplx pos);
void Blast(Projectile *p, int t);
void projectiles_preload(void);
void projectiles_free(void);
complex projectile_graze_size(Projectile *p);
cmplx projectile_graze_size(Projectile *p);
#endif // IGUARD_projectile_h

View file

@ -15,8 +15,8 @@
typedef struct PPBasicPriv {
const char *sprite_name;
Sprite *sprite;
complex size;
complex collision_size;
cmplx size;
cmplx collision_size;
} PPBasicPriv;
static void pp_basic_preload(ProjPrototype *proto) {

View file

@ -652,12 +652,12 @@ void _r_uniform_vec2_vec(const char *uniform, vec2_noalign value) {
_r_uniform_ptr_vec2_vec(r_shader_current_uniform(uniform), value);
}
void _r_uniform_ptr_vec2_complex(Uniform *uniform, complex value) {
void _r_uniform_ptr_vec2_complex(Uniform *uniform, cmplx value) {
ASSERT_UTYPE(uniform, UNIFORM_VEC2);
if(uniform) B.uniform(uniform, 0, 1, (vec2_noalign) { creal(value), cimag(value) });
}
void _r_uniform_vec2_complex(const char *uniform, complex value) {
void _r_uniform_vec2_complex(const char *uniform, cmplx value) {
_r_uniform_ptr_vec2_complex(r_shader_current_uniform(uniform), value);
}
@ -670,11 +670,11 @@ void _r_uniform_vec2_array(const char *uniform, uint offset, uint count, vec2_no
_r_uniform_ptr_vec2_array(r_shader_current_uniform(uniform), offset, count, elements);
}
void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count, complex elements[count]) {
void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count, cmplx elements[count]) {
ASSERT_UTYPE(uniform, UNIFORM_VEC2);
if(uniform && count) {
float arr[2 * count];
complex *eptr = elements;
cmplx *eptr = elements;
float *aptr = arr, *aend = arr + sizeof(arr)/sizeof(*arr);
do {
@ -686,7 +686,7 @@ void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count
}
}
void _r_uniform_vec2_array_complex(const char *uniform, uint offset, uint count, complex elements[count]) {
void _r_uniform_vec2_array_complex(const char *uniform, uint offset, uint count, cmplx elements[count]) {
_r_uniform_ptr_vec2_array_complex(r_shader_current_uniform(uniform), offset, count, elements);
}

View file

@ -485,16 +485,16 @@ void _r_uniform_ptr_vec2_vec(Uniform *uniform, vec2_noalign value) attr_nonnull(
void _r_uniform_vec2_vec(const char *uniform, vec2_noalign value) attr_nonnull(1, 2);
#define r_uniform_vec2_vec(uniform, ...) _R_UNIFORM_GENERIC(vec2_vec, uniform, __VA_ARGS__)
void _r_uniform_ptr_vec2_complex(Uniform *uniform, complex value);
void _r_uniform_vec2_complex(const char *uniform, complex value) attr_nonnull(1);
void _r_uniform_ptr_vec2_complex(Uniform *uniform, cmplx value);
void _r_uniform_vec2_complex(const char *uniform, cmplx value) attr_nonnull(1);
#define r_uniform_vec2_complex(uniform, ...) _R_UNIFORM_GENERIC(vec2_complex, uniform, __VA_ARGS__)
void _r_uniform_ptr_vec2_array(Uniform *uniform, uint offset, uint count, vec2_noalign elements[count]) attr_nonnull(4);
void _r_uniform_vec2_array(const char *uniform, uint offset, uint count, vec2_noalign elements[count]) attr_nonnull(1, 4);
#define r_uniform_vec2_array(uniform, ...) _R_UNIFORM_GENERIC(vec2_array, uniform, __VA_ARGS__)
void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count, complex elements[count]) attr_nonnull(4);
void _r_uniform_vec2_array_complex(const char *uniform, uint offset, uint count, complex elements[count]) attr_nonnull(1, 4);
void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count, cmplx elements[count]) attr_nonnull(4);
void _r_uniform_vec2_array_complex(const char *uniform, uint offset, uint count, cmplx elements[count]) attr_nonnull(1, 4);
#define r_uniform_vec2_array_complex(uniform, ...) _R_UNIFORM_GENERIC(vec2_array_complex, uniform, __VA_ARGS__)
void _r_uniform_ptr_vec3(Uniform *uniform, float x, float y, float z);

View file

@ -50,7 +50,7 @@
#define glClearDepth glClearDepthf
#define glClearTexImage glClearTexImageEXT
#else
#include "glad/glad.h"
#include <glad/glad.h>
#define GL_FUNC(f) (glad_gl##f)
#endif

View file

@ -397,7 +397,7 @@ static bool add_glyph_to_spritesheet(Glyph *glyph, Pixmap *pixmap, SpriteSheet *
glyph->spritesheet = ss;
complex ofs = GLYPH_SPRITE_PADDING * (1+I);
cmplx ofs = GLYPH_SPRITE_PADDING * (1+I);
Rect sprite_pos = rectpack_section_rect(glyph->spritesheet_section);
sprite_pos.bottom_right += ofs;

View file

@ -9,6 +9,7 @@
#include "taisei.h"
#include <SDL.h>
#include "util.h"
#include "postprocess.h"
#include "resource.h"

View file

@ -642,9 +642,9 @@ void fill_screen_p(Texture *tex) {
// draws a thin, w-width rectangle from point A to point B with a texture that
// moves along the line.
//
void loop_tex_line_p(complex a, complex b, float w, float t, Texture *texture) {
complex d = b-a;
complex c = (b+a)/2;
void loop_tex_line_p(cmplx a, cmplx b, float w, float t, Texture *texture) {
cmplx d = b-a;
cmplx c = (b+a)/2;
r_mat_mv_push();
r_mat_mv_translate(creal(c), cimag(c), 0);
@ -661,6 +661,6 @@ void loop_tex_line_p(complex a, complex b, float w, float t, Texture *texture) {
r_mat_mv_pop();
}
void loop_tex_line(complex a, complex b, float w, float t, const char *texture) {
void loop_tex_line(cmplx a, cmplx b, float w, float t, const char *texture) {
loop_tex_line_p(a, b, w, t, get_tex(texture));
}

View file

@ -11,7 +11,6 @@
#include "taisei.h"
#include <SDL.h>
#include "util.h"
#include "resource.h"
@ -29,8 +28,8 @@ void fill_viewport_p(float xoff, float yoff, float ratio, float aspect, float an
void fill_screen(const char *name);
void fill_screen_p(Texture *tex);
void loop_tex_line_p(complex a, complex b, float w, float t, Texture *texture);
void loop_tex_line(complex a, complex b, float w, float t, const char *texture);
void loop_tex_line_p(cmplx a, cmplx b, float w, float t, Texture *texture);
void loop_tex_line(cmplx a, cmplx b, float w, float t, const char *texture);
Texture* get_tex(const char *name);
Texture* prefix_get_tex(const char *name, const char *prefix);

View file

@ -12,7 +12,7 @@
#include "taisei.h"
#include <SDL.h>
#include <zip.h>
#include "vfs/zipfile_impl.h"
SDL_RWops *SDL_RWFromZipFile(VFSNode *znode, VFSZipPathData *pdata);

View file

@ -10,6 +10,7 @@
#include <SDL.h>
#include <zlib.h>
#include "rwops_zlib.h"
#include "util.h"

View file

@ -10,8 +10,6 @@
#include "util.h"
#include "stage.h"
#include <time.h>
#include "global.h"
#include "video.h"
#include "resource/bgm.h"
@ -552,7 +550,7 @@ static bool ellipse_predicate(EntityInterface *ent, void *varg) {
default: UNREACHABLE;
}
}
void stage_clear_hazards_at(complex origin, double radius, ClearHazardsFlags flags) {
void stage_clear_hazards_at(cmplx origin, double radius, ClearHazardsFlags flags) {
Circle area = { origin, radius };
stage_clear_hazards_predicate(proximity_predicate, &area, flags);
}

View file

@ -139,7 +139,7 @@ typedef enum ClearHazardsFlags {
} ClearHazardsFlags;
void stage_clear_hazards(ClearHazardsFlags flags);
void stage_clear_hazards_at(complex origin, double radius, ClearHazardsFlags flags);
void stage_clear_hazards_at(cmplx origin, double radius, ClearHazardsFlags flags);
void stage_clear_hazards_in_ellipse(Ellipse e, ClearHazardsFlags flags);
void stage_clear_hazards_predicate(bool (*predicate)(EntityInterface *ent, void *arg), void *arg, ClearHazardsFlags flags);

View file

@ -374,7 +374,7 @@ static void stage_draw_collision_areas(void) {
r_uniform_vec4("color_outer", 1, 1, 1, 0.1);
for(Projectile *p = global.projs.first; p; p = p->next) {
complex gsize = projectile_graze_size(p);
cmplx gsize = projectile_graze_size(p);
if(creal(gsize)) {
r_draw_sprite(&(SpriteParams) {
@ -657,8 +657,8 @@ static bool boss_distortion_rule(Framebuffer *fb) {
r_blend(BLEND_NONE);
r_disable(RCAP_DEPTH_TEST);
complex fpos = global.boss->pos;
complex pos = fpos + 15*cexp(I*global.frames/4.5);
cmplx fpos = global.boss->pos;
cmplx pos = fpos + 15*cexp(I*global.frames/4.5);
r_shader("boss_zoom");
r_uniform_vec2("blur_orig", creal(pos) / VIEWPORT_W, 1-cimag(pos) / VIEWPORT_H);
@ -742,7 +742,7 @@ static void apply_bg_shaders(ShaderRule *shaderrules, FBPair *fbos) {
fbpair_swap(fbos);
r_framebuffer(fbos->back);
complex pos = b->pos;
cmplx pos = b->pos;
float ratio = (float)VIEWPORT_H/VIEWPORT_W;
float delay;
@ -1542,7 +1542,7 @@ void stage_draw_bottom_text(void) {
static void fill_graph(int num_samples, float *samples, FPSCounter *fps) {
for(int i = 0; i < num_samples; ++i) {
samples[i] = fps->frametimes[i] / (2.0 * (HRTIME_RESOLUTION / (long double)FPS));
samples[i] = fps->frametimes[i] / (2.0 * (HRTIME_RESOLUTION / (float64x)FPS));
if(samples[i] > 1.0) {
samples[i] = 1.0;

View file

@ -72,15 +72,15 @@ static void cirno_icy(Boss *b, int time) {
return;
}
complex vel = (1+0.125*global.diff)*cexp(I*fmod(200*run,M_PI));
cmplx vel = (1+0.125*global.diff)*cexp(I*fmod(200*run,M_PI));
int c = 6;
double dr = 15;
FROM_TO_SND("shot1_loop", 0, 3*size, 3) {
for(int i = 0; i < c; i++) {
double ang = 2*M_PI/c*i+run*515;
complex phase = cexp(I*ang);
complex pos = b->pos+vel*t+dr*_i*phase;
cmplx phase = cexp(I*ang);
cmplx pos = b->pos+vel*t+dr*_i*phase;
PROJECTILE(
.proto = pp_crystal,
@ -105,11 +105,11 @@ static void cirno_icy(Boss *b, int time) {
int split = 3;
if(_i > split) {
complex pos0 = b->pos+vel*t+dr*split*phase;
cmplx pos0 = b->pos+vel*t+dr*split*phase;
for(int j = -1; j <= 1; j+=2) {
complex phase2 = cexp(I*M_PI/4*j)*phase;
complex pos2 = pos0+(dr*(_i-split))*phase2;
cmplx phase2 = cexp(I*M_PI/4*j)*phase;
cmplx pos2 = pos0+(dr*(_i-split))*phase2;
PROJECTILE(
.proto = pp_crystal,
@ -126,7 +126,7 @@ static void cirno_icy(Boss *b, int time) {
}
}
static Projectile* spawn_stain(complex pos, float angle, int to) {
static Projectile* spawn_stain(cmplx pos, float angle, int to) {
return PARTICLE(
.sprite = "stain",
.pos = pos,
@ -260,7 +260,7 @@ static void cirno_mid_flee(Boss *c, int time) {
}
}
Boss* stage1_spawn_cirno(complex pos) {
Boss* stage1_spawn_cirno(cmplx pos) {
Boss *cirno = create_boss("Cirno", "cirno", pos);
boss_set_portrait(cirno, get_sprite("dialog/cirno"), get_sprite("dialog/cirno_face_normal"));
cirno->shadowcolor = *RGBA_MUL_ALPHA(0.6, 0.7, 1.0, 0.25);
@ -489,7 +489,7 @@ static void halation_laser(Laser *l, int time) {
}
}
static complex halation_calc_orb_pos(complex center, float rotation, int proj, int projs) {
static cmplx halation_calc_orb_pos(cmplx center, float rotation, int proj, int projs) {
double f = (double)((proj % projs)+0.5)/projs;
return 200 * cexp(I*(rotation + f * 2 * M_PI)) + center;
}
@ -503,17 +503,17 @@ static int halation_orb(Projectile *p, int time) {
spawn_stain(p->pos, global.frames * 15, 20);
}
complex center = p->args[0];
cmplx center = p->args[0];
double rotation = p->args[1];
int id = creal(p->args[2]);
int count = cimag(p->args[2]);
int halate_time = creal(p->args[3]);
int phase_time = 60;
complex pos0 = halation_calc_orb_pos(center, rotation, id, count);
complex pos1 = halation_calc_orb_pos(center, rotation, id + count/2, count);
complex pos2 = halation_calc_orb_pos(center, rotation, id + count/2 - 1, count);
complex pos3 = halation_calc_orb_pos(center, rotation, id + count/2 - 2, count);
cmplx pos0 = halation_calc_orb_pos(center, rotation, id, count);
cmplx pos1 = halation_calc_orb_pos(center, rotation, id + count/2, count);
cmplx pos2 = halation_calc_orb_pos(center, rotation, id + count/2 - 1, count);
cmplx pos3 = halation_calc_orb_pos(center, rotation, id + count/2 - 2, count);
GO_TO(p, pos2, 0.1);
@ -580,7 +580,7 @@ void cirno_snow_halation(Boss *c, int time) {
// TODO: get rid of the "static" nonsense already! #ArgsForBossAttacks2017
// tfw it's 2018 and still no args
// tfw when you then add another static
static complex center;
static cmplx center;
static float rotation;
static int cheater;

View file

@ -22,6 +22,6 @@ void cirno_crystal_blizzard(Boss*, int);
void cirno_benchmark(Boss*, int);
void stage1_events(void);
Boss* stage1_spawn_cirno(complex pos);
Boss* stage1_spawn_cirno(cmplx pos);
#endif // IGUARD_stages_stage1_events_h

View file

@ -53,7 +53,7 @@ static int stage2_great_circle(Enemy *e, int t) {
for(n = 0; n < c; n++) {
complex dir = cexp(I*(2*M_PI/c*n+partdist*(_i%c2-c2/2)+bunchdist*(_i/c2)));
cmplx dir = cexp(I*(2*M_PI/c*n+partdist*(_i%c2-c2/2)+bunchdist*(_i/c2)));
PROJECTILE(
.proto = pp_rice,
@ -400,19 +400,19 @@ void hina_amulet(Boss *h, int time) {
TIMER(&t);
complex d = global.plr.pos - h->pos;
cmplx d = global.plr.pos - h->pos;
int loopduration = 200*(global.diff+0.5)/(D_Lunatic+0.5);
AT(0) {
aniplayer_queue_frames(&h->ani,"guruguru",loopduration);
}
FROM_TO_SND("shot1_loop", 0,loopduration,1) {
float f = _i/30.0;
complex n = cexp(I*2*M_PI*f+I*carg(d)+0.7*time/200*I)/sqrt(0.5+global.diff);
cmplx n = cexp(I*2*M_PI*f+I*carg(d)+0.7*time/200*I)/sqrt(0.5+global.diff);
float speed = 1.0 + 0.75 * max(0, (int)global.diff - D_Normal);
float accel = 1.0 + 1.20 * max(0, (int)global.diff - D_Normal);
complex p = h->pos+30*log(1+_i/2.0)*n;
cmplx p = h->pos+30*log(1+_i/2.0)*n;
ProjPrototype *t0 = pp_ball;
ProjPrototype *t1 = global.diff == D_Easy ? t0 : pp_crystal;
@ -531,7 +531,7 @@ void hina_bad_pick(Boss *h, int time) {
float cnt = (1+min(D_Normal,global.diff)) * 5;
for(j = 0; j < cnt; j++) {
complex o = VIEWPORT_W/SLOTS*(i + j/(cnt-1));
cmplx o = VIEWPORT_W/SLOTS*(i + j/(cnt-1));
PROJECTILE(
.proto = pp_ball,
@ -700,7 +700,7 @@ void hina_monty(Boss *h, int time) {
static short slave_pos, bad_pos, good_pos, plr_pos;
static int cwidth = VIEWPORT_W / 3.0;
static complex targetpos;
static cmplx targetpos;
if(time == EVENT_DEATH) {
enemy_kill_all(&global.enemies);
@ -732,7 +732,7 @@ void hina_monty(Boss *h, int time) {
do slave_pos = tsrand() % 3; while(slave_pos == plr_pos || slave_pos == good_pos);
while(bad_pos == slave_pos || bad_pos == good_pos) bad_pos = tsrand() % 3;
complex o = cwidth * (0.5 + slave_pos) + VIEWPORT_H/2.0*I - 200.0*I;
cmplx o = cwidth * (0.5 + slave_pos) + VIEWPORT_H/2.0*I - 200.0*I;
play_sound("laser1");
create_laserline_ab(h->pos, o, 15, 30, 60, RGBA(1.0, 0.3, 0.3, 0.0));
@ -760,7 +760,7 @@ void hina_monty(Boss *h, int time) {
float cnt = (2.0+global.diff) * 5;
for(int i = 0; i < cnt; i++) {
bool top = ((global.diff > D_Hard) && (_i % 2));
complex o = !top*VIEWPORT_H*I + cwidth*(bad_pos + i/(double)(cnt - 1));
cmplx o = !top*VIEWPORT_H*I + cwidth*(bad_pos + i/(double)(cnt - 1));
PROJECTILE(
.proto = pp_ball,
@ -801,7 +801,7 @@ void hina_monty(Boss *h, int time) {
p = 1.0 - p;
}
complex o = cwidth * (p + 0.5/(cnt-1) - 0.5) + h->pos;
cmplx o = cwidth * (p + 0.5/(cnt-1) - 0.5) + h->pos;
if(global.diff > D_Normal) {
PROJECTILE(
@ -860,7 +860,7 @@ void hina_spell_bg(Boss *h, int time) {
r_draw_sprite(&sp);
}
Boss* stage2_spawn_hina(complex pos) {
Boss* stage2_spawn_hina(cmplx pos) {
Boss *hina = create_boss("Kagiyama Hina", "hina", pos);
boss_set_portrait(hina, get_sprite("dialog/hina"), get_sprite("dialog/hina_face_normal"));
hina->glowcolor = *RGBA_MUL_ALPHA(0.7, 0.2, 0.3, 0.5);

View file

@ -20,6 +20,6 @@ void hina_wheel(Boss*, int);
void hina_monty(Boss*, int);
void stage2_events(void);
Boss* stage2_spawn_hina(complex pos);
Boss* stage2_spawn_hina(cmplx pos);
#endif // IGUARD_stages_stage2_events_h

View file

@ -50,7 +50,7 @@ static int stage3_enterswirl(Enemy *e, int t) {
int cnt = 24 - (D_Lunatic - global.diff) * 4;
for(int i = 0; i < cnt; ++i) {
double a = (M_PI * 2.0 * i) / cnt;
complex dir = cexp(I*a);
cmplx dir = cexp(I*a);
PROJECTILE(
.proto = e->args[1]? pp_ball : pp_rice,
@ -97,7 +97,7 @@ static int stage3_slavefairy(Enemy *e, int t) {
FROM_TO_SND("shot1_loop", 30, 120, 5 - global.diff) {
float a = _i * 0.5;
complex dir = cexp(I*a);
cmplx dir = cexp(I*a);
PROJECTILE(
.proto = pp_wave,
@ -151,7 +151,7 @@ static int stage3_slavefairy2(Enemy *e, int t) {
a *= -1;
}
complex dir = cexp(I*a);
cmplx dir = cexp(I*a);
PROJECTILE(
.proto = pp_wave,
.pos = e->pos,
@ -182,7 +182,7 @@ static void charge_effect(Enemy *e, int t, int chargetime) {
TIMER(&t);
FROM_TO(chargetime - 30, chargetime, 1) {
complex n = cexp(2.0*I*M_PI*frand());
cmplx n = cexp(2.0*I*M_PI*frand());
float l = 50*frand()+25;
float s = 4+_i*0.01;
@ -224,7 +224,7 @@ static int stage3_burstfairy(Enemy *e, int t) {
int cnt = 6 + 4 * global.diff;
for(int p = 0; p < cnt; ++p) {
complex dir = cexp(I*M_PI*2*p/cnt);
cmplx dir = cexp(I*M_PI*2*p/cnt);
PROJECTILE(
.proto = pp_ball,
.pos = e->args[0],
@ -249,7 +249,7 @@ static int stage3_burstfairy(Enemy *e, int t) {
FROM_TO_SND("shot1_loop", bursttime, bursttime + burstspan, step) {
double phase = (t - bursttime) / (double)burstspan;
complex dir = cexp(I*M_PI*phase);
cmplx dir = cexp(I*M_PI*phase);
int cnt = 5 + global.diff;
for(int p = 0; p < cnt; ++p) {
@ -330,9 +330,9 @@ static int stage3_chargefairy(Enemy *e, int t) {
charge_effect(e, t, chargetime);
FROM_TO_SND("shot1_loop", chargetime, chargetime + cnt * step - 1, step) {
complex aim = e->args[3] - e->pos;
cmplx aim = e->args[3] - e->pos;
aim /= cabs(aim);
complex aim_norm = -cimag(aim) + I*creal(aim);
cmplx aim_norm = -cimag(aim) + I*creal(aim);
int layers = 1 + global.diff;
int i = _i;
@ -344,8 +344,8 @@ static int stage3_chargefairy(Enemy *e, int t) {
double f = i / (cnt - 1.0);
int w = 100 - 20 * layer;
complex o = e->pos + w * psin(M_PI*f) * aim + aim_norm * w*0.8 * (f - 0.5);
complex paim = e->pos + (w+1) * aim - o;
cmplx o = e->pos + w * psin(M_PI*f) * aim + aim_norm * w*0.8 * (f - 0.5);
cmplx paim = e->pos + (w+1) * aim - o;
paim /= cabs(paim);
PROJECTILE(
@ -594,7 +594,7 @@ static void scuttle_lethbite(Boss *boss, int time) {
int cnt = 21 - 1 * (D_Lunatic - global.diff);
for(i = 0; i < cnt; ++i) {
complex v = (2 - psin((max(3, global.diff+1)*2*M_PI*i/(float)cnt) + time)) * cexp(I*2*M_PI/cnt*i);
cmplx v = (2 - psin((max(3, global.diff+1)*2*M_PI*i/(float)cnt) + time)) * cexp(I*2*M_PI/cnt*i);
PROJECTILE(
.proto = pp_wave,
.pos = boss->pos - v * 50,
@ -731,7 +731,7 @@ void wriggle_spellbg(Boss *b, int time) {
r_color4(1, 1, 1, 1);
}
Boss* stage3_spawn_scuttle(complex pos) {
Boss* stage3_spawn_scuttle(cmplx pos) {
Boss *scuttle = create_boss("Scuttle", "scuttle", pos);
boss_set_portrait(scuttle, get_sprite("dialog/scuttle"), get_sprite("dialog/scuttle_face_normal"));
scuttle->glowcolor = *RGB(0.5, 0.6, 0.3);
@ -791,8 +791,8 @@ static int wriggle_rocket_laserbullet(Projectile *p, int time) {
if(time >= creal(p->args[1])) {
if(p->args[2]) {
complex dist = global.plr.pos - p->pos;
complex accel = (0.1 + 0.2 * (global.diff / (float)D_Lunatic)) * dist / cabs(dist);
cmplx dist = global.plr.pos - p->pos;
cmplx accel = (0.1 + 0.2 * (global.diff / (float)D_Lunatic)) * dist / cabs(dist);
float deathtime = sqrt(2*cabs(dist)/cabs(accel));
Laser *l = create_lasercurve2c(p->pos, deathtime, deathtime, RGBA(0.4, 0.9, 1.0, 0.0), las_accel, 0, accel);
@ -873,7 +873,7 @@ static int wriggle_spell_slave(Enemy *e, int time) {
TIMER(&time)
float angle = e->args[2] * (time / 70.0 + e->args[1]);
complex dir = cexp(I*angle);
cmplx dir = cexp(I*angle);
Boss *boss = (Boss*)REF(e->args[0]);
if(!boss)
@ -1064,7 +1064,7 @@ void wriggle_night_ignite(Boss *boss, int time) {
float b = 0.3;
float c = 0.3;
complex vel = 2 * cexp(I*a);
cmplx vel = 2 * cexp(I*a);
double amp = M_PI/5;
double freq = 0.05;
@ -1139,7 +1139,7 @@ void wriggle_light_singularity(Boss *boss, int time) {
aofs = 0.7;
}
complex vel = 2 * cexp(I*(aofs + M_PI / 4 + M_PI * 2 * i / (double)cnt));
cmplx vel = 2 * cexp(I*(aofs + M_PI / 4 + M_PI * 2 * i / (double)cnt));
double amp = (4.0/cnt) * (M_PI/5.0);
double freq = 0.05;
@ -1184,7 +1184,7 @@ void wriggle_light_singularity(Boss *boss, int time) {
for(int i = 0; i < cnt; ++i) {
double a = ((M_PI*2.0*i)/cnt);
complex dir = cexp(I*a);
cmplx dir = cexp(I*a);
PROJECTILE(
.proto = ptype,
@ -1292,7 +1292,7 @@ void wriggle_firefly_storm(Boss *boss, int time) {
for(i = 0; i < cnt; ++i) {
float r = tanh(sin(_i/200.));
float v = lun ? cos(_i/150.)/pow(cosh(atanh(r)),2) : 0.5;
complex pos = 230*cexp(I*(_i*0.301+2*M_PI/cnt*i))*r;
cmplx pos = 230*cexp(I*(_i*0.301+2*M_PI/cnt*i))*r;
PROJECTILE(
.proto = (global.diff >= D_Hard) && !(i%10) ? pp_bigball : pp_ball,
@ -1313,7 +1313,7 @@ static int wriggle_nonspell_slave(Enemy *e, int time) {
int level = e->args[3];
float angle = e->args[2] * (time / 70.0 + e->args[1]);
complex dir = cexp(I*angle);
cmplx dir = cexp(I*angle);
Boss *boss = (Boss*)REF(e->args[0]);
if(!boss)
@ -1414,7 +1414,7 @@ static void stage3_boss_intro(Boss *boss, int time) {
GO_TO(boss, VIEWPORT_W/2.0 + 100.0*I, 0.03);
}
Boss* stage3_spawn_wriggle_ex(complex pos) {
Boss* stage3_spawn_wriggle_ex(cmplx pos) {
Boss *wriggle = create_boss("Wriggle EX", "wriggleex", pos);
boss_set_portrait(wriggle, get_sprite("dialog/wriggle"), get_sprite("dialog/wriggle_face_proud"));
wriggle->glowcolor = *RGBA_MUL_ALPHA(0.2, 0.4, 0.5, 0.5);
@ -1461,7 +1461,7 @@ void stage3_events(void) {
}
FROM_TO(800, 1000-30*(D_Lunatic-global.diff), 20) {
complex f = 5 + (0.93 + 0.01 * _i) * I;
cmplx f = 5 + (0.93 + 0.01 * _i) * I;
create_enemy3c(-20 + 20*I, 50, Swirl, stage3_bitchswirl, 5, 1*I, f);
create_enemy3c(VIEWPORT_W+20 + 20*I, 50, Swirl, stage3_bitchswirl, -5, 1*I, f);
}
@ -1473,8 +1473,8 @@ void stage3_events(void) {
FROM_TO(start, start + step * cnt - 1, step) {
int i = _i % cnt;
double span = 300 - 60 * (i/2);
complex pos1 = VIEWPORT_W/2;
complex pos2 = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
cmplx pos1 = VIEWPORT_W/2;
cmplx pos2 = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
create_enemy4c(pos1, 700, Fairy, stage3_burstfairy, pos2, i&1, 0, start + step * 6 - global.timer);
}
}
@ -1486,9 +1486,9 @@ void stage3_events(void) {
FROM_TO(start, start + cnt * step - 1, step) {
int i = _i % 4;
double span = 300 - 60 * (i/2);
complex pos = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
cmplx pos = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
complex exitdir = pos - (VIEWPORT_W+VIEWPORT_H*I)/2;
cmplx exitdir = pos - (VIEWPORT_W+VIEWPORT_H*I)/2;
exitdir /= cabs(exitdir);
create_enemy3c(pos, 1000, Fairy, stage3_chargefairy, pos, 30, exitdir);
@ -1511,8 +1511,8 @@ void stage3_events(void) {
if(global.enemies.first == NULL) {
int cnt = 2;
for(int i = 0; i <= cnt;i++) {
complex pos1 = VIEWPORT_W/2+VIEWPORT_W/3*nfrand() + VIEWPORT_H/5*I;
complex pos2 = VIEWPORT_W/2+50*(i-cnt/2)+VIEWPORT_H/3*I;
cmplx pos1 = VIEWPORT_W/2+VIEWPORT_W/3*nfrand() + VIEWPORT_H/5*I;
cmplx pos2 = VIEWPORT_W/2+50*(i-cnt/2)+VIEWPORT_H/3*I;
create_enemy3c(pos1, 700, Fairy, stage3_slavefairy2, pos2, i&1,0.5*(i-cnt/2));
}
}
@ -1532,10 +1532,10 @@ void stage3_events(void) {
AT(2400) {
double offs = -50;
complex p1 = 0+0*I;
complex p2 = VIEWPORT_W+0*I;
complex p3 = VIEWPORT_W+VIEWPORT_H*I;
complex p4 = 0+VIEWPORT_H*I;
cmplx p1 = 0+0*I;
cmplx p2 = VIEWPORT_W+0*I;
cmplx p3 = VIEWPORT_W+VIEWPORT_H*I;
cmplx p4 = 0+VIEWPORT_H*I;
create_enemy2c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs - offs*I, p2 + offs - offs*I);
create_enemy2c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs - offs*I, p3 + offs + offs*I);
@ -1546,10 +1546,10 @@ void stage3_events(void) {
if(global.diff > D_Normal) AT(2490) {
double offs = -50;
complex p1 = VIEWPORT_W/2+0*I;
complex p2 = VIEWPORT_W+VIEWPORT_H/2*I;
complex p3 = VIEWPORT_W/2+VIEWPORT_H*I;
complex p4 = 0+VIEWPORT_H/2*I;
cmplx p1 = VIEWPORT_W/2+0*I;
cmplx p2 = VIEWPORT_W+VIEWPORT_H/2*I;
cmplx p3 = VIEWPORT_W/2+VIEWPORT_H*I;
cmplx p4 = 0+VIEWPORT_H/2*I;
create_enemy2c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs*I, p2 + offs);
create_enemy2c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs, p3 + offs*I);
@ -1600,8 +1600,8 @@ void stage3_events(void) {
int cnt = 4;
int step = 60;
FROM_TO(3500 + midboss_time, 3500 + cnt * step - 1 + midboss_time, step) {
complex pos = VIEWPORT_W - VIEWPORT_W/3 + (VIEWPORT_H/5)*I;
complex spos = creal(pos) - 20 * I;
cmplx pos = VIEWPORT_W - VIEWPORT_W/3 + (VIEWPORT_H/5)*I;
cmplx spos = creal(pos) - 20 * I;
create_enemy3c(spos, 1000, Fairy, stage3_chargefairy, pos, 30, 2*I);
}
}
@ -1613,8 +1613,8 @@ void stage3_events(void) {
FROM_TO(start, start + step * cnt - 1, step) {
int i = _i % cnt;
double span = 300 - 60 * (1-i/2);
complex pos1 = VIEWPORT_W/2;
complex pos2 = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
cmplx pos1 = VIEWPORT_W/2;
cmplx pos2 = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
create_enemy4c(pos1, 3000, BigFairy, stage3_burstfairy, pos2, i&1, 0,
(start + 300 - global.timer) + I *
(30)
@ -1629,10 +1629,10 @@ void stage3_events(void) {
AT(4330 + midboss_time) {
double offs = -50;
complex p1 = 0+0*I;
complex p2 = VIEWPORT_W+0*I;
complex p3 = VIEWPORT_W+VIEWPORT_H*I;
complex p4 = 0+VIEWPORT_H*I;
cmplx p1 = 0+0*I;
cmplx p2 = VIEWPORT_W+0*I;
cmplx p3 = VIEWPORT_W+VIEWPORT_H*I;
cmplx p4 = 0+VIEWPORT_H*I;
create_enemy3c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs - offs*I, p2 + offs - offs*I, 1);
create_enemy3c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs - offs*I, p3 + offs + offs*I, 1);
@ -1643,10 +1643,10 @@ void stage3_events(void) {
if(global.diff > D_Normal) AT(4480 + midboss_time) {
double offs = -50;
complex p1 = VIEWPORT_W/2+0*I;
complex p2 = VIEWPORT_W+VIEWPORT_H/2*I;
complex p3 = VIEWPORT_W/2+VIEWPORT_H*I;
complex p4 = 0+VIEWPORT_H/2*I;
cmplx p1 = VIEWPORT_W/2+0*I;
cmplx p2 = VIEWPORT_W+VIEWPORT_H/2*I;
cmplx p3 = VIEWPORT_W/2+VIEWPORT_H*I;
cmplx p4 = 0+VIEWPORT_H/2*I;
create_enemy3c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs*I, p2 + offs, 0);
create_enemy3c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs, p3 + offs*I, 0);

View file

@ -23,8 +23,8 @@ void wriggle_firefly_storm(Boss*, int t);
void wriggle_light_singularity(Boss*, int t);
void stage3_events(void);
Boss* stage3_spawn_scuttle(complex pos);
Boss* stage3_spawn_wriggle_ex(complex pos);
Boss* stage3_spawn_scuttle(cmplx pos);
Boss* stage3_spawn_wriggle_ex(cmplx pos);
#define STAGE3_MIDBOSS_TIME 1765

View file

@ -88,7 +88,7 @@ static int stage4_fodder(Enemy *e, int t) {
e->pos += e->args[0];
FROM_TO(10, 200, 120) {
complex fairy_halfsize = 21 * (1 + I);
cmplx fairy_halfsize = 21 * (1 + I);
if(!rect_rect_intersect(
(Rect) { e->pos - fairy_halfsize, e->pos + fairy_halfsize },
@ -99,7 +99,7 @@ static int stage4_fodder(Enemy *e, int t) {
}
play_sound_ex("shot3", 5, false);
complex aim = global.plr.pos - e->pos;
cmplx aim = global.plr.pos - e->pos;
aim /= cabs(aim);
float speed = 3;
@ -166,7 +166,7 @@ static int stage4_partcircle(Enemy *e, int t) {
int i;
for(i = 0; i < global.diff; i++) {
play_sound("shot2");
complex n = cexp(I*M_PI/16.0*_i + I*carg(e->args[0])-I*M_PI/4.0 + 0.01*I*i*(1-2*(creal(e->args[0]) > 0)));
cmplx n = cexp(I*M_PI/16.0*_i + I*carg(e->args[0])-I*M_PI/4.0 + 0.01*I*i*(1-2*(creal(e->args[0]) > 0)));
PROJECTILE(
.proto = pp_wave,
.pos = e->pos + (30)*n,
@ -200,7 +200,7 @@ static int stage4_cardbuster(Enemy *e, int t) {
e->pos += (e->args[2]-e->args[1])/200.0;
int c = 40;
complex n = cexp(I*carg(global.plr.pos - e->pos) + 4*M_PI/(c+1)*I*_i);
cmplx n = cexp(I*carg(global.plr.pos - e->pos) + 4*M_PI/(c+1)*I*_i);
FROM_TO_SND("shot1_loop", 60, 60+c*global.diff, 1) {
for(int i = 0; i < 3; ++i) {
@ -248,7 +248,7 @@ static int stage4_backfire(Enemy *e, int t) {
FROM_TO(20,180+global.diff*20,2) {
play_sound("shot2");
complex n = cexp(I*M_PI*frand()-I*copysign(M_PI/2.0, creal(e->args[0])));
cmplx n = cexp(I*M_PI*frand()-I*copysign(M_PI/2.0, creal(e->args[0])));
for(int i = 0; i < global.diff; i++) {
PROJECTILE(
.proto = pp_wave,
@ -319,7 +319,7 @@ static int stage4_explosive(Enemy *e, int t) {
spawn_items(e->pos, ITEM_POWER, 1);
int n = 10*global.diff;
complex phase = global.plr.pos-e->pos;
cmplx phase = global.plr.pos-e->pos;
phase /= cabs(phase);
for(i = 0; i < n; i++) {
@ -351,7 +351,7 @@ static void KurumiSlave(Enemy *e, int t, bool render) {
}
if(!(t%2)) {
complex offset = (frand()-0.5)*30;
cmplx offset = (frand()-0.5)*30;
offset += (frand()-0.5)*20.0*I;
PARTICLE(
.sprite = "smoothdot",
@ -508,8 +508,8 @@ void kurumi_redspike(Boss *b, int time) {
FROM_TO_INT(80, 500, 40,200,2+2*(global.diff == D_Hard)) {
tsrand_fill(2);
complex offset = 100*afrand(0)*cexp(2.0*I*M_PI*afrand(1));
complex n = cexp(I*carg(global.plr.pos-b->pos-offset));
cmplx offset = 100*afrand(0)*cexp(2.0*I*M_PI*afrand(1));
cmplx n = cexp(I*carg(global.plr.pos-b->pos-offset));
PROJECTILE(
.proto = pp_rice,
.pos = b->pos+offset,
@ -550,7 +550,7 @@ static void kurumi_global_rule(Boss *b, int time) {
}
}
Boss* stage4_spawn_kurumi(complex pos) {
Boss* stage4_spawn_kurumi(cmplx pos) {
Boss* b = create_boss("Kurumi", "kurumi", pos);
boss_set_portrait(b, get_sprite("dialog/kurumi"), get_sprite("dialog/kurumi_face_normal"));
b->glowcolor = *RGB(0.5, 0.1, 0.0);
@ -620,7 +620,7 @@ static int stage4_supercard(Enemy *e, int t) {
FROM_TO(70, 70+20*global.diff, 1) {
play_sound_ex("shot1",5,false);
complex n = cexp(I*(2*M_PI/20.0*_i + (t / 150) * M_PI/4));
cmplx n = cexp(I*(2*M_PI/20.0*_i + (t / 150) * M_PI/4));
for(int i = -1; i <= 1 && t; i++) {
PROJECTILE(
.proto = pp_card,
@ -675,10 +675,10 @@ static void kurumi_breaker(Boss *b, int time) {
TIMER(&t);
FROM_TO_SND("shot1_loop", 50, 400, 50-7*global.diff) {
complex p = b->pos + 150*sin(_i) + 100.0*I*cos(_i);
cmplx p = b->pos + 150*sin(_i) + 100.0*I*cos(_i);
for(i = 0; i < c; i++) {
complex n = cexp(2.0*I*M_PI/c*i);
cmplx n = cexp(2.0*I*M_PI/c*i);
PROJECTILE(
.proto = pp_rice,
.pos = p,
@ -766,7 +766,7 @@ static int aniwall_slave(Enemy *e, int t) {
e->pos += e->args[2];
if(!(t % 7-global.diff-2*(global.diff > D_Normal))) {
complex v = e->args[2]/cabs(e->args[2])*I*sign(creal(e->args[0]));
cmplx v = e->args[2]/cabs(e->args[2])*I*sign(creal(e->args[0]));
if(cimag(v) > -0.1 || global.diff >= D_Normal) {
play_sound("shot1");
PROJECTILE(
@ -834,9 +834,9 @@ static void kurumi_sbreaker(Boss *b, int time) {
int kt = 40;
FROM_TO_SND("shot1_loop", 50, dur, 2+(global.diff < D_Hard)) {
complex p = b->pos + 150*sin(_i/8.0)+100.0*I*cos(_i/15.0);
cmplx p = b->pos + 150*sin(_i/8.0)+100.0*I*cos(_i/15.0);
complex n = cexp(2.0*I*M_PI/c*_i);
cmplx n = cexp(2.0*I*M_PI/c*_i);
PROJECTILE(
.proto = pp_rice,
.pos = p,
@ -966,7 +966,7 @@ void kurumi_blowwall(Boss *b, int time) {
}
static Projectile* vapor_particle(complex pos, const Color *clr) {
static Projectile* vapor_particle(cmplx pos, const Color *clr) {
return PARTICLE(
.sprite = "stain",
.color = clr,
@ -1050,7 +1050,7 @@ static int kdanmaku_slave(Enemy *e, int t) {
float speed = 1.5+0.1*global.diff;
for(i = 0; i < n; i++) {
complex p = VIEWPORT_W/(float)n*(i+psin(t*t*i*i+t*t)) + I*cimag(e->pos);
cmplx p = VIEWPORT_W/(float)n*(i+psin(t*t*i*i+t*t)) + I*cimag(e->pos);
if(cabs(p-global.plr.pos) > 60) {
PROJECTILE(
.proto = pp_thickrice,
@ -1134,7 +1134,7 @@ static int kurumi_extra_dead_shield(Enemy *e, int time) {
if(!(time % 6)) {
// complex dir = cexp(I*(M_PI * 0.5 * nfrand() + carg(global.plr.pos - e->pos)));
// complex dir = cexp(I*(carg(global.plr.pos - e->pos)));
complex dir = cexp(I*creal(e->args[0]));
cmplx dir = cexp(I*creal(e->args[0]));
PROJECTILE(
.proto = pp_rice,
.pos = e->pos,
@ -1151,7 +1151,7 @@ static int kurumi_extra_dead_shield(Enemy *e, int time) {
if(kurumi_extra_shield_expire(e, time)) {
int cnt = 10;
for(int i = 0; i < cnt; ++i) {
complex dir = cexp(I*M_PI*2*i/(double)cnt);
cmplx dir = cexp(I*M_PI*2*i/(double)cnt);
tsrand_fill(2);
PROJECTILE(
.proto = pp_ball,
@ -1202,9 +1202,9 @@ static int kurumi_extra_bigfairy1(Enemy *e, int time) {
FROM_TO(50,escapetime,60) {
int count = 5;
complex phase = cexp(I*2*M_PI*frand());
cmplx phase = cexp(I*2*M_PI*frand());
for(int i = 0; i < count; i++) {
complex arg = cexp(I*2*M_PI*i/count);
cmplx arg = cexp(I*2*M_PI*i/count);
if(global.diff == D_Lunatic)
arg *= phase;
create_lasercurve2c(e->pos, 20, 200, RGBA(1.0, 0.3, 0.7, 0.0), las_accel, arg, 0.1*arg);
@ -1224,8 +1224,8 @@ static int kurumi_extra_bigfairy1(Enemy *e, int time) {
}
static void kurumi_extra_drainer_draw(Projectile *p, int time) {
complex org = p->pos;
complex targ = p->args[1];
cmplx org = p->pos;
cmplx targ = p->args[1];
double a = 0.5 * creal(p->args[2]);
Texture *tex = get_tex("part/sinewave");
@ -1351,14 +1351,14 @@ static int kurumi_extra_fairy(Enemy *e, int t) {
int attacktime = creal(e->args[1]);
int flytime = cimag(e->args[1]);
FROM_TO_SND("shot1_loop", attacktime-20,attacktime+20,20) {
complex vel = cexp(I*frand()*2*M_PI)*(2+0.1*(global.diff-D_Easy));
cmplx vel = cexp(I*frand()*2*M_PI)*(2+0.1*(global.diff-D_Easy));
if(e->args[2] == 0) { // attack type
int corners = 5;
double len = 50;
int count = 5;
for(int i = 0; i < corners; i++) {
for(int j = 0; j < count; j++) {
complex pos = len/2/tan(2*M_PI/corners)*I+(j/(double)count-0.5)*len;
cmplx pos = len/2/tan(2*M_PI/corners)*I+(j/(double)count-0.5)*len;
pos *= cexp(I*2*M_PI/corners*i);
PROJECTILE(
.proto = pp_flea,
@ -1374,7 +1374,7 @@ static int kurumi_extra_fairy(Enemy *e, int t) {
double rad = 20;
for(int j = 0; j < count; j++) {
double x = (j/(double)count-0.5)*2*M_PI;
complex pos = 0.5*cos(x)+sin(2*x) + (0.5*sin(x)+cos(2*x))*I;
cmplx pos = 0.5*cos(x)+sin(2*x) + (0.5*sin(x)+cos(2*x))*I;
pos*=vel/cabs(vel);
PROJECTILE(
.proto = pp_flea,
@ -1450,7 +1450,7 @@ void kurumi_extra(Boss *b, int time) {
if(b->current->hp < castlimit)
b->current->hp = castlimit;
tsrand_fill(2);
complex pos = VIEWPORT_W/2*afrand(0)+I*afrand(1)*VIEWPORT_H*2/3;
cmplx pos = VIEWPORT_W/2*afrand(0)+I*afrand(1)*VIEWPORT_H*2/3;
if(direction)
pos = VIEWPORT_W-creal(pos)+I*cimag(pos);
// immune so they dont get killed while they are still offscreen.
@ -1461,7 +1461,7 @@ void kurumi_extra(Boss *b, int time) {
play_sound("shot_special1");
}
complex sidepos = VIEWPORT_W * (0.5+0.3*(1-2*direction)) + VIEWPORT_H * 0.28 * I;
cmplx sidepos = VIEWPORT_W * (0.5+0.3*(1-2*direction)) + VIEWPORT_H * 0.28 * I;
FROM_TO(90,120,1) {
GO_TO(b, sidepos,0.1)
}
@ -1482,8 +1482,8 @@ void kurumi_extra(Boss *b, int time) {
if(global.diff >= D_Hard) {
AT(300) {
double ofs = VIEWPORT_W * 0.5;
complex pos = 0.5 * VIEWPORT_W + I * (VIEWPORT_H - 100);
complex targ = 0.5 *VIEWPORT_W + VIEWPORT_H * 0.3 * I;
cmplx pos = 0.5 * VIEWPORT_W + I * (VIEWPORT_H - 100);
cmplx targ = 0.5 *VIEWPORT_W + VIEWPORT_H * 0.3 * I;
create_enemy1c(pos + ofs, 3300, kurumi_extra_bigfairy_visual, kurumi_extra_bigfairy1, targ + 0.8*ofs);
create_enemy1c(pos - ofs, 3300, kurumi_extra_bigfairy_visual, kurumi_extra_bigfairy1, targ - 0.8*ofs);
}
@ -1544,11 +1544,11 @@ static int scythe_post_mid(Enemy *e, int t) {
double alpha = scale * scale;
double spin = (0.2 + 0.2 * (1.0 - alpha)) * 1.5;
complex opos = VIEWPORT_W/2+160*I;
cmplx opos = VIEWPORT_W/2+160*I;
double targ = (t-300) * (0.5 + psin(t/300.0));
double w = min(0.15, 0.0001*targ);
complex pofs = 150*cos(w*targ+M_PI/2.0) + I*80*sin(2*w*targ);
cmplx pofs = 150*cos(w*targ+M_PI/2.0) + I*80*sin(2*w*targ);
pofs += ((VIEWPORT_W/2+VIEWPORT_H/2*I - opos) * (global.diff - D_Easy)) / (D_Lunatic - D_Easy);
e->pos = opos + pofs * (1.0 - clamp((t - (fleetime - 120)) / 60.0, 0.0, 1.0)) * smooth(smooth(scale));
@ -1556,8 +1556,8 @@ static int scythe_post_mid(Enemy *e, int t) {
e->args[1] = creal(e->args[1]) + spin * I;
FROM_TO(90, fleetime - 120, 1) {
complex shotorg = e->pos+80*cexp(I*creal(e->args[1]));
complex shotdir = cexp(I*creal(e->args[1]));
cmplx shotorg = e->pos+80*cexp(I*creal(e->args[1]));
cmplx shotdir = cexp(I*creal(e->args[1]));
struct projentry { ProjPrototype *proj; char *snd; } projs[] = {
{ pp_ball, "shot1"},

View file

@ -22,7 +22,7 @@ void kurumi_danmaku(Boss*, int);
void kurumi_extra(Boss*, int);
void stage4_events(void);
Boss* stage4_spawn_kurumi(complex pos);
Boss* stage4_spawn_kurumi(cmplx pos);
#define STAGE4_MIDBOSS_TIME 3724
#define STAGE4_MIDBOSS_MUSIC_TIME 2818

View file

@ -94,7 +94,7 @@ static int stage5_lightburst(Enemy *e, int t) {
FROM_TO_SND("shot1_loop", 20, 300, 5) {
int c = 5+global.diff;
for(int i = 0; i < c; i++) {
complex n = cexp(I*carg(global.plr.pos) + 2.0*I*M_PI/c*i);
cmplx n = cexp(I*carg(global.plr.pos) + 2.0*I*M_PI/c*i);
PROJECTILE(
.proto = pp_ball,
.pos = e->pos + 50*n*cexp(-0.4*I*_i*global.diff),
@ -154,7 +154,7 @@ static int stage5_limiter(Enemy *e, int t) {
for(int i = 1; i >= -1; i -= 2) {
double a = i * 0.2 - 0.1 * (global.diff / 4) + i * 3.0 / (_i + 1);
complex aim = cexp(I * (base_angle + a));
cmplx aim = cexp(I * (base_angle + a));
PROJECTILE(
.proto = pp_rice,
@ -185,7 +185,7 @@ static int stage5_laserfairy(Enemy *e, int t) {
e->pos -= e->args[0];
FROM_TO(100, 700, (7-global.diff)*(1+(int)creal(e->args[1]))) {
complex n = cexp(I*carg(global.plr.pos-e->pos)+(0.2-0.02*global.diff)*I*_i);
cmplx n = cexp(I*carg(global.plr.pos-e->pos)+(0.2-0.02*global.diff)*I*_i);
float fac = (0.5+0.2*global.diff);
create_lasercurve2c(e->pos, 100, 300, RGBA(0.7, 0.3, 1, 0), las_accel, fac*4*n, fac*0.05*n);
PROJECTILE(
@ -225,7 +225,7 @@ static int stage5_miner(Enemy *e, int t) {
return 1;
}
static void lightning_particle(complex pos, int t) {
static void lightning_particle(cmplx pos, int t) {
if(!(t % 5)) {
char *part = frand() > 0.5 ? "lightning0" : "lightning1";
PARTICLE(
@ -252,7 +252,7 @@ static int stage5_magnetto(Enemy *e, int t) {
return 1;
}
complex offset = (frand()-0.5)*10 + (frand()-0.5)*10.0*I;
cmplx offset = (frand()-0.5)*10 + (frand()-0.5)*10.0*I;
lightning_particle(e->pos + 3*offset, t);
FROM_TO(0, 70, 1) {
@ -273,7 +273,7 @@ static int stage5_magnetto(Enemy *e, int t) {
// complex dir = cexp(I*carg(global.plr.pos - e->pos));
for(int i = 0; i < 2 - (global.diff == D_Easy); ++i) {
complex dir = cexp(I*(M_PI*i + M_PI/8*sin(2*(t-140)/70.0 * M_PI) + carg(e->args[1] - e->pos)));
cmplx dir = cexp(I*(M_PI*i + M_PI/8*sin(2*(t-140)/70.0 * M_PI) + carg(e->args[1] - e->pos)));
PROJECTILE(
.proto = pp_ball,
@ -374,7 +374,7 @@ static void iku_slave_visual(Enemy *e, int t, bool render) {
return;
}
complex offset = (frand()-0.5)*10 + (frand()-0.5)*10.0*I;
cmplx offset = (frand()-0.5)*10 + (frand()-0.5)*10.0*I;
if(e->args[2] && !(t % 5)) {
lightning_particle(e->pos + 3*offset, t);
@ -451,7 +451,7 @@ static int stage5_lightburst2(Enemy *e, int t) {
int c = 4+global.diff-(global.diff==D_Easy);
for(i = 0; i < c; i++) {
tsrand_fill(2);
complex n = cexp(I*carg(global.plr.pos-e->pos) + 2.0*I*M_PI/c*i);
cmplx n = cexp(I*carg(global.plr.pos-e->pos) + 2.0*I*M_PI/c*i);
PROJECTILE(
.proto = pp_bigball,
.pos = e->pos + 50*n*cexp(-1.0*I*_i*global.diff),
@ -482,7 +482,7 @@ static int stage5_superbullet(Enemy *e, int t) {
}
FROM_TO(60, 200, 1) {
complex n = cexp(I*M_PI*sin(_i/(8.0+global.diff)+frand()*0.1)+I*carg(global.plr.pos-e->pos));
cmplx n = cexp(I*M_PI*sin(_i/(8.0+global.diff)+frand()*0.1)+I*carg(global.plr.pos-e->pos));
PROJECTILE(
.proto = pp_bullet,
.pos = e->pos + 50*n,
@ -582,8 +582,8 @@ void iku_atmospheric(Boss *b, int time) {
FROM_TO(0, 500, 23-2*global.diff) {
tsrand_fill(4);
complex p1 = VIEWPORT_W*afrand(0) + VIEWPORT_H/2*I*afrand(1);
complex p2 = p1 + (120+20*global.diff)*cexp(0.5*I-afrand(2)*I)*(1-2*(afrand(3) > 0.5));
cmplx p1 = VIEWPORT_W*afrand(0) + VIEWPORT_H/2*I*afrand(1);
cmplx p2 = p1 + (120+20*global.diff)*cexp(0.5*I-afrand(2)*I)*(1-2*(afrand(3) > 0.5));
int i;
int c = 6+global.diff;
@ -626,7 +626,7 @@ void iku_atmospheric(Boss *b, int time) {
}
}
static complex bolts2_laser(Laser *l, float t) {
static cmplx bolts2_laser(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/iku_lightning");
return 0;
@ -763,7 +763,7 @@ void iku_lightning(Boss *b, int time) {
}
FROM_TO(0, 60, 1) {
complex n = cexp(2.0*I*M_PI*frand());
cmplx n = cexp(2.0*I*M_PI*frand());
float l = 150*frand()+50;
float s = 4+_i*0.01;
float alpha = 0.5;
@ -803,7 +803,7 @@ void iku_lightning(Boss *b, int time) {
int s = 10;
for(int i=0; i < c; i++) {
complex n = cexp(2.0*I*M_PI*frand());
cmplx n = cexp(2.0*I*M_PI*frand());
PARTICLE(
.sprite = "smoke",
.pos = b->pos,
@ -835,7 +835,7 @@ static void iku_bolts3(Boss *b, int time) {
aniplayer_queue(&b->ani, (_i&1) ? "dashdown_left" : "dashdown_right",1);
aniplayer_queue(&b->ani, "main", 0);
int i, c = 10+global.diff;
complex n = cexp(I*carg(global.plr.pos-b->pos)+0.1*I-0.2*I*frand());
cmplx n = cexp(I*carg(global.plr.pos-b->pos)+0.1*I-0.2*I*frand());
for(i = 0; i < c; i++) {
PROJECTILE(
.proto = pp_ball,
@ -872,7 +872,7 @@ static void iku_bolts3(Boss *b, int time) {
}
static complex induction_bullet_traj(Projectile *p, float t) {
static cmplx induction_bullet_traj(Projectile *p, float t) {
return p->pos0 + p->args[0]*t*cexp(p->args[1]*t);
}
@ -901,7 +901,7 @@ static int induction_bullet(Projectile *p, int time) {
return 1;
}
static complex cathode_laser(Laser *l, float t) {
static cmplx cathode_laser(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->shader = r_shader_get_optional("lasers/iku_cathode");
return 0;
@ -951,7 +951,7 @@ void iku_cathode(Boss *b, int t) {
void iku_induction(Boss *b, int t) {
// thwarf safespots
complex ofs = global.diff > D_Normal ? 10*I : 0;
cmplx ofs = global.diff > D_Normal ? 10*I : 0;
GO_TO(b, VIEWPORT_W/2+200.0*I + ofs, 0.03);
@ -996,11 +996,11 @@ void iku_induction(Boss *b, int t) {
void iku_spell_bg(Boss *b, int t);
static Enemy* iku_extra_find_next_slave(complex from, double playerbias) {
static Enemy* iku_extra_find_next_slave(cmplx from, double playerbias) {
Enemy *nearest = NULL, *e;
double dist, mindist = INFINITY;
complex org = from + playerbias * cexp(I*(carg(global.plr.pos - from)));
cmplx org = from + playerbias * cexp(I*(carg(global.plr.pos - from)));
for(e = global.enemies.first; e; e = e->next) {
if(e->args[2]) {
@ -1026,7 +1026,7 @@ static void iku_extra_slave_visual(Enemy *e, int t, bool render) {
}
if(e->args[2] && !(t % 5)) {
complex offset = (frand()-0.5)*30 + (frand()-0.5)*20.0*I;
cmplx offset = (frand()-0.5)*30 + (frand()-0.5)*20.0*I;
PARTICLE(
.sprite = "smoothdot",
.pos = offset,
@ -1075,7 +1075,7 @@ static int iku_extra_trigger_bullet(Projectile *p, int t) {
if(creal(p->args[2]) == 0) {
int cnt = 6 + 2 * global.diff;
for(int i = 0; i < cnt; ++i) {
complex dir = cexp(I*(t + i*2*M_PI/cnt));
cmplx dir = cexp(I*(t + i*2*M_PI/cnt));
PROJECTILE(
.proto = pp_bigball,
@ -1156,7 +1156,7 @@ static int iku_extra_slave(Enemy *e, int t) {
}
if(global.frames == creal(e->args[3])) {
complex o2 = e->args[2];
cmplx o2 = e->args[2];
e->args[2] = 0;
Enemy *new = iku_extra_find_next_slave(e->pos, 75);
e->args[2] = o2;
@ -1255,7 +1255,7 @@ void iku_extra(Boss *b, int t) {
for(i = 0; i < cnt; ++i) {
for(j = 0; j < cnt; ++j) {
complex epos = step * (0.5 + i) + (step * j + 125) * I;
cmplx epos = step * (0.5 + i) + (step * j + 125) * I;
create_enemy4c(b->pos, ENEMY_IMMUNE, iku_extra_slave_visual, iku_extra_slave, epos, 0, 0, 1);
}
}
@ -1266,7 +1266,7 @@ void iku_extra(Boss *b, int t) {
}
}
Boss* stage5_spawn_iku(complex pos) {
Boss* stage5_spawn_iku(cmplx pos) {
Boss *b = create_boss("Nagae Iku", "iku", pos);
boss_set_portrait(b, get_sprite("dialog/iku"), get_sprite("dialog/iku_face_normal"));
b->glowcolor = *RGBA_MUL_ALPHA(0.2, 0.4, 0.5, 0.5);
@ -1434,10 +1434,10 @@ void stage5_events(void) {
double ofs = 42*2;
FROM_TO(5620, 5620 + step*cnt-1, step) {
complex src1 = -ofs/4 + (-ofs/4 + _i * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
complex src2 = (VIEWPORT_W + ofs/4) + (-ofs/4 + (cnt-_i-1) * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
complex dst1 = ofs + ( ofs + _i * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
complex dst2 = (VIEWPORT_W - ofs) + ( ofs + (cnt-_i-1) * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
cmplx src1 = -ofs/4 + (-ofs/4 + _i * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
cmplx src2 = (VIEWPORT_W + ofs/4) + (-ofs/4 + (cnt-_i-1) * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
cmplx dst1 = ofs + ( ofs + _i * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
cmplx dst2 = (VIEWPORT_W - ofs) + ( ofs + (cnt-_i-1) * (VIEWPORT_H-2*ofs)/(cnt-1))*I;
create_enemy2c(src1, 2000, Swirl, stage5_magnetto, dst1, dst2);
create_enemy2c(src2, 2000, Swirl, stage5_magnetto, dst2, dst1);

View file

@ -21,6 +21,6 @@ void iku_induction(Boss*, int);
void iku_extra(Boss*, int);
void stage5_events(void);
Boss* stage5_spawn_iku(complex pos);
Boss* stage5_spawn_iku(cmplx pos);
#endif // IGUARD_stages_stage5_events_h

View file

@ -46,7 +46,7 @@ static int stage6_hacker(Enemy *e, int t) {
FROM_TO_SND("shot1_loop",100, 180+40*global.diff, 3) {
int i;
for(i = 0; i < 6; i++) {
complex n = sin(_i*0.2)*cexp(I*0.3*(i/2-1))*(1-2*(i&1));
cmplx n = sin(_i*0.2)*cexp(I*0.3*(i/2-1))*(1-2*(i&1));
PROJECTILE(
.proto = pp_wave,
.pos = e->pos + 120*n,
@ -150,7 +150,7 @@ void scythe_common(Enemy *e, int t) {
static int scythe_mid(Enemy *e, int t) {
TIMER(&t);
complex n;
cmplx n;
if(t < 0) {
scythe_common(e, t);
@ -457,7 +457,7 @@ void elly_newton(Boss *b, int t) {
case 2: c = *RGB(0.8, 0.6, 0.0); break;
}
complex apple_pos = clamp(creal(global.plr.pos) + nfrand() * 64, apple->w*0.5, VIEWPORT_W - apple->w*0.5);
cmplx apple_pos = clamp(creal(global.plr.pos) + nfrand() * 64, apple->w*0.5, VIEWPORT_W - apple->w*0.5);
PROJECTILE(
.pos = apple_pos,
@ -537,7 +537,7 @@ static int kepler_bullet(Projectile *p, int t) {
return ACTION_ACK;
}
complex pos = p->pos0;
cmplx pos = p->pos0;
if(tier != 0) {
Projectile *parent = (Projectile *) REF(creal(p->args[2]));
@ -551,15 +551,15 @@ static int kepler_bullet(Projectile *p, int t) {
pos += t*p->args[2];
}
complex newpos = pos + tanh(t/90.)*p->args[0]*cexp((1-2*(tier&1))*I*t*0.5/cabs(p->args[0]));
complex vel = newpos-p->pos;
cmplx newpos = pos + tanh(t/90.)*p->args[0]*cexp((1-2*(tier&1))*I*t*0.5/cabs(p->args[0]));
cmplx vel = newpos-p->pos;
p->pos = newpos;
p->args[3] = vel;
if(t%(30-5*global.diff) == 0) {
p->args[1]+=1*I;
int tau = global.frames-global.boss->current->starttime;
complex phase = cexp(I*0.2*tau*tau);
cmplx phase = cexp(I*0.2*tau*tau);
int n = global.diff/2+3+(frand()>0.3);
if(global.diff == D_Easy)
n=7;
@ -612,7 +612,7 @@ void elly_kepler(Boss *b, int t) {
int c = 2;
play_sound("shot_special1");
for(int i = 0; i < c; i++) {
complex n = cexp(I*2*M_PI/c*i+I*0.6*_i);
cmplx n = cexp(I*2*M_PI/c*i+I*0.6*_i);
PROJECTILE(
.proto = kepler_pick_bullet(0),
@ -644,7 +644,7 @@ static void elly_frequency2(Boss *b, int t) {
}
FROM_TO_SND("shot1_loop",0, 2000, 3-global.diff/2) {
complex n = sin(t*0.12*global.diff)*cexp(t*0.02*I*global.diff);
cmplx n = sin(t*0.12*global.diff)*cexp(t*0.02*I*global.diff);
PROJECTILE(
.proto = pp_plainball,
.pos = b->pos+80*n,
@ -655,7 +655,7 @@ static void elly_frequency2(Boss *b, int t) {
}
}
static complex maxwell_laser(Laser *l, float t) {
static cmplx maxwell_laser(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->unclearable = true;
l->shader = r_shader_get_optional("lasers/maxwell");
@ -695,7 +695,7 @@ void elly_maxwell(Boss *b, int t) {
}
static void draw_baryon_connector(complex a, complex b) {
static void draw_baryon_connector(cmplx a, cmplx b) {
Sprite *spr = get_sprite("stage6/baryon_connector");
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = spr,
@ -847,7 +847,7 @@ static void BaryonCenter(Enemy *bcenter, int t, bool render) {
for(Enemy *e = global.enemies.first; e; e = e->next) {
if(e->visual_rule == Baryon) {
complex p = e->pos;//+10*frand()*cexp(2.0*I*M_PI*frand());
cmplx p = e->pos;//+10*frand()*cexp(2.0*I*M_PI*frand());
r_draw_sprite(&(SpriteParams) {
.sprite = "part/myon",
@ -933,7 +933,7 @@ static int scythe_explode(Enemy *e, int t) {
return 1;
}
void elly_spawn_baryons(complex pos) {
void elly_spawn_baryons(cmplx pos) {
int i;
Enemy *e, *last = NULL, *first = NULL, *middle = NULL;
@ -1028,7 +1028,7 @@ static int baryon_eigenstate(Enemy *e, int t) {
play_sound("shot_special1");
play_sound_delayed("redirect",4,true,60);
for(i = 0; i < c; i++) {
complex n = cexp(2.0*I*_i+I*M_PI/2+I*creal(e->args[2]));
cmplx n = cexp(2.0*I*_i+I*M_PI/2+I*creal(e->args[2]));
for(j = 0; j < 3; j++) {
PROJECTILE(
.proto = pp_plainball,
@ -1056,7 +1056,7 @@ static int baryon_reset(Enemy *baryon, int t) {
for(Enemy *e = global.enemies.first; e; e = e->next) {
if(e->visual_rule == BaryonCenter) {
complex targ_pos = baryon->pos0 - e->pos0 + e->pos;
cmplx targ_pos = baryon->pos0 - e->pos0 + e->pos;
GO_TO(baryon, targ_pos, 0.1);
return 1;
@ -1103,7 +1103,7 @@ static int broglie_particle(Projectile *p, int t) {
Laser *laser = (Laser*)REF(p->args[0]);
if(laser) {
complex oldpos = p->pos;
cmplx oldpos = p->pos;
p->pos = laser->prule(laser, min(t, cimag(p->args[1])));
if(oldpos != p->pos) {
@ -1185,7 +1185,7 @@ static int broglie_charge(Projectile *p, int t) {
double hue = creal(p->args[3]);
p->pos -= p->args[0] * 15;
complex aim = cexp(I*p->angle);
cmplx aim = cexp(I*p->angle);
double s_ampl = 30 + 2 * attack_num;
double s_freq = 0.10 + 0.01 * attack_num;
@ -1224,14 +1224,14 @@ static int broglie_charge(Projectile *p, int t) {
return ACTION_DESTROY;
} else {
float f = pow(clamp((140 - (firetime - t)) / 90.0, 0, 1), 8);
complex o = p->pos - p->args[0] * 15;
cmplx o = p->pos - p->args[0] * 15;
p->args[0] *= cexp(I*M_PI*0.2*f);
p->pos = o + p->args[0] * 15;
if(f > 0.1) {
play_loop("charge_generic");
complex n = cexp(2.0*I*M_PI*frand());
cmplx n = cexp(2.0*I*M_PI*frand());
float l = 50*frand()+25;
float s = 4+f;
@ -1303,7 +1303,7 @@ static int baryon_broglie(Enemy *e, int t) {
FROM_TO(delay, delay + step * cnt - 1, step) {
double a = 2*M_PI * (0.25 + 1.0/cnt*_i);
complex n = cexp(I*a);
cmplx n = cexp(I*a);
double hue = (attack_num * M_PI + a + M_PI/6) / (M_PI*2);
PROJECTILE(
@ -1323,7 +1323,7 @@ static int baryon_broglie(Enemy *e, int t) {
}
if(t < delay /*|| t > delay + fire_delay*/) {
complex target_pos = global.boss->pos + 100 * cexp(I*carg(global.plr.pos - global.boss->pos));
cmplx target_pos = global.boss->pos + 100 * cexp(I*carg(global.plr.pos - global.boss->pos));
GO_TO(e, target_pos, 0.03);
}
@ -1348,7 +1348,7 @@ void elly_broglie(Boss *b, int t) {
int period = BROGLIE_PERIOD;
double ofs = 100;
complex positions[] = {
cmplx positions[] = {
VIEWPORT_W-ofs + ofs*I,
VIEWPORT_W-ofs + ofs*I,
ofs + (VIEWPORT_H-ofs)*I,
@ -1358,7 +1358,7 @@ void elly_broglie(Boss *b, int t) {
};
if(t/period > 0) {
GO_TO(b, positions[(t/period) % (sizeof(positions)/sizeof(complex))], 0.02);
GO_TO(b, positions[(t/period) % (sizeof(positions)/sizeof(cmplx))], 0.02);
}
}
@ -1491,7 +1491,7 @@ static int baryon_ricci(Enemy *e, int t) {
GO_TO(e, global.plr.pos, 0.1);
} else {
float s = 1.00 + 0.25 * (global.diff - D_Easy);
complex d = e->pos - VIEWPORT_W/2-VIEWPORT_H*I*2/3 + 100*sin(s*t/200.)+25*I*cos(s*t*3./500.);
cmplx d = e->pos - VIEWPORT_W/2-VIEWPORT_H*I*2/3 + 100*sin(s*t/200.)+25*I*cos(s*t*3./500.);
e->pos += -0.5*d/cabs(d);
}
} else {
@ -1511,7 +1511,7 @@ static int baryon_ricci(Enemy *e, int t) {
if(phase < 0.55 && phase > 0.15) {
FROM_TO(150,100000,10) {
int c = 3;
complex n = cexp(2*M_PI*I * (0.25 + 1.0/c*_i));
cmplx n = cexp(2*M_PI*I * (0.25 + 1.0/c*_i));
PROJECTILE(
.proto = pp_ball,
.pos = 15*n,
@ -1552,7 +1552,7 @@ static int ricci_proj(Projectile *p, int t) {
int time = global.frames-global.boss->current->starttime;
complex shift = 0;
cmplx shift = 0;
p->pos = p->pos0 + p->args[0]*t;
double influence = 0;
@ -1566,7 +1566,7 @@ static int ricci_proj(Projectile *p, int t) {
if(num % 2 == 0) {
double radius = SAFE_RADIUS(e);
complex d = e->pos-p->pos;
cmplx d = e->pos-p->pos;
float s = 1.00 + 0.25 * (global.diff - D_Easy);
int gaps = SAFE_RADIUS_PHASE_NUM(e) + 5;
double r = cabs(d)/(1.0-0.15*sin(gaps*carg(d)+0.01*s*time));
@ -1620,7 +1620,7 @@ void elly_ricci(Boss *b, int t) {
w *= (1 + 2.0 / c);
for(int i = 0; i < c; i++) {
complex pos = ofs + fmod(w/(float)c*(i+0.5*_i),w) + (VIEWPORT_H+10)*I;
cmplx pos = ofs + fmod(w/(float)c*(i+0.5*_i),w) + (VIEWPORT_H+10)*I;
PROJECTILE(
.proto = pp_ball,
@ -1673,7 +1673,7 @@ static void elly_baryonattack2(Boss *b, int t) {
for(int i = 0; i < cnt; ++i) {
float a = M_PI/4;
a = a * (i/(float)cnt) - a/2;
complex n = cexp(I*(a+carg(global.plr.pos-b->pos)));
cmplx n = cexp(I*(a+carg(global.plr.pos-b->pos)));
for(int j = 0; j < 3; ++j) {
PROJECTILE(
@ -1688,7 +1688,7 @@ static void elly_baryonattack2(Boss *b, int t) {
} else {
int x, y;
int w = 1+(global.diff > D_Normal);
complex n = cexp(I*carg(global.plr.pos-b->pos));
cmplx n = cexp(I*carg(global.plr.pos-b->pos));
for(x = -w; x <= w; x++) {
for(y = -w; y <= w; y++) {
@ -1762,13 +1762,13 @@ void elly_lhc(Boss *b, int t) {
FROM_TO(280, 10000, 400) {
int i;
int c = 30+10*global.diff;
complex pos = VIEWPORT_W/2 + 100.0*I+400.0*I*((t/400)&1);
cmplx pos = VIEWPORT_W/2 + 100.0*I+400.0*I*((t/400)&1);
global.shake_view = 16;
play_sound("boom");
for(i = 0; i < c; i++) {
complex v = 3*cexp(2.0*I*M_PI*frand());
cmplx v = 3*cexp(2.0*I*M_PI*frand());
tsrand_fill(4);
create_lasercurve2c(pos, 70+20*global.diff, 300, RGBA(0.5, 0.3, 0.9, 0), las_accel, v, 0.02*frand()*copysign(1,creal(v)))->width=15;
@ -1918,13 +1918,13 @@ static int baryon_explode(Enemy *e, int t) {
static int baryon_curvature(Enemy *e, int t) {
int num = creal(e->args[2])+0.5;
int odd = num&1;
complex bpos = global.boss->pos;
complex target = (1-2*odd)*(300+100*sin(t*0.01))*cexp(I*(2*M_PI*(num+0.5*odd)/6+0.6*sqrt(1+t*t/600.)));
cmplx bpos = global.boss->pos;
cmplx target = (1-2*odd)*(300+100*sin(t*0.01))*cexp(I*(2*M_PI*(num+0.5*odd)/6+0.6*sqrt(1+t*t/600.)));
GO_TO(e,bpos+target, 0.1);
if(global.diff > D_Easy && t % (80-4*global.diff) == 0) {
tsrand_fill(2);
complex pos = e->pos+60*anfrand(0)+I*60*anfrand(1);
cmplx pos = e->pos+60*anfrand(0)+I*60*anfrand(1);
if(cabs(pos - global.plr.pos) > 100) {
PROJECTILE(
@ -1953,7 +1953,7 @@ static int curvature_bullet(Projectile *p, int t) {
}
float vx, vy, x, y;
complex v = ((Enemy *)REF(p->args[1]))->args[0]*0.00005;
cmplx v = ((Enemy *)REF(p->args[1]))->args[0]*0.00005;
vx = creal(v);
vy = cimag(v);
x = creal(p->pos-global.plr.pos);
@ -1998,7 +1998,7 @@ static int curvature_slave(Enemy *e, int t) {
if(t % (2+(global.diff < D_Hard)) == 0) {
tsrand_fill(2);
complex pos = VIEWPORT_W*afrand(0)+I*VIEWPORT_H*afrand(1);
cmplx pos = VIEWPORT_W*afrand(0)+I*VIEWPORT_H*afrand(1);
if(cabs(pos - global.plr.pos) > 50) {
tsrand_fill(2);
float speed = 0.5/(1+(global.diff < D_Hard));
@ -2106,7 +2106,7 @@ static void elly_baryon_explode(Boss *b, int t) {
}
}
static complex wrap_around(complex *pos) {
static cmplx wrap_around(cmplx *pos) {
// This function only works approximately. If more than one of these conditions are true,
// dir has to correspond to the wall that was passed first for the
// current preview display to work.
@ -2115,7 +2115,7 @@ static complex wrap_around(complex *pos) {
// preview calculation, but the spell as it is currently seems to work
// perfectly with this simplified version.
complex dir = 0;
cmplx dir = 0;
if(creal(*pos) < -10) {
*pos += VIEWPORT_W;
dir += -1;
@ -2214,7 +2214,7 @@ static int elly_toe_boson(Projectile *p, int t) {
}
p->pos += p->args[0];
complex prev_pos = p->pos;
cmplx prev_pos = p->pos;
int warps_left = creal(p->args[1]);
int warps_initial = cimag(p->args[1]);
@ -2271,10 +2271,10 @@ static int elly_toe_boson(Projectile *p, int t) {
}
float tLookahead = 40;
complex posLookahead = p->pos+p->args[0]*tLookahead;
complex dir = wrap_around(&posLookahead);
cmplx posLookahead = p->pos+p->args[0]*tLookahead;
cmplx dir = wrap_around(&posLookahead);
if(dir != 0 && t%3 == 0 && warps_left > 0) {
complex pos0 = posLookahead - VIEWPORT_W/2*(1-creal(dir))-I*VIEWPORT_H/2*(1-cimag(dir));
cmplx pos0 = posLookahead - VIEWPORT_W/2*(1-creal(dir))-I*VIEWPORT_H/2*(1-cimag(dir));
// Re [a b^*] behaves like the 2D vector scalar product
float tOvershoot = creal(pos0*conj(dir))/creal(p->args[0]*conj(dir));
@ -2304,7 +2304,7 @@ static int elly_toe_boson(Projectile *p, int t) {
#define SYMMETRYTIME (HIGGSTIME+200)
#define BREAKTIME (YUKAWATIME+400)
static bool elly_toe_its_yukawatime(complex pos) {
static bool elly_toe_its_yukawatime(cmplx pos) {
int t = global.frames-global.boss->current->starttime;
if(pos == 0)
@ -2425,14 +2425,14 @@ static int elly_toe_higgs(Projectile *p, int t) {
global_time = max_time;
}
complex vel = p->args[0] * cexp(I*rotation*global_time/(float)max_time);
cmplx vel = p->args[0] * cexp(I*rotation*global_time/(float)max_time);
p->pos = p->pos0 + t * vel;
p->angle = carg(vel);
return ACTION_NONE;
}
static complex elly_toe_laser_pos(Laser *l, float t) { // a[0]: direction, a[1]: type, a[2]: width
static cmplx elly_toe_laser_pos(Laser *l, float t) { // a[0]: direction, a[1]: type, a[2]: width
int type = creal(l->args[1]+0.5);
if(t == EVENT_BIRTH) {
@ -2497,7 +2497,7 @@ static int elly_toe_laser_particle_rule(Projectile *p, int t) {
return ACTION_NONE;
}
static void elly_toe_laser_particle(Laser *l, complex origin) {
static void elly_toe_laser_particle(Laser *l, cmplx origin) {
Color *c = color_mul(COLOR_COPY(&l->color), &l->color);
c->a = 0;
@ -2546,7 +2546,7 @@ static void elly_toe_laser_logic(Laser *l, int t) {
{0, 3, 3, 1}
};
complex newpos = l->prule(l,t);
cmplx newpos = l->prule(l,t);
if(creal(newpos) < 0 || cimag(newpos) < 0 || creal(newpos) > VIEWPORT_W || cimag(newpos) > VIEWPORT_H)
return;
@ -2562,8 +2562,8 @@ static void elly_toe_laser_logic(Laser *l, int t) {
// I removed type 3 because i cant draw dotted lines and it would be too difficult either way
} while(newtype2 == -1 || newtype2 == 3 || newtype == 3);
complex origin = l->prule(l,t);
complex newdir = cexp(0.3*I);
cmplx origin = l->prule(l,t);
cmplx newdir = cexp(0.3*I);
Laser *l1 = create_laser(origin,LASER_LENGTH,LASER_LENGTH,RGBA(1, 1, 1, 0),
elly_toe_laser_pos,elly_toe_laser_logic,
@ -2696,10 +2696,10 @@ void elly_theory(Boss *b, int time) {
for(int i = 0; i < 4; i++) {
pnum = (count - pnum - 1);
complex dir = I*cexp(I*(2*M_PI/count*(pnum+0.5)));
cmplx dir = I*cexp(I*(2*M_PI/count*(pnum+0.5)));
dir *= cexp(I*0.15*sign(creal(dir))*sin(_i));
complex bpos = b->pos + 18 * dir * i;
cmplx bpos = b->pos + 18 * dir * i;
PROJECTILE(
.proto = pp_rice,
@ -2722,7 +2722,7 @@ void elly_theory(Boss *b, int time) {
// play_loop("noise1");
play_sound_ex("shot1", 5, false);
complex dest = 100*cexp(I*1*_i);
cmplx dest = 100*cexp(I*1*_i);
for(int clr = 0; clr < 3; clr++) {
PROJECTILE(
.proto = pp_ball,
@ -2804,7 +2804,7 @@ void elly_theory(Boss *b, int time) {
for(int dir = 0; dir < 2; dir++) {
for(int arm = 0; arm < arms; arm++) {
complex v = -2*I*cexp(I*M_PI/(arms+1)*(arm+1)+0.1*I*sin(time*0.1+arm));
cmplx v = -2*I*cexp(I*M_PI/(arms+1)*(arm+1)+0.1*I*sin(time*0.1+arm));
if(dir)
v = -conj(v);
if(time>symmetrytime) {
@ -2826,7 +2826,7 @@ void elly_theory(Boss *b, int time) {
FROM_TO(breaktime,breaktime+10000,100) {
play_sound_ex("laser1", 0, true);
complex phase = cexp(2*I*M_PI*frand());
cmplx phase = cexp(2*I*M_PI*frand());
int count = 8;
for(int i = 0; i < count; i++) {
create_laser(b->pos,LASER_LENGTH,LASER_LENGTH/2,RGBA(1, 1, 1, 0),
@ -2949,7 +2949,7 @@ static void elly_global_rule(Boss *b, int time) {
global.boss->shadowcolor = *HSLA_MUL_ALPHA((time+20)/120.0, 1.0, 0.25, 0.5);
}
Boss* stage6_spawn_elly(complex pos) {
Boss* stage6_spawn_elly(cmplx pos) {
Boss *b = create_boss("Elly", "elly", pos);
boss_set_portrait(b, get_sprite("dialog/elly"), get_sprite("dialog/elly_face_normal"));
b->global_rule = elly_global_rule;
@ -3018,7 +3018,7 @@ void stage6_events(void) {
create_enemy3c(VIEWPORT_W*(_i&1), 2000, Fairy, stage6_side, 2.0*I+0.1*(1-2*(_i&1)),1-2*(_i&1),_i);
FROM_TO(720, 940, 10) {
complex p = VIEWPORT_W/2+(1-2*(_i&1))*20*(_i%10);
cmplx p = VIEWPORT_W/2+(1-2*(_i&1))*20*(_i%10);
create_enemy3c(p, 2000, Fairy, stage6_side, 2.0*I+1*(1-2*(_i&1)),I*cexp(I*carg(global.plr.pos-p))*(1-2*(_i&1)),_i*psin(_i));
}

View file

@ -30,10 +30,10 @@ void elly_theory(Boss*, int);
void elly_curvature(Boss*, int);
void elly_intro(Boss*, int);
void elly_spawn_baryons(complex pos);
void elly_spawn_baryons(cmplx pos);
void stage6_events(void);
Boss* stage6_spawn_elly(complex pos);
Boss* stage6_spawn_elly(cmplx pos);
void Scythe(Enemy *e, int t, bool render);
void scythe_common(Enemy *e, int t);

View file

@ -16,7 +16,7 @@ static StageText *textlist = NULL;
#define NUM_PLACEHOLDER "........................"
StageText* stagetext_add(const char *text, complex pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
StageText* stagetext_add(const char *text, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
StageText *t = (StageText*)objpool_acquire(stage_object_pools.stagetext);
list_append(&textlist, t);
@ -43,7 +43,7 @@ static void stagetext_numeric_update(StageText *txt, int t, float a) {
format_huge_num(0, (uintptr_t)txt->custom.data1 * pow(a, 5), sizeof(NUM_PLACEHOLDER), txt->text);
}
StageText* stagetext_add_numeric(int n, complex pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
StageText* stagetext_add_numeric(int n, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
StageText *t = stagetext_add(NUM_PLACEHOLDER, pos, align, font, clr, delay, lifetime, fadeintime, fadeouttime);
t->custom.data1 = (void*)(intptr_t)n;
t->custom.update = stagetext_numeric_update;
@ -154,7 +154,7 @@ void stagetext_begin_table(StageTextTable *tbl, const char *title, const Color *
}
void stagetext_end_table(StageTextTable *tbl) {
complex ofs = -0.5 * I * (cimag(tbl->pos) - VIEWPORT_H/2);
cmplx ofs = -0.5 * I * (cimag(tbl->pos) - VIEWPORT_H/2);
for(ListContainer *c = tbl->elems; c; c = c->next) {
((StageText*)c->data)->pos += ofs;

View file

@ -29,7 +29,7 @@ struct StageText {
LIST_INTERFACE(StageText);
Font *font;
complex pos;
cmplx pos;
struct {
StageTextUpdateFunc update;
@ -53,12 +53,12 @@ struct StageText {
void stagetext_free(void);
void stagetext_update(void);
void stagetext_draw(void);
StageText *stagetext_add(const char *text, complex pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
StageText *stagetext_add_numeric(int n, complex pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
StageText *stagetext_add(const char *text, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
StageText *stagetext_add_numeric(int n, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
StageText *stagetext_list_head(void);
struct StageTextTable {
complex pos;
cmplx pos;
double width;
Color clr;
int lifetime;

View file

@ -81,9 +81,22 @@
#define __attribute__(...)
#define __extension__
#define UNREACHABLE
#define DIAGNOSTIC(x)
#define DIAGNOSTIC_GCC(x)
#define DIAGNOSTIC_CLANG(x)
#else
#define USE_GNU_EXTENSIONS
#define UNREACHABLE __builtin_unreachable()
#define DIAGNOSTIC(x) PRAGMA(GCC diagnostic x)
#if defined(__clang__)
#define DIAGNOSTIC_GCC(x)
#define DIAGNOSTIC_CLANG(x) PRAGMA(clang diagnostic x)
#else
#define DIAGNOSTIC_GCC(x) PRAGMA(GCC diagnostic x)
#define DIAGNOSTIC_CLANG(x)
#endif
#endif
#ifndef __has_attribute
@ -132,6 +145,27 @@ typedef unsigned char uchar;
#undef schar
typedef signed char schar;
#undef float32
typedef float float32;
#undef float64
typedef double float64;
#undef float64x
typedef long double float64x;
#undef real
typedef float64 real;
#undef cmplx32
typedef _Complex float cmplx32;
#undef cmplx64
typedef _Complex double cmplx64;
#undef cmplx
typedef cmplx64 cmplx;
// These definitions are common but non-standard, so we provide our own
#undef M_PI
#undef M_PI_2
@ -142,25 +176,12 @@ typedef signed char schar;
#define M_PI_4 0.78539816339744830962
#define M_E 2.7182818284590452354
// This is a workaround to properly specify the type of our "complex" variables...
// Taisei code always uses just "complex" when it actually means "complex double", which is not really correct.
// gcc doesn't seem to care, other compilers do (e.g. clang)
#undef complex
// typedef it for convenience
typedef _Complex double complex;
// standard says `complex` should be a macro
#define complex complex
// unfortunately, the above `complex` hack conflicts with some headers that define
// `CMPLX` like ((double complex){ x, y })
#undef CMPLX
// FIXME this is likely incorrect!
#if TAISEI_BUILDCONF_MALLOC_ALIGNMENT < 0
#warning max_align_t not supported
#undef TAISEI_BUILDCONF_MALLOC_ALIGNMENT
#define TAISEI_BUILDCONF_MALLOC_ALIGNMENT 8
typedef struct { alignas(TAISEI_BUILDCONF_MALLOC_ALIGNMENT) long double a; } max_align_t;
typedef struct { alignas(TAISEI_BUILDCONF_MALLOC_ALIGNMENT) float64x a; } max_align_t;
#endif
// In case the C11 CMPLX macro is not present, try our best to provide a substitute

View file

@ -16,7 +16,7 @@ static inline void ellipse_bbox(const Ellipse *e, Rect *r) {
r->bottom_right = e->origin + largest_radius + I * largest_radius;
}
bool point_in_ellipse(complex p, Ellipse e) {
bool point_in_ellipse(cmplx p, Ellipse e) {
double Xp = creal(p);
double Yp = cimag(p);
double Xe = creal(e.origin);
@ -52,7 +52,7 @@ static bool segment_ellipse_nonintersection_heuristic(LineSegment seg, Ellipse e
// if yes, return f so that a+f*(b-a) is that point.
// otherwise return -1.
static double lineseg_circle_intersect_fallback(LineSegment seg, Circle c) {
complex m, v;
cmplx m, v;
double projection, lv, lm, distance;
m = seg.b - seg.a; // vector pointing along the line
@ -98,7 +98,7 @@ bool lineseg_ellipse_intersect(LineSegment seg, Ellipse e) {
seg.b -= e.origin;
double ratio = creal(e.axes) / cimag(e.axes);
complex rotation = cexp(I * -e.angle);
cmplx rotation = cexp(I * -e.angle);
seg.a *= rotation;
seg.b *= rotation;
seg.a = creal(seg.a) + I * ratio * cimag(seg.a);
@ -116,7 +116,7 @@ double lineseg_circle_intersect(LineSegment seg, Circle c) {
return lineseg_circle_intersect_fallback(seg, c);
}
bool point_in_rect(complex p, Rect r) {
bool point_in_rect(cmplx p, Rect r) {
return
creal(p) >= rect_left(r) &&
creal(p) <= rect_right(r) &&

View file

@ -50,27 +50,27 @@ typedef struct IntRect {
} IntRect;
typedef struct Ellipse {
complex origin;
complex axes; // NOT half-axes!
cmplx origin;
cmplx axes; // NOT half-axes!
double angle;
} Ellipse;
typedef struct LineSegment {
complex a;
complex b;
cmplx a;
cmplx b;
} LineSegment;
typedef struct Circle {
complex origin;
cmplx origin;
double radius;
} Circle;
typedef struct Rect {
complex top_left;
complex bottom_right;
cmplx top_left;
cmplx bottom_right;
} Rect;
bool point_in_ellipse(complex p, Ellipse e) attr_const;
bool point_in_ellipse(cmplx p, Ellipse e) attr_const;
double lineseg_circle_intersect(LineSegment seg, Circle c) attr_const;
bool lineseg_ellipse_intersect(LineSegment seg, Ellipse e) attr_const;
@ -120,13 +120,13 @@ double rect_area(Rect r) {
}
INLINE
void rect_move(Rect *r, complex pos) {
complex vector = pos - r->top_left;
void rect_move(Rect *r, cmplx pos) {
cmplx vector = pos - r->top_left;
r->top_left += vector;
r->bottom_right += vector;
}
bool point_in_rect(complex p, Rect r);
bool point_in_rect(cmplx p, Rect r);
bool rect_in_rect(Rect inner, Rect outer) attr_const;
bool rect_rect_intersect(Rect r1, Rect r2, bool edges, bool corners) attr_const;
bool rect_rect_intersection(Rect r1, Rect r2, bool edges, bool corners, Rect *out) attr_pure attr_nonnull(5);

View file

@ -12,6 +12,7 @@
#include "taisei.h"
#include <SDL.h>
#include "hashtable.h"
// The callback should return true on success and false on error. In the case of

View file

@ -15,7 +15,7 @@ double lerp(double v0, double v1, double f) {
return f * (v1 - v0) + v0;
}
complex clerp(complex v0, complex v1, double f) {
cmplx clerp(cmplx v0, cmplx v1, double f) {
return f * (v1 - v0) + v0;
}
@ -71,7 +71,7 @@ float fapproach_asymptotic(float val, float target, float rate, float epsilon) {
return val + (target - val) * rate;
}
complex capproach_asymptotic(complex val, complex target, double rate, double epsilon) {
cmplx capproach_asymptotic(cmplx val, cmplx target, double rate, double epsilon) {
if(cabs(val - target) < epsilon || rate >= 1) {
return target;
}
@ -87,7 +87,7 @@ void fapproach_asymptotic_p(float *val, float target, float rate, float epsilon)
*val = fapproach_asymptotic(*val, target, rate, epsilon);
}
void capproach_asymptotic_p(complex *val, complex target, double rate, double epsilon) {
void capproach_asymptotic_p(cmplx *val, cmplx target, double rate, double epsilon) {
*val = capproach_asymptotic(*val, target, rate, epsilon);
}
@ -389,7 +389,7 @@ uint64_t _umuldiv64(uint64_t x, uint64_t multiplier, uint64_t divisor) {
return ((uint128_t)x * (uint128_t)multiplier) / divisor;
#elif defined(TAISEI_BUILDCONF_HAVE_LONG_DOUBLE)
#define UMULDIV64_SANITY_CHECK
return ((long double)x * (long double)multiplier) / (long double)divisor;
return ((float64x)x * (float64x)multiplier) / (float64x)divisor;
#else
return _umuldiv64_slow(x, multiplier, divisor);
#endif

View file

@ -16,7 +16,7 @@
#define GOLDEN_RATIO 1.618033988749895
double lerp(double v0, double v1, double f) attr_const;
complex clerp(complex v0, complex v1, double f) attr_const;
cmplx clerp(cmplx v0, cmplx v1, double f) attr_const;
intmax_t imin(intmax_t, intmax_t) attr_const;
intmax_t imax(intmax_t, intmax_t) attr_const;
uintmax_t umin(uintmax_t, uintmax_t) attr_const;
@ -33,10 +33,10 @@ void approach_p(double *v, double t, double d);
void fapproach_p(float *v, float t, float d);
double approach_asymptotic(double val, double target, double rate, double epsilon) attr_const;
float fapproach_asymptotic(float val, float target, float rate, float epsilon) attr_const;
complex capproach_asymptotic(complex val, complex target, double rate, double epsilon) attr_const;
cmplx capproach_asymptotic(cmplx val, cmplx target, double rate, double epsilon) attr_const;
void approach_asymptotic_p(double *val, double target, double rate, double epsilon);
void fapproach_asymptotic_p(float *val, float target, float rate, float epsilon);
void capproach_asymptotic_p(complex *val, complex target, double rate, double epsilon);
void capproach_asymptotic_p(cmplx *val, cmplx target, double rate, double epsilon);
double psin(double) attr_const;
int sign(double) attr_const;
double swing(double x, double s) attr_const;

View file

@ -12,6 +12,7 @@
#include "taisei.h"
#include <SDL.h>
#include "../pixmap.h"
typedef struct PixmapLoader {

View file

@ -9,6 +9,7 @@
#include "taisei.h"
#include <immintrin.h>
#include "sse42.h"
uint32_t crc32str_sse42(uint32_t crc, const char *str) {

View file

@ -8,7 +8,7 @@
#include "taisei.h"
#include <version.h>
#include "version.h"
int taisei_version_compare(TaiseiVersion *v1, TaiseiVersion *v2, TaiseiVersionCmpLevel level) {
int result = 0;

View file

@ -10,6 +10,7 @@
#include "public.h"
#include "util.h"
#include <emscripten.h>
void EMSCRIPTEN_KEEPALIVE vfs_sync_callback(bool is_load, char *error, CallChain *next);

View file

@ -12,6 +12,7 @@
#include "taisei.h"
#include <zip.h>
#include "private.h"
#include "hashtable.h"