WIP de Broglie tweaks

This commit is contained in:
Andrei Alexeyev 2017-10-22 05:52:37 +03:00
parent f21e35f459
commit 2290d9c2ea
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
4 changed files with 41 additions and 19 deletions

View file

@ -10,6 +10,7 @@ uniform vec2 pos;
uniform float timeshift;
uniform float wq;
uniform float hq;
uniform float width_exponent;
uniform int span;
float pi = 2.0 * asin(1.0);
@ -41,7 +42,7 @@ void main(void) {
mat2 m = mat2(cos(a), -sin(a), sin(a), cos(a));
v.x *= wq*1.5*length(d);
v.y *= hq*s;
v.y *= hq*pow(s, width_exponent);
gl_Position = gl_ModelViewProjectionMatrix*vec4(m*v+pos, 0.0, 1.0);
gl_TexCoord[0] = gl_MultiTexCoord0;

View file

@ -30,6 +30,7 @@ Laser *create_laser(complex pos, float time, float deathtime, Color color, Laser
l->shader = NULL;
l->collision_step = 5;
l->width = 10;
l->width_exponent = 1.0;
l->speed = 1;
l->timeshift = 0;
l->in_background = false;
@ -97,6 +98,7 @@ void draw_laser_curve_instanced(Laser *l) {
glUniform1f(uniloc(l->shader, "timeshift"), t);
glUniform1f(uniloc(l->shader, "wq"), wq*l->width);
glUniform1f(uniloc(l->shader, "hq"), hq*l->width);
glUniform1f(uniloc(l->shader, "width_exponent"), l->width_exponent);
glUniform1i(uniloc(l->shader, "span"), c*2);
@ -130,6 +132,7 @@ void draw_laser_curve(Laser *laser) {
float tail = laser->timespan/1.9;
float s = -0.75/pow(tail,2)*(t1-tail)*(t1+tail);
s = pow(s, laser->width_exponent);
glTranslatef(creal(pos), cimag(pos), 0);
glRotatef(180/M_PI*carg(last-pos), 0, 0, 1);
@ -268,6 +271,7 @@ int collision_laser_curve(Laser *l) {
float t1 = t - ((global.frames - l->birthtime)*l->speed - l->timespan/2 + l->timeshift);
float tail = l->timespan/1.9;
float s = -0.75/pow(tail,2)*(t1-tail)*(t1+tail);
s = pow(s, l->width_exponent);
if(collision_line(last, pos, global.plr.pos, s*l->width*0.5))
return 1;

View file

@ -33,6 +33,7 @@ struct Laser {
float timeshift;
float speed;
float width;
float width_exponent;
Shader *shader;

View file

@ -743,7 +743,7 @@ int broglie_particle(Projectile *p, int t) {
double angle_ampl = creal(p->args[3]);
double angle_freq = cimag(p->args[3]);
p->angle += angle_ampl * sin(t * angle_freq);
p->angle += angle_ampl * sin(t * angle_freq) * cos(2 * t * angle_freq);
p->args[2] = -cabs(p->args[2]) * cexp(I*p->angle);
}
@ -767,11 +767,10 @@ void broglie_laser_logic(Laser *l, int t) {
return;
}
int dt = l->deathtime + l->timespan * l->speed;
log_debug("%i %i", t, dt);
l->color = hsl(hue, 1.0, 0.5 + 0.3 * pow((double)t / dt, 2));
int dt = l->timespan * l->speed;
float charge = min(1, pow((double)t / dt, 4));
l->color = hsl(hue, 1.0, 0.5 + 0.2 * charge);
l->width_exponent = 1.0 - 0.5 * charge;
}
int broglie_charge(Projectile *p, int t) {
@ -785,14 +784,14 @@ int broglie_charge(Projectile *p, int t) {
int attack_num = creal(p->args[2]);
double hue = creal(p->args[3]);
complex aim = p->args[0];
double dt = 200;
p->pos -= p->args[0] * 15;
complex aim = cexp(I*p->angle);
double s_ampl = 30 + 2 * attack_num;
double s_freq = 0.10 + 0.01 * attack_num;
for(int lnum = 0; lnum < 2; ++lnum) {
Laser *l = create_lasercurve4c(p->pos - aim * 15, dt, dt/2, 0, las_sine,
Laser *l = create_lasercurve4c(p->pos, 75, 100, 0, las_sine,
5*aim, s_ampl, s_freq, lnum * M_PI +
I*(hue + lnum * (M_PI/12)/(M_PI/2)));
@ -802,7 +801,7 @@ int broglie_charge(Projectile *p, int t) {
int pnum = 0;
double inc = pow(1.10 - 0.10 * (global.diff - D_Easy), 2);
for(double ofs = 0; ofs < dt; ofs += inc, ++pnum) {
for(double ofs = 0; ofs < l->deathtime; ofs += inc, ++pnum) {
complex pos = l->prule(l, ofs);
bool fast = global.diff == D_Easy || pnum & 1;
@ -811,8 +810,8 @@ int broglie_charge(Projectile *p, int t) {
Projectile *part = create_projectile4c(txt, pos,
hsl(hue + lnum * (M_PI/12)/(M_PI/2), 1.0, 0.5), broglie_particle,
add_ref(l), I*ofs + dt + ofs - 10, spd,
(1 + 2 * ((global.diff - 1) / (double)(D_Lunatic - 1))) * M_PI/11 + s_freq*5*I);
add_ref(l), I*ofs + l->timespan + ofs - 10, spd,
(1 + 2 * ((global.diff - 1) / (double)(D_Lunatic - 1))) * M_PI/11 + s_freq*10*I);
part->draw = ProjNoDraw;
part->type = FakeProj;
@ -820,6 +819,11 @@ int broglie_charge(Projectile *p, int t) {
}
return ACTION_DESTROY;
} else {
float f = pow(clamp((120 - (firetime - t)) / 90.0, 0, 1), 8);
complex o = p->pos - p->args[0] * 15;
p->args[0] *= cexp(I*M_PI*0.2*f);
p->pos = o + p->args[0] * 15;
}
return 1;
@ -862,22 +866,32 @@ int baryon_broglie(Enemy *e, int t) {
}
int delay = 140;
int step = 30;
int step = 15;
int cnt = 3;
int fire_delay = 120;
static double aim_angle;
AT(delay) {
aim_angle = carg(e->pos - global.boss->pos);
}
FROM_TO(delay, delay + step * cnt - 1, step) {
double a = 2*M_PI * (0.25 + 1.0/cnt*_i);
complex n = cexp(I*a);
double hue = (attack_num * M_PI + a + M_PI/6) / (M_PI*2);
create_projectile4c("ball", e->pos + 15*n,
Projectile *p = create_projectile4c("ball", e->pos + 15*n,
hsl(hue, 1.0, 0.55),
broglie_charge, n, fire_delay - step * _i, attack_num, hue)->draw = ProjDrawAdd;
broglie_charge, n, (fire_delay - step * _i), attack_num, hue
);
p->draw = ProjDrawAdd;
p->angle = (2*M_PI*_i)/cnt + aim_angle;
}
if(t < delay || t > delay + fire_delay) {
if(t < delay /*|| t > delay + fire_delay*/) {
complex target_pos = global.boss->pos + 100 * cexp(I*carg(global.plr.pos - global.boss->pos));
GO_TO(e, target_pos, 0.03);
}
@ -904,14 +918,16 @@ void elly_broglie(Boss *b, int t) {
double ofs = 100;
complex positions[] = {
VIEWPORT_W-ofs + ofs*I,
VIEWPORT_W-ofs + ofs*I,
ofs + (VIEWPORT_H-ofs)*I,
VIEWPORT_W-ofs + (VIEWPORT_H-ofs)*I,
ofs + ofs*I,
ofs + ofs*I,
VIEWPORT_W-ofs + (VIEWPORT_H-ofs)*I,
};
if(t/period > 0) {
GO_TO(b, positions[(t/(period*2)) % (sizeof(positions)/sizeof(complex))], 0.02);
GO_TO(b, positions[(t/period) % (sizeof(positions)/sizeof(complex))], 0.02);
}
}