part of pre-midboss stage (wip)
This commit is contained in:
parent
b5f0d50761
commit
f590fb4bd8
5 changed files with 232 additions and 7 deletions
23
src/enemy.c
23
src/enemy.c
|
@ -24,6 +24,7 @@ void create_enemy_p(Enemy **enemies, complex pos, int hp, EnemyDrawRule draw_rul
|
|||
e->pos0 = pos;
|
||||
|
||||
e->hp = hp;
|
||||
e->alpha = 1.0;
|
||||
|
||||
e->logic_rule = logic_rule;
|
||||
e->draw_rule = draw_rule;
|
||||
|
@ -62,11 +63,25 @@ void delete_enemies(Enemy **enemies) {
|
|||
}
|
||||
|
||||
void draw_enemies(Enemy *enemies) {
|
||||
Enemy *e;
|
||||
Enemy *e;
|
||||
int reset = False;
|
||||
|
||||
for(e = enemies; e; e = e->next)
|
||||
if(e->draw_rule)
|
||||
for(e = enemies; e; e = e->next) {
|
||||
if(e->draw_rule) {
|
||||
if(e->alpha < 1) {
|
||||
e->alpha += 1 / 60.0;
|
||||
if(e->alpha > 1)
|
||||
e->alpha = 1;
|
||||
|
||||
glColor4f(1,1,1,e->alpha);
|
||||
reset = True;
|
||||
}
|
||||
|
||||
e->draw_rule(e, global.frames - e->birthtime);
|
||||
if(reset)
|
||||
glColor4f(1,1,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,4 +213,4 @@ void process_enemies(Enemy **enemies) {
|
|||
enemy = enemy->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ struct Enemy {
|
|||
int hp;
|
||||
|
||||
complex args[RULE_ARGC];
|
||||
float alpha;
|
||||
};
|
||||
|
||||
#define create_enemy4c(p,h,d,l,a1,a2,a3,a4) create_enemy_p(&global.enemies,p,h,d,l,a1,a2,a3,a4)
|
||||
|
@ -64,4 +65,4 @@ void BigFairy(Enemy*, int t);
|
|||
int enemy_flare(Projectile *p, int t);
|
||||
void EnemyFlareShrink(Projectile *p, int t);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -357,4 +357,4 @@ void petal_explosion(int n, complex pos) {
|
|||
for(i = 0; i < n; i++) {
|
||||
create_particle4c("petal", pos, rgba(0.6,1-frand()*0.4,0.5,1-0.5*frand()), Petal, asymptotic, (3+5*frand())*cexp(I*M_PI*2*frand()), 5, frand() + frand()*I, frand() + 360I*frand());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ void replay_input() {
|
|||
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
global_processevent(&event);
|
||||
int sym = event.key.keysym.sym;
|
||||
|
||||
switch(event.type) {
|
||||
|
@ -108,6 +109,7 @@ void stage_input() {
|
|||
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
global_processevent(&event);
|
||||
int sym = event.key.keysym.sym;
|
||||
int key = config_sym2key(sym);
|
||||
|
||||
|
|
|
@ -10,5 +10,212 @@
|
|||
#include "stage.h"
|
||||
#include "enemy.h"
|
||||
|
||||
float nfrand() {
|
||||
return (frand() - 0.5) * 2;
|
||||
}
|
||||
|
||||
int stage2_enterswirl(Enemy *e, int t) {
|
||||
TIMER(&t)
|
||||
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 1, 1, 0, 0);
|
||||
|
||||
float r, g;
|
||||
if(frand() > 0.5) {
|
||||
r = 0.3 + 0.3 * frand();
|
||||
g = 1;
|
||||
} else {
|
||||
r = 1;
|
||||
g = 0.3 + 0.3 * frand();
|
||||
}
|
||||
|
||||
float a; for(a = 0; a < M_PI * 2; a += 1.3 - global.diff * 0.2) {
|
||||
complex dir = sin(a) + I * cos(a);
|
||||
float spd = 1 + 0.5 * sin(10 * a);
|
||||
|
||||
create_projectile2c("rice", e->pos, rgb(r, g, 1), accelerated,
|
||||
dir * 2,
|
||||
dir * spd * -0.03
|
||||
);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AT(EVENT_BIRTH) {
|
||||
e->alpha = 0;
|
||||
}
|
||||
|
||||
AT(60) {
|
||||
e->hp = 0;
|
||||
}
|
||||
|
||||
e->pos += e->args[0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stage2_slavefairy(Enemy *e, int t) {
|
||||
TIMER(&t)
|
||||
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 1, 3, 0, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
AT(EVENT_BIRTH) {
|
||||
e->alpha = 0;
|
||||
}
|
||||
|
||||
GO_TO(e, e->args[0], 0.03)
|
||||
|
||||
FROM_TO_INT(30, 120, 5 - global.diff, 1, 1) {
|
||||
float a = global.timer * 0.5;
|
||||
if(_i % 2)
|
||||
a = -a;
|
||||
complex dir = sin(a) + I * cos(a);
|
||||
|
||||
create_projectile2c("wave", e->pos + dir * 10, (global.timer % 2)? rgb(1.0, 0.6, 0.6) : rgb(0.6, 0.6, 1.0), accelerated,
|
||||
dir * 3,
|
||||
dir * -0.05
|
||||
);
|
||||
}
|
||||
|
||||
AT(120) {
|
||||
e->hp = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stage2_bigfairy(Enemy *e, int t) {
|
||||
TIMER(&t)
|
||||
|
||||
AT(EVENT_DEATH) {
|
||||
if(e->args[0])
|
||||
spawn_items(e->pos, 5, 5, 0, 1);
|
||||
else
|
||||
spawn_items(e->pos, 3, 3, 1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
AT(EVENT_BIRTH) {
|
||||
e->alpha = 0;
|
||||
}
|
||||
|
||||
FROM_TO(30, 600, 270) {
|
||||
create_enemy1c(e->pos, 300, Fairy, stage2_slavefairy, e->pos + 70 + 50 * I);
|
||||
create_enemy1c(e->pos, 300, Fairy, stage2_slavefairy, e->pos - 70 + 50 * I);
|
||||
}
|
||||
|
||||
FROM_TO(120, 600, 270) {
|
||||
create_enemy1c(e->pos, 300, Fairy, stage2_slavefairy, e->pos + 70 - 50 * I);
|
||||
create_enemy1c(e->pos, 300, Fairy, stage2_slavefairy, e->pos - 70 - 50 * I);
|
||||
}
|
||||
|
||||
AT(600)
|
||||
e->hp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stage2_bitchswirl(Enemy *e, int t) {
|
||||
TIMER(&t)
|
||||
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 1, 1, 0, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
FROM_TO(0, 120, 20) {
|
||||
float c = 0.25 + 0.25 * sin(t / 5.0);
|
||||
|
||||
create_projectile2c("flea", e->pos, rgb(1.0 - c, 0.6, 0.5 + c), accelerated,
|
||||
2*cexp(I*carg(global.plr.pos - e->pos)),
|
||||
0.005*cexp(I*(M_PI_2 * nfrand()))
|
||||
);
|
||||
}
|
||||
|
||||
e->pos -= 5I;
|
||||
|
||||
AT(120) {
|
||||
e->hp = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stage2_cornerfairy(Enemy *e, int t) {
|
||||
TIMER(&t)
|
||||
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 5, 5, 0, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
AT(EVENT_BIRTH) {
|
||||
e->alpha = 0;
|
||||
}
|
||||
|
||||
FROM_TO(0, 60, 1)
|
||||
GO_TO(e, e->args[0], 0.01)
|
||||
|
||||
FROM_TO(60, 120, 1) {
|
||||
GO_TO(e, e->args[1], 0.05)
|
||||
|
||||
if(!(t % (D_Lunatic - global.diff + 2))) {
|
||||
float i; for(i = -M_PI; i <= M_PI; i += 1.0) {
|
||||
float c = 0.25 + 0.25 * sin(t / 5.0);
|
||||
|
||||
create_projectile2c("thickrice", e->pos, rgb(1.0 - c, 0.6, 0.5 + c), asymptotic,
|
||||
//2*cexp(I*(carg(global.plr.pos - e->pos) + i)),
|
||||
2*cexp(I*(i+carg((VIEWPORT_W+I*VIEWPORT_H)/2 - e->pos))),
|
||||
1.5
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AT(180)
|
||||
e->hp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage2_events() {
|
||||
}
|
||||
TIMER(&global.timer);
|
||||
|
||||
//AT(0)
|
||||
// global.timer = 1460;
|
||||
|
||||
FROM_TO(160, 300, 10) {
|
||||
create_enemy1c(VIEWPORT_W/2 + 20 * nfrand() + (VIEWPORT_H/4 + 20 * nfrand())*I, 200, Swirl, stage2_enterswirl, I * 3 + nfrand() * 3);
|
||||
}
|
||||
|
||||
AT(400) {
|
||||
create_enemy1c(VIEWPORT_W/2 + (VIEWPORT_H/3)*I, 10000, BigFairy, stage2_bigfairy, 0);
|
||||
}
|
||||
|
||||
FROM_TO(1000, 1300, 10) {
|
||||
create_enemy1c(20 + (VIEWPORT_H+20)*I, 50, Swirl, stage2_bitchswirl, 0);
|
||||
create_enemy1c(VIEWPORT_W-20 + (VIEWPORT_H+20)*I, 50, Swirl, stage2_bitchswirl, 0);
|
||||
}
|
||||
|
||||
AT(1400) {
|
||||
create_enemy1c(VIEWPORT_W/2 + (VIEWPORT_H/3)*I, 10000, BigFairy, stage2_bigfairy, 1);
|
||||
}
|
||||
|
||||
FROM_TO(2200, 2420, 130) {
|
||||
double offs = -50;
|
||||
|
||||
complex p1 = 0+0I;
|
||||
complex p2 = VIEWPORT_W+0I;
|
||||
complex p3 = VIEWPORT_W + VIEWPORT_H*I;
|
||||
complex p4 = 0+VIEWPORT_H*I;
|
||||
|
||||
create_enemy2c(p1, 500, Fairy, stage2_cornerfairy, p1 - offs - offs*I, p2 + offs - offs*I);
|
||||
create_enemy2c(p2, 500, Fairy, stage2_cornerfairy, p2 + offs - offs*I, p3 + offs + offs*I);
|
||||
create_enemy2c(p3, 500, Fairy, stage2_cornerfairy, p3 + offs + offs*I, p4 - offs + offs*I);
|
||||
create_enemy2c(p4, 500, Fairy, stage2_cornerfairy, p4 - offs + offs*I, p1 - offs - offs*I);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue