Merge branch 'master' into stage5
Conflicts: src/laser.c
This commit is contained in:
commit
c29cd0e45b
3 changed files with 33 additions and 27 deletions
36
src/laser.c
36
src/laser.c
|
@ -9,7 +9,7 @@
|
|||
#include "global.h"
|
||||
#include "list.h"
|
||||
|
||||
Laser *create_laser(LaserType type, complex pos, complex pos0, int time, int deathtime, Color *color, LaserRule rule, complex args, ...) {
|
||||
Laser *create_laser_p(LaserType type, complex pos, complex dir, int time, int deathtime, Color *color, LaserRule rule, complex a0, complex a1, complex a2, complex a3) {
|
||||
Laser *l = create_element((void **)&global.lasers, sizeof(Laser));
|
||||
|
||||
l->type = type;
|
||||
|
@ -17,27 +17,20 @@ Laser *create_laser(LaserType type, complex pos, complex pos0, int time, int dea
|
|||
l->time = time;
|
||||
l->deathtime = deathtime;
|
||||
l->pos = pos;
|
||||
l->pos0 = pos0;
|
||||
l->dir = dir;
|
||||
l->rule = rule;
|
||||
l->color = color;
|
||||
|
||||
l->args[0] = a0;
|
||||
l->args[1] = a1;
|
||||
l->args[2] = a2;
|
||||
l->args[3] = a3;
|
||||
|
||||
va_list ap;
|
||||
int i;
|
||||
|
||||
va_start(ap, args);
|
||||
for(i = 0; i < 4 && args; i++) {
|
||||
l->args[i++] = args;
|
||||
args = va_arg(ap, complex);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
// play_sound("laser1");
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
void draw_laser_line(Laser *laser) {
|
||||
float width = cabs(laser->pos0);
|
||||
float width = cabs(laser->dir);
|
||||
if(global.frames - laser->birthtime < laser->time*3/5.0)
|
||||
width = 2;
|
||||
else if(global.frames - laser->birthtime < laser->time)
|
||||
|
@ -47,7 +40,7 @@ void draw_laser_line(Laser *laser) {
|
|||
|
||||
glPushMatrix();
|
||||
glTranslatef(creal(laser->pos), cimag(laser->pos),0);
|
||||
glRotatef(carg(laser->pos0)*180/M_PI,0,0,1);
|
||||
glRotatef(carg(laser->dir)*180/M_PI,0,0,1);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("part/lasercurve")->gltex);
|
||||
|
||||
|
@ -128,10 +121,13 @@ void process_lasers() {
|
|||
|
||||
while(laser != NULL) {
|
||||
int c = 0;
|
||||
if(laser->type == LT_Line)
|
||||
if(laser->type == LT_Line) {
|
||||
if(laser->rule)
|
||||
laser->rule(laser, global.frames - laser->birthtime);
|
||||
c = collision_laser_line(laser);
|
||||
else
|
||||
} else {
|
||||
c = collision_laser_curve(laser);
|
||||
}
|
||||
|
||||
if(c && global.frames - laser->birthtime > laser->time)
|
||||
player_death(&global.plr);
|
||||
|
@ -149,9 +145,9 @@ void process_lasers() {
|
|||
|
||||
int collision_laser_line(Laser *l) {
|
||||
Player *plr = &global.plr;
|
||||
float x = creal(l->pos) + creal(l->pos0)/cimag(l->pos0)*(cimag(plr->pos) - cimag(l->pos));
|
||||
float x = creal(l->pos) + creal(l->dir)/cimag(l->dir)*(cimag(plr->pos) - cimag(l->pos));
|
||||
|
||||
if(fabs(creal(plr->pos) - x) < fabs(creal(l->pos0*I)/2))
|
||||
if(fabs(creal(plr->pos) - x) < fabs(creal(l->dir*I)/2))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
|
14
src/laser.h
14
src/laser.h
|
@ -27,7 +27,7 @@ typedef struct Laser {
|
|||
LaserType type;
|
||||
|
||||
complex pos;
|
||||
complex pos0; // if type == LaserLine, carg(pos0) is orientation and cabs(pos0) width
|
||||
complex dir; // if type == LaserLine, carg(pos0) is orientation and cabs(pos0) width
|
||||
|
||||
Color *color;
|
||||
|
||||
|
@ -39,7 +39,17 @@ typedef struct Laser {
|
|||
complex args[4];
|
||||
} Laser;
|
||||
|
||||
Laser *create_laser(LaserType type, complex pos, complex pos0, int time, int deathtime, Color *color, LaserRule rule, complex args, ...);
|
||||
#define create_lasercurve1c(p, time, deathtime, clr, rule, a0) create_laser_p(LT_Curve, p, 0, time, deathtime, clr, rule, a0, 0, 0, 0)
|
||||
#define create_lasercurve2c(p, time, deathtime, clr, rule, a0, a1) create_laser_p(LT_Curve, p, 0, time, deathtime, clr, rule, a0, a1, 0, 0)
|
||||
#define create_lasercurve3c(p, time, deathtime, clr, rule, a0, a1, a2) create_laser_p(LT_Curve, p, 0, time, deathtime, clr, rule, a0, a1, a2, 0)
|
||||
#define create_lasercurve4c(p, time, deathtime, clr, rule, a0, a1, a2, a3) create_laser_p(LT_Curve, p, 0, time, deathtime, clr, rule, a0, a1, a2, a3)
|
||||
|
||||
#define create_laserline1c(p, prop, time, deathtime, clr, rule, a0) create_laser_p(LT_Line, p, prop, time, deathtime, clr, rule, a0, 0, 0, 0)
|
||||
#define create_laserline2c(p, prop, time, deathtime, clr, rule, a0, a1) create_laser_p(LT_Line, p, prop, time, deathtime, clr, rule, a0, a1, 0, 0)
|
||||
#define create_laserline3c(p, prop, time, deathtime, clr, rule, a0, a1, a2) create_laser_p(LT_Line, p, prop, time, deathtime, clr, rule, a0, a1, a2, 0)
|
||||
#define create_laserline4c(p, prop, time, deathtime, clr, rule, a0, a1, a2, a3) create_laser_p(LT_Line, p, prop, time, deathtime, clr, rule, a0, a1, a2, a3)
|
||||
|
||||
Laser *create_laser_p(LaserType type, complex pos, complex dir, int time, int deathtime, Color *color, LaserRule rule, complex a0, complex a1, complex a2, complex a3);
|
||||
void draw_lasers();
|
||||
void delete_lasers();
|
||||
void process_lasers();
|
||||
|
|
|
@ -531,9 +531,9 @@ void kurumi_aniwall(Boss *b, int time) {
|
|||
return;
|
||||
|
||||
AT(60) {
|
||||
create_laser(LT_Curve, b->pos, 0, 50, 80, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(0.4I));
|
||||
create_lasercurve1c(b->pos, 50, 80, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(0.4I));
|
||||
create_enemy1c(b->pos, ENEMY_IMMUNE, KurumiAniWallSlave, aniwall_slave, 0.2*cexp(0.4I));
|
||||
create_laser(LT_Curve, b->pos, 0, 50, 80, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*M_PI - 0.4I));
|
||||
create_lasercurve1c(b->pos, 50, 80, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*M_PI - 0.4I));
|
||||
create_enemy1c(b->pos, ENEMY_IMMUNE, KurumiAniWallSlave, aniwall_slave, 0.2*cexp(I*M_PI - 0.4I));
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ int blowwall_slave(Enemy *e, int t) {
|
|||
|
||||
|
||||
static void bwlaser(Boss *b, float arg, int slave) {
|
||||
create_laser(LT_Curve, b->pos, 0, 50, 100, rgb(1, 0.5+0.3*slave, 0.5+0.3*slave), kurumi_wall_laser, (0.1+0.1*slave)*cexp(I*arg));
|
||||
create_lasercurve1c(b->pos, 50, 100, rgb(1, 0.5+0.3*slave, 0.5+0.3*slave), kurumi_wall_laser, (0.1+0.1*slave)*cexp(I*arg));
|
||||
if(slave)
|
||||
create_enemy1c(b->pos, ENEMY_IMMUNE, NULL, blowwall_slave, 0.2*cexp(I*arg));
|
||||
}
|
||||
|
@ -689,8 +689,8 @@ void kurumi_danmaku(Boss *b, int time) {
|
|||
return;
|
||||
|
||||
AT(50) {
|
||||
create_laser(LT_Curve, b->pos, 0, 50, 100, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*carg(-b->pos)));
|
||||
create_laser(LT_Curve, b->pos, 0, 50, 100, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*carg(VIEWPORT_W-b->pos)));
|
||||
create_lasercurve1c(b->pos, 50, 100, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*carg(-b->pos)));
|
||||
create_lasercurve1c(b->pos, 50, 100, rgb(1, 0.8, 0.8), kurumi_wall_laser, 0.2*cexp(I*carg(VIEWPORT_W-b->pos)));
|
||||
create_enemy3c(b->pos, ENEMY_IMMUNE, KurumiAniWallSlave, kdanmaku_slave, 0.2*cexp(I*carg(-b->pos)), 0, 1);
|
||||
create_enemy3c(b->pos, ENEMY_IMMUNE, KurumiAniWallSlave, kdanmaku_slave, 0.2*cexp(I*carg(VIEWPORT_W-b->pos)), 0, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue