Get rid of custom min() and max() functions
Use the standard fmin() and fmax() for floating point values, and ours imin(), imax(), umin(), umax() for integers.
This commit is contained in:
parent
0f2a6a0229
commit
f5f8f9fb49
29 changed files with 120 additions and 138 deletions
|
@ -402,7 +402,7 @@ static void custom_fadeout_proc(int chan, void *stream, int len, void *udata) {
|
|||
|
||||
for(int i = 0; i < len; i++) {
|
||||
e->counter++;
|
||||
data[i]*=1.-min(1,(double)e->counter/(double)e->duration);
|
||||
data[i]*=1.-fmin(1,(double)e->counter/(double)e->duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
38
src/boss.c
38
src/boss.c
|
@ -268,7 +268,7 @@ static void update_healthbar(Boss *boss) {
|
|||
float spell_maxhp;
|
||||
|
||||
if(spell->type == AT_SurvivalSpell) {
|
||||
spell_hp = spell_maxhp = max(1, total_maxhp * 0.1);
|
||||
spell_hp = spell_maxhp = fmax(1, total_maxhp * 0.1);
|
||||
} else {
|
||||
spell_hp = spell->hp;
|
||||
spell_maxhp = spell->maxhp;
|
||||
|
@ -288,10 +288,10 @@ static void update_healthbar(Boss *boss) {
|
|||
target_opacity = 0.0;
|
||||
}
|
||||
} else if(total_maxhp > 0) {
|
||||
total_maxhp = max(0.001, total_maxhp);
|
||||
total_maxhp = fmax(0.001, total_maxhp);
|
||||
|
||||
if(total_hp > 0) {
|
||||
total_hp = max(0.001, total_hp);
|
||||
total_hp = fmax(0.001, total_hp);
|
||||
}
|
||||
|
||||
target_fill = total_hp / total_maxhp;
|
||||
|
@ -443,7 +443,7 @@ static void draw_spell_name(Boss *b, int time, bool healthbar_radial) {
|
|||
r_mat_mv_scale(scale,scale,1);
|
||||
r_mat_mv_rotate(glm_ease_quad_out(f) * 2 * M_PI, 0.8, -0.2, 0);
|
||||
|
||||
float spellname_opacity_noplr = opacity_noplr * min(1, warn_progress/0.6);
|
||||
float spellname_opacity_noplr = opacity_noplr * fmin(1, warn_progress/0.6);
|
||||
float spellname_opacity = spellname_opacity_noplr * b->hud.plrproximity_opacity;
|
||||
|
||||
draw_boss_text(ALIGN_RIGHT, strw/2*(1-f), 0, b->current->name, font, color_mul_scalar(RGBA(1, 1, 1, 1), spellname_opacity));
|
||||
|
@ -539,8 +539,8 @@ static void draw_spell_portrait(Boss *b, int time) {
|
|||
r_shader("sprite_default");
|
||||
|
||||
float char_in = clamp(a * 1.5, 0, 1);
|
||||
float char_out = min(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * min(1, a * 5);
|
||||
float char_out = fmin(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * fmin(1, a * 5);
|
||||
float char_opacity = char_opacity_in * char_out * char_out;
|
||||
float char_xofs = -20 * a;
|
||||
|
||||
|
@ -564,14 +564,14 @@ static void draw_spell_portrait(Boss *b, int time) {
|
|||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4 - i * 0.3) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = color_mul_scalar(color_add(RGBA(0.2, 0.2, 0.2, 0), RGBA(i==1, i==2, i==3, 0)), char_opacity_in * (1 - char_in * o) * o),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.02 * (min(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
.scale.both = 1.0 + 0.02 * (fmin(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
});
|
||||
}
|
||||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * min(1, char_in * 2) * (1 - min(1, (1 - char_out) * 5))),
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * fmin(1, char_in * 2) * (1 - fmin(1, (1 - char_out) * 5))),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.1 * (1 - char_out),
|
||||
});
|
||||
|
@ -650,7 +650,7 @@ void draw_boss_background(Boss *boss) {
|
|||
|
||||
if(boss_is_dying(boss)) {
|
||||
float t = (global.frames - boss->current->endtime)/(float)BOSS_DEATH_DELAY + 1;
|
||||
f -= t*(t-0.7)/max(0.01, 1-t);
|
||||
f -= t*(t-0.7)/fmax(0.01, 1-t);
|
||||
}
|
||||
|
||||
r_mat_mv_scale(f, f, 1);
|
||||
|
@ -793,8 +793,8 @@ static void boss_rule_extra(Boss *boss, float alpha) {
|
|||
return;
|
||||
}
|
||||
|
||||
int cnt = 5 * max(1, alpha);
|
||||
alpha = min(2, alpha);
|
||||
int cnt = 5 * fmax(1, alpha);
|
||||
alpha = fmin(2, alpha);
|
||||
int lt = 1;
|
||||
|
||||
if(alpha == 0) {
|
||||
|
@ -806,7 +806,7 @@ static void boss_rule_extra(Boss *boss, float alpha) {
|
|||
float a = i*2*M_PI/cnt + global.frames / 100.0;
|
||||
cmplx dir = cexp(I*(a+global.frames/50.0));
|
||||
cmplx vel = dir * 3;
|
||||
float v = max(0, alpha - 1);
|
||||
float v = fmax(0, alpha - 1);
|
||||
float psina = psin(a);
|
||||
|
||||
PARTICLE(
|
||||
|
@ -875,7 +875,7 @@ static void calc_spell_bonus(Attack *a, SpellBonus *bonus) {
|
|||
bool survival = a->type == AT_SurvivalSpell;
|
||||
bonus->failed = a->failtime > 0;
|
||||
|
||||
int time_left = max(0, a->starttime + a->timeout - global.frames);
|
||||
int time_left = fmax(0, a->starttime + a->timeout - global.frames);
|
||||
|
||||
double piv_factor = global.plr.point_item_value / (double)PLR_START_PIV;
|
||||
double base = a->bonus_base * 0.5 * (1 + piv_factor);
|
||||
|
@ -887,7 +887,7 @@ static void calc_spell_bonus(Attack *a, SpellBonus *bonus) {
|
|||
|
||||
if(bonus->failed) {
|
||||
bonus->time /= 4;
|
||||
bonus->endurance = base * 0.1 * (max(0, a->failtime - a->starttime) / (double)a->timeout);
|
||||
bonus->endurance = base * 0.1 * (fmax(0, a->failtime - a->starttime) / (double)a->timeout);
|
||||
} else if(survival) {
|
||||
bonus->survival = base * (1.0 + 0.02 * (a->timeout / (double)FPS));
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ void process_boss(Boss **pboss) {
|
|||
|
||||
if(boss->current->endtime) {
|
||||
float p = (boss->current->endtime - global.frames)/(float)ATTACK_END_DELAY_EXTRA;
|
||||
float a = max((base + ampl * s) * p * 0.5, 5 * pow(1 - p, 3));
|
||||
float a = fmax((base + ampl * s) * p * 0.5, 5 * pow(1 - p, 3));
|
||||
if(a < 2) {
|
||||
global.shake_view = 3 * a;
|
||||
boss_rule_extra(boss, a);
|
||||
|
@ -1067,12 +1067,12 @@ void process_boss(Boss **pboss) {
|
|||
} else if(time < 0) {
|
||||
boss_rule_extra(boss, 1+time/(float)ATTACK_START_DELAY_EXTRA);
|
||||
} else {
|
||||
float o = min(0, -5 + time/30.0);
|
||||
float q = (time <= 150? 1 - pow(time/250.0, 2) : min(1, time/60.0));
|
||||
float o = fmin(0, -5 + time/30.0);
|
||||
float q = (time <= 150? 1 - pow(time/250.0, 2) : fmin(1, time/60.0));
|
||||
|
||||
boss_rule_extra(boss, max(1-time/300.0, base + ampl * s) * q);
|
||||
boss_rule_extra(boss, fmax(1-time/300.0, base + ampl * s) * q);
|
||||
if(o) {
|
||||
boss_rule_extra(boss, max(1-time/300.0, base + ampl * s) - o);
|
||||
boss_rule_extra(boss, fmax(1-time/300.0, base + ampl * s) - o);
|
||||
if(!global.shake_view) {
|
||||
global.shake_view = 5;
|
||||
global.shake_view_fade = 0.9;
|
||||
|
|
|
@ -145,8 +145,8 @@ void color_get_hsl(const Color *c, float *out_h, float *out_s, float *out_l) {
|
|||
float g = clamp(c->g, 0, 1);
|
||||
float b = clamp(c->b, 0, 1);
|
||||
|
||||
float maxv = max(max(r, g), b);
|
||||
float minv = min(min(r, g), b);
|
||||
float maxv = fmax(fmax(r, g), b);
|
||||
float minv = fmin(fmin(r, g), b);
|
||||
float h = 0, s = 0, d = maxv - minv, l = (maxv + minv) / 2;
|
||||
|
||||
if(maxv != minv) {
|
||||
|
|
|
@ -313,7 +313,7 @@ static void credits_draw_entry(CreditsEntry *e) {
|
|||
}
|
||||
|
||||
if(time - e->time - CREDITS_ENTRY_FADEIN + ofs > 0) {
|
||||
fadeout = max(0, 1 - (time - e->time - CREDITS_ENTRY_FADEIN + ofs) / CREDITS_ENTRY_FADEOUT);
|
||||
fadeout = fmax(0, 1 - (time - e->time - CREDITS_ENTRY_FADEIN + ofs) / CREDITS_ENTRY_FADEOUT);
|
||||
}
|
||||
|
||||
if(!fadein || !fadeout) {
|
||||
|
|
|
@ -197,7 +197,7 @@ static cmplx move_item(Item *i) {
|
|||
}
|
||||
|
||||
static bool item_out_of_bounds(Item *item) {
|
||||
double margin = max(item_sprite(item->type)->w, item_sprite(item->type)->h);
|
||||
double margin = fmax(item_sprite(item->type)->w, item_sprite(item->type)->h);
|
||||
|
||||
return (
|
||||
creal(item->pos) < -margin ||
|
||||
|
@ -216,7 +216,7 @@ bool collect_item(Item *item, float value) {
|
|||
|
||||
if(item->auto_collect) {
|
||||
item->auto_collect = imax(speed, item->auto_collect);
|
||||
item->pickup_value = max(clamp(value, ITEM_MIN_VALUE, ITEM_MAX_VALUE), item->pickup_value);
|
||||
item->pickup_value = fmax(clamp(value, ITEM_MIN_VALUE, ITEM_MAX_VALUE), item->pickup_value);
|
||||
item->collecttime = imin(global.frames + delay, item->collecttime);
|
||||
} else {
|
||||
item->auto_collect = speed;
|
||||
|
|
|
@ -453,7 +453,7 @@ void process_lasers(void) {
|
|||
bool kill_now = laser->timespan < 5;
|
||||
|
||||
if(!((global.frames - laser->birthtime) % 2) || kill_now) {
|
||||
double t = max(0, (global.frames - laser->birthtime)*laser->speed - laser->timespan + laser->timeshift);
|
||||
double t = fmax(0, (global.frames - laser->birthtime)*laser->speed - laser->timespan + laser->timeshift);
|
||||
cmplx p = laser->prule(laser, t);
|
||||
double x = creal(p);
|
||||
double y = cimag(p);
|
||||
|
@ -591,7 +591,7 @@ bool laser_intersects_circle(Laser *l, Circle circle) {
|
|||
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);
|
||||
l->collision_step = fmax(3, l->timespan/10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ cmplx las_linear(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);
|
||||
l->collision_step = fmax(3, l->timespan/10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ static void end_char_menu(MenuData *m) {
|
|||
}
|
||||
|
||||
static void transition_to_game(double fade) {
|
||||
fade_out(pow(max(0, (fade - 0.5) * 2), 2));
|
||||
fade_out(pow(fmax(0, (fade - 0.5) * 2), 2));
|
||||
}
|
||||
|
||||
MenuData* create_char_menu(void) {
|
||||
|
@ -195,7 +195,7 @@ void draw_char_menu(MenuData *menu) {
|
|||
face = facedefs[i][F_UNAMUSED];
|
||||
}
|
||||
|
||||
float pofs = max(0, e->drawdata * 1.5 - 0.5);
|
||||
float pofs = fmax(0.0f, e->drawdata * 1.5f - 0.5f);
|
||||
pofs = glm_ease_back_in(pofs);
|
||||
|
||||
if(i != menu->selected) {
|
||||
|
|
|
@ -161,8 +161,8 @@ void draw_main_menu(MenuData *menu) {
|
|||
.pos = { SCREEN_W/2, SCREEN_H/2 },
|
||||
.shader = "sprite_default",
|
||||
.rotation.vector = { 0, -1, 0 },
|
||||
.rotation.angle = max(0, M_PI/1.5 - min(M_PI/1.5, rot) * rotfac),
|
||||
.color = color_mul_scalar(RGBA(1, 1, 1, 1), min(1, rot) * rotfac),
|
||||
.rotation.angle = fmax(0, M_PI/1.5 - fmin(M_PI/1.5, rot) * rotfac),
|
||||
.color = color_mul_scalar(RGBA(1, 1, 1, 1), fmin(1, rot) * rotfac),
|
||||
});
|
||||
|
||||
r_mat_mv_push();
|
||||
|
@ -176,7 +176,7 @@ void draw_main_menu(MenuData *menu) {
|
|||
r_color4(0.2 * o, 0.3 * o, 0.5 * o, o);
|
||||
} else {
|
||||
float a = 1 - e->drawdata;
|
||||
r_color4(o, min(1, 0.7 + a) * o, min(1, 0.4 + a) * o, o);
|
||||
r_color4(o, fmin(1, 0.7 + a) * o, fmin(1, 0.4 + a) * o, o);
|
||||
}
|
||||
|
||||
text_draw(e->name, &(TextParams) {
|
||||
|
|
24
src/player.c
24
src/player.c
|
@ -147,7 +147,6 @@ void player_move(Player *plr, cmplx delta) {
|
|||
}
|
||||
|
||||
void player_draw_overlay(Player *plr) {
|
||||
// plr->bomb_cutin_alpha = 1 - fmod(global.frames / 200.0, 1.0);
|
||||
float a = 1 - plr->bomb_cutin_alpha;
|
||||
|
||||
if(a <= 0 || a >= 1) {
|
||||
|
@ -158,12 +157,11 @@ void player_draw_overlay(Player *plr) {
|
|||
r_shader("sprite_default");
|
||||
|
||||
float char_in = clamp(a * 1.5, 0, 1);
|
||||
float char_out = min(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * min(1, a * 5);
|
||||
float char_out = fmin(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * fmin(1, a * 5);
|
||||
float char_opacity = char_opacity_in * char_out * char_out;
|
||||
float char_xofs = -20 * a;
|
||||
|
||||
// Sprite *char_spr = get_sprite(plr->mode->character->dialog_sprite_name);
|
||||
Sprite *char_spr = &plr->bomb_portrait;
|
||||
|
||||
for(int i = 1; i <= 3; ++i) {
|
||||
|
@ -179,21 +177,21 @@ void player_draw_overlay(Player *plr) {
|
|||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4 - i * 0.3) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = color_mul_scalar(color_add(RGBA(0.2, 0.2, 0.2, 0), RGBA(i==1, i==2, i==3, 0)), char_opacity_in * (1 - char_in * o) * o),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.02 * (min(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
.scale.both = 1.0 + 0.02 * (fmin(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
});
|
||||
}
|
||||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * min(1, char_in * 2) * (1 - min(1, (1 - char_out) * 5))),
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * fmin(1, char_in * 2) * (1 - fmin(1, (1 - char_out) * 5))),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.1 * (1 - char_out),
|
||||
});
|
||||
|
||||
float spell_in = min(1, a * 3.0);
|
||||
float spell_out = min(1, 3 - (3 * a));
|
||||
float spell_opacity = min(1, a * 5) * spell_out * spell_out;
|
||||
float spell_in = fmin(1, a * 3.0);
|
||||
float spell_out = fmin(1, 3 - (3 * a));
|
||||
float spell_opacity = fmin(1, a * 5) * spell_out * spell_out;
|
||||
|
||||
float spell_x = 128 * (1 - pow(1 - spell_in, 5)) + (VIEWPORT_W + 256) * pow(1 - spell_in, 3);
|
||||
float spell_y = VIEWPORT_H - 128 * sqrt(a);
|
||||
|
@ -494,8 +492,8 @@ static void player_powersurge_logic(Player *plr) {
|
|||
return;
|
||||
}
|
||||
|
||||
plr->powersurge.positive = max(0, plr->powersurge.positive - lerp(PLR_POWERSURGE_POSITIVE_DRAIN_MIN, PLR_POWERSURGE_POSITIVE_DRAIN_MAX, plr->powersurge.positive));
|
||||
plr->powersurge.negative = max(0, plr->powersurge.negative - lerp(PLR_POWERSURGE_NEGATIVE_DRAIN_MIN, PLR_POWERSURGE_NEGATIVE_DRAIN_MAX, plr->powersurge.negative));
|
||||
plr->powersurge.positive = fmax(0, plr->powersurge.positive - lerp(PLR_POWERSURGE_POSITIVE_DRAIN_MIN, PLR_POWERSURGE_POSITIVE_DRAIN_MAX, plr->powersurge.positive));
|
||||
plr->powersurge.negative = fmax(0, plr->powersurge.negative - lerp(PLR_POWERSURGE_NEGATIVE_DRAIN_MIN, PLR_POWERSURGE_NEGATIVE_DRAIN_MAX, plr->powersurge.negative));
|
||||
|
||||
if(stage_is_cleared()) {
|
||||
player_cancel_powersurge(plr);
|
||||
|
@ -868,7 +866,7 @@ void player_realdeath(Player *plr) {
|
|||
|
||||
int total_power = plr->power + plr->power_overflow;
|
||||
|
||||
int drop = max(2, (total_power * 0.15) / POWER_VALUE);
|
||||
int drop = fmax(2, (total_power * 0.15) / POWER_VALUE);
|
||||
spawn_items(plr->deathpos, ITEM_POWER, drop);
|
||||
|
||||
player_set_power(plr, total_power * 0.7);
|
||||
|
@ -1516,7 +1514,7 @@ static void add_score_text(Player *plr, cmplx location, uint points, bool is_piv
|
|||
timings.fadeouttime = 20;
|
||||
|
||||
if(is_piv) {
|
||||
importance = sqrt(min(points/500.0, 1));
|
||||
importance = sqrt(fmin(points/500.0, 1));
|
||||
a = lerp(0.4, 1.0, importance);
|
||||
c = *color_lerp(RGB(0.5, 0.8, 1.0), RGB(1.0, 0.3, 1.0), importance);
|
||||
timings.lifetime = 35 + 10 * importance;
|
||||
|
|
|
@ -243,7 +243,7 @@ TASK(marisa_star_slave, {
|
|||
|
||||
for(int t = 0; slave->alive; t += WAIT(1)) {
|
||||
cmplx target_pos = ctrl->slave_ref_pos + 80 * sin(angle) + 45*I;
|
||||
slave->pos = clerp(plr->pos, target_pos, glm_ease_quad_out(min(1, (real)t/HAKKERO_RETRACT_TIME)));
|
||||
slave->pos = clerp(plr->pos, target_pos, glm_ease_quad_out(fmin(1, (real)t/HAKKERO_RETRACT_TIME)));
|
||||
slave->ent.draw_layer = cos(angle) < 0 ? LAYER_BACKGROUND : LAYER_PLAYER_SLAVE;
|
||||
angle += angle_step;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ TASK(marisa_star_bomb_controller, { MarisaBController *ctrl; }) {
|
|||
}
|
||||
|
||||
do {
|
||||
global.shake_view = max(8, global.shake_view);
|
||||
global.shake_view = fmax(8, global.shake_view);
|
||||
player_placeholder_bomb_logic(plr);
|
||||
|
||||
float tb = player_get_bomb_progress(plr);
|
||||
|
|
|
@ -263,7 +263,7 @@ TASK(reimu_spirit_bomb_orb_impact, { BoxedProjectile orb; }) {
|
|||
|
||||
ENT_ARRAY_FOREACH_COUNTER(&impact_effects, int i, Projectile *p, {
|
||||
float t = (global.frames - p->birthtime) / p->timeout;
|
||||
float attack = min(1, vrng_range(rand[i], 7, 12) * t);
|
||||
float attack = fmin(1, vrng_f32_range(rand[i], 7, 12) * t);
|
||||
float decay = t;
|
||||
|
||||
Color c = base_colors[i];
|
||||
|
|
|
@ -318,7 +318,7 @@ static void reimu_dream_bullet_warp(ReimuBController *ctrl, Projectile *p, int *
|
|||
return;
|
||||
}
|
||||
|
||||
real p_long_side = max(creal(p->size), cimag(p->size));
|
||||
real p_long_side = fmax(creal(p->size), cimag(p->size));
|
||||
cmplx half = 0.25 * (1 + I);
|
||||
Rect p_bbox = { p->pos - p_long_side * half, p->pos + p_long_side * half };
|
||||
|
||||
|
@ -334,8 +334,8 @@ static void reimu_dream_bullet_warp(ReimuBController *ctrl, Projectile *p, int *
|
|||
cmplx gap_size = (GAP_LENGTH + I * GAP_WIDTH) * gap->parallel_axis;
|
||||
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));
|
||||
gap_bbox.top_left = fmin(creal(p0), creal(p1)) + I * fmin(cimag(p0), cimag(p1));
|
||||
gap_bbox.bottom_right = fmax(creal(p0), creal(p1)) + I * fmax(cimag(p0), cimag(p1));
|
||||
|
||||
if(rect_rect_intersection(p_bbox, gap_bbox, true, false, &overlap)) {
|
||||
cmplx o = (overlap.top_left + overlap.bottom_right) / 2;
|
||||
|
@ -611,7 +611,7 @@ TASK(reimu_dream_controller_tick, { ReimuBController *ctrl; }) {
|
|||
|
||||
for(;;) {
|
||||
if(player_is_bomb_active(plr)) {
|
||||
global.shake_view_fade = max(global.shake_view_fade, 5);
|
||||
global.shake_view_fade = fmax(global.shake_view_fade, 5);
|
||||
approach_p(&ctrl->bomb_alpha, 1.0, 0.1);
|
||||
} else {
|
||||
approach_p(&ctrl->bomb_alpha, 0.0, 0.025);
|
||||
|
|
|
@ -102,7 +102,7 @@ TASK(youmu_mirror_myon_trail, { YoumuAMyon *myon; cmplx pos; }) {
|
|||
|
||||
for(int t = 0;; ++t) {
|
||||
real f = myon->focus_factor;
|
||||
myon_color(&p->color, f, pow(1 - min(1, t / p->timeout), 2), 0.95);
|
||||
myon_color(&p->color, f, pow(1 - fmin(1, t / p->timeout), 2), 0.95);
|
||||
p->pos += 0.05 * (myon->pos - p->pos) * cdir(sin((t - global.frames * 2) * 0.1) * M_PI/8);
|
||||
p->move.velocity = 3 * myon_tail_dir(myon);
|
||||
YIELD;
|
||||
|
@ -151,7 +151,7 @@ static void myon_spawn_trail(YoumuAMyon *myon, int t) {
|
|||
static void myon_draw_proj_trail(Projectile *p, int t, ProjDrawRuleArgs args) {
|
||||
float time_progress = projectile_timeout_factor(p);
|
||||
float s = 2 * time_progress;
|
||||
float a = min(1, s) * (1 - time_progress);
|
||||
float a = fmin(1, s) * (1 - time_progress);
|
||||
|
||||
SpriteParamsBuffer spbuf;
|
||||
SpriteParams sp = projectile_sprite_params(p, &spbuf);
|
||||
|
@ -347,7 +347,7 @@ TASK(youmu_mirror_myon, { YoumuAController *ctrl; }) {
|
|||
}
|
||||
|
||||
cmplx target = plr->pos + distance * offset_dir;
|
||||
cmplx v = cnormalize(target - myon->pos) * min(10, follow_factor * max(0, cabs(target - myon->pos) - VIEWPORT_W * 0.5 * focus_factor));
|
||||
cmplx v = cnormalize(target - myon->pos) * fmin(10, follow_factor * fmax(0, cabs(target - myon->pos) - VIEWPORT_W * 0.5 * focus_factor));
|
||||
|
||||
real s = sign(creal(myon->pos) - creal(plr->pos));
|
||||
if(!s) {
|
||||
|
|
|
@ -317,7 +317,7 @@ TASK(youmu_orb_homing_spirit, { YoumuBController *ctrl; cmplx pos; cmplx velocit
|
|||
}
|
||||
}
|
||||
|
||||
real s = max(speed, cabs(p->move.velocity));
|
||||
real s = fmax(speed, cabs(p->move.velocity));
|
||||
p->move.velocity = s * cnormalize(p->move.velocity + aim_strength * s * aimdir);
|
||||
approach_asymptotic_p(&speed, speed_target, 0.05, 1e-5);
|
||||
|
||||
|
@ -474,7 +474,7 @@ TASK(youmu_haunting_bomb_slice_petal, { YoumuBController *ctrl; cmplx pos; cmplx
|
|||
real transition_time = 40;
|
||||
|
||||
for(real t = 0; t <= transition_time; ++t) {
|
||||
p->color = *color_mul_scalar(RGBA(0.2, 0.2, 1, 0), min(1, t / transition_time));
|
||||
p->color = *color_mul_scalar(RGBA(0.2, 0.2, 1, 0), fmin(1, t / transition_time));
|
||||
YIELD;
|
||||
}
|
||||
}
|
||||
|
@ -504,9 +504,9 @@ TASK(youmu_haunting_bomb_slice, { YoumuBController *ctrl; cmplx pos; real angle;
|
|||
real a = 0;
|
||||
|
||||
if(tt > 0.5) {
|
||||
a = max(0, 1 - (tt - 0.5) / 0.5);
|
||||
a = fmax(0, 1 - (tt - 0.5) / 0.5);
|
||||
} else {
|
||||
a = min(1, tt / 0.2);
|
||||
a = fmin(1, tt / 0.2);
|
||||
}
|
||||
|
||||
p->color = *RGBA(a, a, a, 0);
|
||||
|
|
|
@ -729,7 +729,7 @@ static void bullet_highlight_draw(Projectile *p, int t, ProjDrawRuleArgs args) {
|
|||
float tex_angle = args[1].as_float[0];
|
||||
|
||||
float opacity = pow(1 - timefactor, 2);
|
||||
opacity = min(1, 1.5 * opacity) * min(1, timefactor * 10);
|
||||
opacity = fmin(1, 1.5 * opacity) * fmin(1, timefactor * 10);
|
||||
opacity *= p->opacity;
|
||||
|
||||
r_mat_tex_push();
|
||||
|
|
|
@ -48,8 +48,8 @@ static size_t gl33_buffer_stream_write(SDL_RWops *rw, const void *data, size_t s
|
|||
|
||||
if(total_size > 0) {
|
||||
memcpy(cbuf->cache.buffer + cbuf->offset, data, total_size);
|
||||
cbuf->cache.update_begin = min(cbuf->offset, cbuf->cache.update_begin);
|
||||
cbuf->cache.update_end = max(cbuf->offset + total_size, cbuf->cache.update_end);
|
||||
cbuf->cache.update_begin = umin(cbuf->offset, cbuf->cache.update_begin);
|
||||
cbuf->cache.update_end = umax(cbuf->offset + total_size, cbuf->cache.update_end);
|
||||
cbuf->offset += total_size;
|
||||
}
|
||||
|
||||
|
@ -137,4 +137,3 @@ void gl33_buffer_flush(CommonBuffer *cbuf) {
|
|||
cbuf->cache.update_begin = cbuf->size;
|
||||
cbuf->cache.update_end = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,11 +164,11 @@ void gl33_texture_get_size(Texture *tex, uint mipmap, uint *width, uint *height)
|
|||
}
|
||||
} else {
|
||||
if(width != NULL) {
|
||||
*width = max(1, floor(tex->params.width / pow(2, mipmap)));
|
||||
*width = umax(1, tex->params.width / (1u << mipmap));
|
||||
}
|
||||
|
||||
if(height != NULL) {
|
||||
*height = max(1, floor(tex->params.height / pow(2, mipmap)));
|
||||
*height = umax(1, tex->params.height / (1u << mipmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ Texture* gl33_texture_create(const TextureParams *params) {
|
|||
memcpy(&tex->params, params, sizeof(*params));
|
||||
TextureParams *p = &tex->params;
|
||||
|
||||
uint max_mipmaps = 1 + floor(log2(max(tex->params.width, tex->params.height)));
|
||||
uint max_mipmaps = 1 + floor(log2(umax(tex->params.width, tex->params.height))); // TODO replace with integer log2
|
||||
|
||||
if(p->mipmaps == 0) {
|
||||
if(p->mipmap_mode == TEX_MIPMAP_AUTO) {
|
||||
|
|
|
@ -127,7 +127,7 @@ static struct {
|
|||
static double global_font_scale(void) {
|
||||
float w, h;
|
||||
video_get_viewport_size(&w, &h);
|
||||
return sanitize_scale(((double)h / SCREEN_H) * config_get_float(CONFIG_TEXT_QUALITY));
|
||||
return fmax(0.1, ((double)h / SCREEN_H) * config_get_float(CONFIG_TEXT_QUALITY));
|
||||
}
|
||||
|
||||
static void reload_fonts(double quality);
|
||||
|
@ -146,7 +146,7 @@ static bool fonts_event(SDL_Event *event, void *arg) {
|
|||
case TE_CONFIG_UPDATED: {
|
||||
if(event->user.code == CONFIG_TEXT_QUALITY) {
|
||||
ConfigValue *val = event->user.data1;
|
||||
val->f = sanitize_scale(val->f);
|
||||
val->f = fmax(0.1, val->f);
|
||||
reload_fonts(global_font_scale());
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ static void set_fb_size(StageFBPair fb_id, int *w, int *h, float scale_worst, fl
|
|||
break;
|
||||
}
|
||||
|
||||
scale = sanitize_scale(scale);
|
||||
scale = fmax(0.1, scale);
|
||||
*w = round(VIEWPORT_W * scale);
|
||||
*h = round(VIEWPORT_H * scale);
|
||||
}
|
||||
|
@ -791,7 +791,7 @@ static void apply_bg_shaders(ShaderRule *shaderrules, FBPair *fbos) {
|
|||
r_shader("spellcard_outro");
|
||||
r_uniform_float("ratio", ratio);
|
||||
r_uniform_vec2("origin", creal(pos) / VIEWPORT_W, 1 - cimag(pos) / VIEWPORT_H);
|
||||
r_uniform_float("t", max(0, tn / delay + 1));
|
||||
r_uniform_float("t", fmax(0, tn / delay + 1));
|
||||
}
|
||||
|
||||
r_blend(BLEND_PREMUL_ALPHA);
|
||||
|
@ -1636,9 +1636,9 @@ void stage_draw_hud(void) {
|
|||
float extraspell_fadein = 1;
|
||||
|
||||
if(global.boss && global.boss->current && global.boss->current->type == AT_ExtraSpell) {
|
||||
extraspell_fadein = min(1, -min(0, global.frames - global.boss->current->starttime) / (float)ATTACK_START_DELAY);
|
||||
extraspell_fadein = fmin(1, -fmin(0, global.frames - global.boss->current->starttime) / (float)ATTACK_START_DELAY);
|
||||
float fadeout = global.boss->current->finished * (1 - (global.boss->current->endtime - global.frames) / (float)ATTACK_END_DELAY_EXTRA) / 0.74;
|
||||
float fade = max(extraspell_fadein, fadeout);
|
||||
float fade = fmax(extraspell_fadein, fadeout);
|
||||
extraspell_alpha = 1 - fade;
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ void stage_draw_hud(void) {
|
|||
|
||||
// Extra Spell indicator
|
||||
if(extraspell_alpha > 0) {
|
||||
float s2 = max(0, swing(extraspell_alpha, 3));
|
||||
float s2 = fmax(0, swing(extraspell_alpha, 3));
|
||||
r_state_push();
|
||||
r_shader("text_default");
|
||||
r_mat_mv_push();
|
||||
|
|
|
@ -1524,7 +1524,7 @@ DEFINE_EXTERN_TASK(stage1_spell_perfect_freeze) {
|
|||
|
||||
INVOKE_SUBTASK_DELAYED(120, move_frozen, &projs);
|
||||
|
||||
int d = max(0, global.diff - D_Normal);
|
||||
int d = imax(0, global.diff - D_Normal);
|
||||
for(int i = 0; i < 30+10*d; i++) {
|
||||
play_loop("shot1_loop");
|
||||
float r1, r2;
|
||||
|
|
|
@ -226,7 +226,7 @@ static void stage2_update(void) {
|
|||
stage_3d_context.cv[1] = approach(stage_3d_context.cv[1], 9, 0.05);
|
||||
}
|
||||
|
||||
stage_3d_context.crot[2] += min(0.5, -stage_3d_context.crot[2] * 0.02);
|
||||
stage_3d_context.crot[2] += fmin(0.5f, -stage_3d_context.crot[2] * 0.02f);
|
||||
|
||||
stage3d_update(&stage_3d_context);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ static int stage2_great_circle(Enemy *e, int t) {
|
|||
}
|
||||
|
||||
AT(210+global.diff*25) {
|
||||
e->hp = min(e->hp,200);
|
||||
e->hp = fmin(e->hp,200);
|
||||
e->args[0] = 2.0*I;
|
||||
}
|
||||
|
||||
|
@ -411,8 +411,8 @@ void hina_amulet(Boss *h, int time) {
|
|||
float f = _i/30.0;
|
||||
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);
|
||||
float speed = 1.0 + 0.75 * imax(0, global.diff - D_Normal);
|
||||
float accel = 1.0 + 1.20 * imax(0, global.diff - D_Normal);
|
||||
|
||||
cmplx p = h->pos+30*log(1+_i/2.0)*n;
|
||||
|
||||
|
@ -501,7 +501,7 @@ void hina_bad_pick(Boss *h, int time) {
|
|||
if(global.diff >= D_Hard) {
|
||||
double shift = 0;
|
||||
if(global.diff == D_Lunatic)
|
||||
shift = 0.3*max(0,t-200);
|
||||
shift = 0.3*fmax(0,t-200);
|
||||
for(i = 1; i < SLOTS; i++) {
|
||||
double height = VIEWPORT_H/SLOTS*i+shift;
|
||||
if(height > VIEWPORT_H-40)
|
||||
|
@ -531,7 +531,7 @@ void hina_bad_pick(Boss *h, int time) {
|
|||
if(i == win)
|
||||
continue;
|
||||
|
||||
float cnt = (1+min(D_Normal,global.diff)) * 5;
|
||||
float cnt = (1+imin(D_Normal,global.diff)) * 5;
|
||||
for(j = 0; j < cnt; j++) {
|
||||
cmplx o = VIEWPORT_W/SLOTS*(i + j/(cnt-1));
|
||||
|
||||
|
@ -579,13 +579,13 @@ void hina_wheel(Boss *h, int time) {
|
|||
return;
|
||||
}
|
||||
|
||||
FROM_TO_SND("shot1_loop", 0, 400, 5-(int)min(global.diff, D_Normal)) {
|
||||
FROM_TO_SND("shot1_loop", 0, 400, 5-imin(global.diff, D_Normal)) {
|
||||
int i;
|
||||
float speed = 10;
|
||||
if(time > 500)
|
||||
speed = 1+9*exp(-(time-500)/100.0);
|
||||
|
||||
float d = max(0, (int)global.diff - D_Normal);
|
||||
float d = imax(0, global.diff - D_Normal);
|
||||
|
||||
for(i = 1; i < 6+d; i++) {
|
||||
float a = dir * 2*M_PI/(5+d)*(i+(1 + 0.4 * d)*time/100.0+(1 + 0.2 * d)*frand()*time/1700.0);
|
||||
|
@ -621,7 +621,7 @@ static int hina_monty_slave(Enemy *s, int time) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(time > 60 && time < 720-140 + 20*(global.diff-D_Lunatic) && !(time % (int)(max(2 + (global.diff < D_Normal), (120 - 0.5 * time))))) {
|
||||
if(time > 60 && time < 720-140 + 20*(global.diff-D_Lunatic) && !(time % (int)(fmax(2 + (global.diff < D_Normal), (120 - 0.5 * time))))) {
|
||||
play_loop("shot1_loop");
|
||||
|
||||
PROJECTILE(
|
||||
|
@ -756,7 +756,7 @@ void hina_monty(Boss *h, int time) {
|
|||
play_sound("laser1");
|
||||
}
|
||||
|
||||
FROM_TO(220, 360 + 60 * max(0, (double)global.diff - D_Easy), 60) {
|
||||
FROM_TO(220, 360 + 60 * imax(0, global.diff - D_Easy), 60) {
|
||||
play_sound("shot_special1");
|
||||
|
||||
float cnt = (2.0+global.diff) * 5;
|
||||
|
|
|
@ -128,7 +128,7 @@ static bool stage3_glitch(Framebuffer *fb) {
|
|||
float strength;
|
||||
|
||||
if(global.boss && global.boss->current && ATTACK_IS_SPELL(global.boss->current->type) && !strcmp(global.boss->name, "Scuttle")) {
|
||||
strength = 0.05 * max(0, (global.frames - global.boss->current->starttime) / (double)global.boss->current->timeout);
|
||||
strength = 0.05 * fmax(0, (global.frames - global.boss->current->starttime) / (double)global.boss->current->timeout);
|
||||
} else {
|
||||
strength = 0.0;
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ static int stage3_cornerfairy(Enemy *e, int t) {
|
|||
GO_TO(e, e->args[0], 0.01)
|
||||
|
||||
FROM_TO_SND("shot1_loop", 140, 240, 1) {
|
||||
GO_TO(e, e->args[1], 0.025 * min((t - 120) / 42.0, 1))
|
||||
GO_TO(e, e->args[1], 0.025 * fmin((t - 120) / 42.0, 1))
|
||||
int d = 5; //(D_Lunatic - global.diff + 3);
|
||||
if(!(t % d)) {
|
||||
int i, cnt = 7+global.diff;
|
||||
|
@ -498,7 +498,7 @@ static void scuttle_outro(Boss *boss, int time) {
|
|||
spawn_items(boss->pos, ITEM_POINTS, 10, ITEM_POWER, 10, ITEM_LIFE, 1);
|
||||
}
|
||||
|
||||
boss->pos += pow(max(0, time)/30.0, 2) * cexp(I*(3*M_PI/2 + 0.5 * sin(time / 20.0)));
|
||||
boss->pos += pow(fmax(0, time)/30.0, 2) * cexp(I*(3*M_PI/2 + 0.5 * sin(time / 20.0)));
|
||||
}
|
||||
|
||||
static int scuttle_poison(Projectile *p, int time) {
|
||||
|
@ -596,7 +596,7 @@ static void scuttle_lethbite(Boss *boss, int time) {
|
|||
int cnt = 21 - 1 * (D_Lunatic - global.diff);
|
||||
|
||||
for(i = 0; i < 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);
|
||||
cmplx v = (2 - psin((fmax(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,
|
||||
|
@ -630,7 +630,7 @@ void scuttle_deadly_dance(Boss *boss, int time) {
|
|||
if(time > 30) {
|
||||
float angle_ofs = frand() * M_PI * 2;
|
||||
double t = time * 1.5 * (0.4 + 0.3 * global.diff);
|
||||
double moverad = min(160, time/2.7);
|
||||
double moverad = fmin(160, time/2.7);
|
||||
GO_TO(boss, VIEWPORT_W/2 + VIEWPORT_H*I/2 + sin(t/50.0) * moverad * cexp(I * M_PI_2 * t/100.0), 0.03)
|
||||
|
||||
if(!(time % 70)) {
|
||||
|
@ -1074,10 +1074,10 @@ void wriggle_night_ignite(Boss *boss, int time) {
|
|||
Laser *l1 = create_lasercurve3c(boss->pos, lt, dt, RGBA(b, b, 1.0, 0.0), las_sine_expanding, vel, amp, freq);
|
||||
wriggle_ignite_warnlaser(l1);
|
||||
|
||||
Laser *l2 = create_lasercurve3c(boss->pos, lt * 1.5, dt, RGBA(1.0, b, b, 0.0), las_sine_expanding, vel, amp, freq - 0.002 * min(global.diff, D_Hard));
|
||||
Laser *l2 = create_lasercurve3c(boss->pos, lt * 1.5, dt, RGBA(1.0, b, b, 0.0), las_sine_expanding, vel, amp, freq - 0.002 * fmin(global.diff, D_Hard));
|
||||
wriggle_ignite_warnlaser(l2);
|
||||
|
||||
Laser *l3 = create_lasercurve3c(boss->pos, lt, dt, RGBA(b, b, 1.0, 0.0), las_sine_expanding, vel, amp, freq - 0.004 * min(global.diff, D_Hard));
|
||||
Laser *l3 = create_lasercurve3c(boss->pos, lt, dt, RGBA(b, b, 1.0, 0.0), las_sine_expanding, vel, amp, freq - 0.004 * fmin(global.diff, D_Hard));
|
||||
wriggle_ignite_warnlaser(l3);
|
||||
|
||||
for(int i = 0; i < 5 + 15 * dfactor; ++i) {
|
||||
|
@ -1208,7 +1208,7 @@ void wriggle_light_singularity(Boss *boss, int time) {
|
|||
|
||||
DEPRECATED_DRAW_RULE
|
||||
static void wriggle_fstorm_proj_draw(Projectile *p, int time, ProjDrawRuleArgs args) {
|
||||
float f = 1-min(time/60.0,1);
|
||||
float f = 1-fmin(time/60.0,1);
|
||||
r_mat_mv_push();
|
||||
r_mat_mv_translate(creal(p->pos), cimag(p->pos), 0);
|
||||
r_mat_mv_rotate(p->angle + M_PI/2, 0, 0, 1);
|
||||
|
|
|
@ -1048,7 +1048,7 @@ static int kdanmaku_slave(Enemy *e, int t) {
|
|||
return ACTION_DESTROY;
|
||||
|
||||
if(e->args[2] && e->args[1]) {
|
||||
int i, n = 3+max(D_Normal,global.diff);
|
||||
int i, n = 3+imax(D_Normal,global.diff);
|
||||
float speed = 1.5+0.1*global.diff;
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
|
@ -1100,8 +1100,8 @@ void kurumi_danmaku(Boss *b, int time) {
|
|||
}
|
||||
|
||||
static void kurumi_extra_shield_pos(Enemy *e, int time) {
|
||||
double dst = 75 + 100 * max((60 - time) / 60.0, 0);
|
||||
double spd = cimag(e->args[0]) * min(time / 120.0, 1);
|
||||
double dst = 75 + 100 * fmax((60 - time) / 60.0, 0);
|
||||
double spd = cimag(e->args[0]) * fmin(time / 120.0, 1);
|
||||
e->args[0] += spd;
|
||||
e->pos = global.boss->pos + dst * cexp(I*creal(e->args[0]));
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ static int kurumi_extra_dead_shield_proj(Projectile *p, int time) {
|
|||
p->color = *color_lerp(
|
||||
RGBA(2.0, 0.0, 0.0, 0.0),
|
||||
RGBA(0.2, 0.1, 0.5, 0.0),
|
||||
min(time / 60.0f, 1.0f));
|
||||
fmin(time / 60.0f, 1.0f));
|
||||
|
||||
return asymptotic(p, time);
|
||||
}
|
||||
|
@ -1264,9 +1264,9 @@ static int kurumi_extra_drainer(Projectile *p, int time) {
|
|||
if(time > 40 && e->hp > 0) {
|
||||
// TODO: maybe add a special sound for this?
|
||||
|
||||
float drain = min(4, e->hp);
|
||||
float drain = fmin(4, e->hp);
|
||||
ent_damage(&e->ent, &(DamageInfo) { .amount = drain });
|
||||
global.boss->current->hp = min(global.boss->current->maxhp, global.boss->current->hp + drain * 2);
|
||||
global.boss->current->hp = fmin(global.boss->current->maxhp, global.boss->current->hp + drain * 2);
|
||||
}
|
||||
} else {
|
||||
p->args[2] = approach(p->args[2], 0, 0.5);
|
||||
|
@ -1543,13 +1543,13 @@ static int scythe_post_mid(Enemy *e, int t) {
|
|||
return ACTION_DESTROY;
|
||||
}
|
||||
|
||||
double scale = min(1.0, t / 60.0) * (1.0 - clamp((t - (fleetime - 60)) / 60.0, 0.0, 1.0));
|
||||
double scale = fmin(1.0, t / 60.0) * (1.0 - clamp((t - (fleetime - 60)) / 60.0, 0.0, 1.0));
|
||||
double alpha = scale * scale;
|
||||
double spin = (0.2 + 0.2 * (1.0 - alpha)) * 1.5;
|
||||
|
||||
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);
|
||||
double w = fmin(0.15, 0.0001*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);
|
||||
|
@ -1660,7 +1660,7 @@ void stage4_events(void) {
|
|||
|
||||
AT(3201) {
|
||||
if(global.boss) {
|
||||
global.timer += min(midboss_time, global.frames - global.boss->birthtime) - 1;
|
||||
global.timer += fmin(midboss_time, global.frames - global.boss->birthtime) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ static void stage6_update(void) {
|
|||
}
|
||||
|
||||
if(t >= 190)
|
||||
stage_3d_context.cx[2] -= max(6, 0.05*(global.frames-fall_over-150));
|
||||
stage_3d_context.cx[2] -= fmax(6, 0.05*(global.frames-fall_over-150));
|
||||
|
||||
FROM_TO(300, 470,1) {
|
||||
stage_3d_context.cx[0] -= 0.01*cos(M_PI/180*stage_3d_context.crot[2]+M_PI/2)*_i;
|
||||
|
@ -210,12 +210,12 @@ static void stage6_update(void) {
|
|||
float w = 0.002;
|
||||
float f = 1, g = 1;
|
||||
if(global.timer > 3273) {
|
||||
f = max(0, f-0.01*(global.timer-3273));
|
||||
f = fmax(0, f-0.01*(global.timer-3273));
|
||||
|
||||
}
|
||||
|
||||
if(global.timer > 3628)
|
||||
g = max(0, g-0.01*(global.timer - 3628));
|
||||
g = fmax(0, g-0.01*(global.timer - 3628));
|
||||
|
||||
stage_3d_context.cx[0] += -230*w*f*sin(w*global.frames-M_PI/2);
|
||||
stage_3d_context.cx[1] += 230*w*f*cos(w*global.frames-M_PI/2);
|
||||
|
|
|
@ -289,12 +289,12 @@ static int scythe_infinity(Enemy *e, int t) {
|
|||
TIMER(&t);
|
||||
FROM_TO(0, 40, 1) {
|
||||
GO_TO(e, VIEWPORT_W/2+200.0*I, 0.01);
|
||||
e->args[2] = min(0.8, creal(e->args[2])+0.0003*t*t);
|
||||
e->args[1] = creal(e->args[1]) + I*min(0.2, cimag(e->args[1])+0.0001*t*t);
|
||||
e->args[2] = fmin(0.8, creal(e->args[2])+0.0003*t*t);
|
||||
e->args[1] = creal(e->args[1]) + I*fmin(0.2, cimag(e->args[1])+0.0001*t*t);
|
||||
}
|
||||
|
||||
FROM_TO_SND("shot1_loop",40, 3000, 1) {
|
||||
float w = min(0.15, 0.0001*(t-40));
|
||||
float w = fmin(0.15, 0.0001*(t-40));
|
||||
e->pos = VIEWPORT_W/2 + 200.0*I + 200*cos(w*(t-40)+M_PI/2.0) + I*80*sin(creal(e->args[0])*w*(t-40));
|
||||
|
||||
PROJECTILE(
|
||||
|
@ -323,7 +323,7 @@ int scythe_reset(Enemy *e, int t) {
|
|||
e->args[1] = fmod(creal(e->args[1]), 2*M_PI) + I*cimag(e->args[1]);
|
||||
|
||||
GO_TO(e, BOSS_DEFAULT_GO_POS, 0.05);
|
||||
e->args[2] = max(0.6, creal(e->args[2])-0.01*t);
|
||||
e->args[2] = fmax(0.6, creal(e->args[2])-0.01*t);
|
||||
e->args[1] += (0.19-creal(e->args[1]))*0.05;
|
||||
e->args[1] = creal(e->args[1]) + I*0.9*cimag(e->args[1]);
|
||||
|
||||
|
@ -991,7 +991,7 @@ static void elly_paradigm_shift(Boss *b, int t) {
|
|||
}
|
||||
|
||||
if(t > 120)
|
||||
global.shake_view = max(0, 16-0.26*(t-120));
|
||||
global.shake_view = fmax(0, 16-0.26*(t-120));
|
||||
}
|
||||
|
||||
static void set_baryon_rule(EnemyLogicRule r) {
|
||||
|
@ -1099,7 +1099,7 @@ static int broglie_particle(Projectile *p, int t) {
|
|||
|
||||
if(laser) {
|
||||
cmplx oldpos = p->pos;
|
||||
p->pos = laser->prule(laser, min(t, cimag(p->args[1])));
|
||||
p->pos = laser->prule(laser, fmin(t, cimag(p->args[1])));
|
||||
|
||||
if(oldpos != p->pos) {
|
||||
p->angle = carg(p->pos - oldpos);
|
||||
|
@ -1140,7 +1140,7 @@ static void broglie_laser_logic(Laser *l, int t) {
|
|||
}
|
||||
|
||||
int dt = l->timespan * l->speed;
|
||||
float charge = min(1, pow((double)t / dt, 4));
|
||||
float charge = fmin(1, pow((double)t / dt, 4));
|
||||
l->color = *HSLA(hue, 1.0, 0.5 + 0.2 * charge, 0.0);
|
||||
l->width_exponent = 1.0 - 0.5 * charge;
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ static int baryon_nattack(Enemy *e, int t) {
|
|||
#define SAFE_RADIUS_MAX 150
|
||||
#define SAFE_RADIUS_SPEED 0.015
|
||||
#define SAFE_RADIUS_PHASE 3*M_PI/2
|
||||
#define SAFE_RADIUS_PHASE_FUNC(o) ((int)(creal(e->args[2])+0.5) * M_PI/3 + SAFE_RADIUS_PHASE + max(0, time - SAFE_RADIUS_DELAY) * SAFE_RADIUS_SPEED)
|
||||
#define SAFE_RADIUS_PHASE_FUNC(o) ((int)(creal(e->args[2])+0.5) * M_PI/3 + SAFE_RADIUS_PHASE + fmax(0, time - SAFE_RADIUS_DELAY) * SAFE_RADIUS_SPEED)
|
||||
#define SAFE_RADIUS_PHASE_NORMALIZED(o) (fmod(SAFE_RADIUS_PHASE_FUNC(o) - SAFE_RADIUS_PHASE, 2*M_PI) / (2*M_PI))
|
||||
#define SAFE_RADIUS_PHASE_NUM(o) ((int)((SAFE_RADIUS_PHASE_FUNC(o) - SAFE_RADIUS_PHASE) / (2*M_PI)))
|
||||
#define SAFE_RADIUS(o) smoothreclamp(SAFE_RADIUS_BASE + SAFE_RADIUS_STRETCH * sin(SAFE_RADIUS_PHASE_FUNC(o)), SAFE_RADIUS_BASE - SAFE_RADIUS_STRETCH, SAFE_RADIUS_BASE + SAFE_RADIUS_STRETCH, SAFE_RADIUS_MIN, SAFE_RADIUS_MAX)
|
||||
|
@ -1575,8 +1575,8 @@ static int ricci_proj(Projectile *p, int t) {
|
|||
p->angle = carg(p->args[0]);
|
||||
p->prevpos = p->pos;
|
||||
|
||||
float a = 0.5 + 0.5 * max(0,tanh((time-80)/100.))*clamp(influence,0.2,1);
|
||||
a *= min(1, t / 20.0f);
|
||||
float a = 0.5 + 0.5 * fmax(0,tanh((time-80)/100.))*clamp(influence,0.2,1);
|
||||
a *= fmin(1, t / 20.0f);
|
||||
|
||||
/*
|
||||
p->color = derive_color(p->color, CLRMASK_B|CLRMASK_A,
|
||||
|
@ -1822,7 +1822,7 @@ static int baryon_explode(Enemy *e, int t) {
|
|||
free_ref(e->args[1]);
|
||||
petal_explosion(24, e->pos);
|
||||
play_sound("boom");
|
||||
global.shake_view = max(15, global.shake_view);
|
||||
global.shake_view = fmaxf(15, global.shake_view);
|
||||
|
||||
for(uint i = 0; i < 3; ++i) {
|
||||
PARTICLE(
|
||||
|
@ -2084,7 +2084,7 @@ static void elly_baryon_explode(Boss *b, int t) {
|
|||
FROM_TO(0, 200, 1) {
|
||||
// tsrand_fill(2);
|
||||
// petal_explosion(1, b->pos + 100*afrand(0)*cexp(2.0*I*M_PI*afrand(1)));
|
||||
global.shake_view = max(global.shake_view, 5 * _i / 200.0);
|
||||
global.shake_view = fmaxf(global.shake_view, 5 * _i / 200.0f);
|
||||
|
||||
if(_i > 30) {
|
||||
play_loop("charge_generic");
|
||||
|
@ -2136,7 +2136,7 @@ static int elly_toe_boson_effect(Projectile *p, int t) {
|
|||
return ACTION_ACK;
|
||||
}
|
||||
|
||||
p->angle = creal(p->args[3]) * max(0, t) / (double)p->timeout;
|
||||
p->angle = creal(p->args[3]) * fmax(0, t) / (double)p->timeout;
|
||||
return ACTION_NONE;
|
||||
}
|
||||
|
||||
|
@ -2352,13 +2352,13 @@ static int elly_toe_fermion(Projectile *p, int t) {
|
|||
thiscolor_additive.a = 0;
|
||||
|
||||
if(t > 0 && t % 5 == 0) {
|
||||
double particle_scale = min(1.0, 0.5 * p->sprite->w / 28.0);
|
||||
double particle_scale = fmin(1.0, 0.5 * p->sprite->w / 28.0);
|
||||
|
||||
PARTICLE(
|
||||
.sprite = "stardust",
|
||||
.pos = p->pos,
|
||||
.color = &thiscolor_additive,
|
||||
.timeout = min(t / 6.0, 10),
|
||||
.timeout = fmin(t / 6.0, 10),
|
||||
.draw_rule = ScaleFade,
|
||||
.args = { 0, 0, particle_scale * (0.5 + 2 * I) },
|
||||
.angle = M_PI*2*frand(),
|
||||
|
@ -2414,7 +2414,7 @@ static int elly_toe_higgs(Projectile *p, int t) {
|
|||
|
||||
int global_time = global.frames - global.boss->current->starttime - HIGGSTIME;
|
||||
int max_time = SYMMETRYTIME - HIGGSTIME;
|
||||
double rotation = 0.5 * M_PI * max(0, (int)global.diff - D_Normal);
|
||||
double rotation = 0.5 * M_PI * fmax(0, (int)global.diff - D_Normal);
|
||||
|
||||
if(global_time > max_time) {
|
||||
global_time = max_time;
|
||||
|
@ -2894,7 +2894,7 @@ void elly_spellbg_toe(Boss *b, int t) {
|
|||
r_color(RGBA_MUL_ALPHA(1, 1, 1, 0.5*clamp((t-delays[i])*0.1,0,1)));
|
||||
char texname[33];
|
||||
snprintf(texname, sizeof(texname), "stage6/toelagrangian/%d", i);
|
||||
float wobble = max(0,t-BREAKTIME)*0.03;
|
||||
float wobble = fmax(0,t-BREAKTIME)*0.03;
|
||||