wriggle animation in stage 2
This commit is contained in:
parent
b83b563acf
commit
aaa6ad29e9
5 changed files with 37 additions and 7 deletions
|
@ -1,3 +1,3 @@
|
|||
rows = 1
|
||||
cols = 1
|
||||
speed = 10
|
||||
rows = 2
|
||||
cols = 6
|
||||
speed = 5
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 31 KiB |
|
@ -43,6 +43,18 @@ AniSequence *aniplayer_queue(AniPlayer *plr, int row, int loops, int delay) {
|
|||
return s;
|
||||
}
|
||||
|
||||
AniSequence *aniplayer_queue_pro(AniPlayer *plr, int row, int start, int end, int delay, int speed) {
|
||||
AniSequence *s = aniplayer_queue(plr,row,0,delay);
|
||||
// i bet you didn’t expect the _pro function calling the plain one
|
||||
s->speed = speed;
|
||||
|
||||
if(speed <= 0)
|
||||
speed = plr->ani->speed;
|
||||
s->duration = end*speed;
|
||||
s->clock = start*speed;
|
||||
return s;
|
||||
}
|
||||
|
||||
void aniplayer_update(AniPlayer *plr) {
|
||||
plr->clock++;
|
||||
if(plr->queue) {
|
||||
|
@ -62,10 +74,15 @@ void aniplayer_update(AniPlayer *plr) {
|
|||
void aniplayer_play(AniPlayer *plr, float x, float y) {
|
||||
int col = (plr->clock/plr->ani->speed) % plr->ani->cols;
|
||||
int row = plr->stdrow;
|
||||
int speed = plr->ani->speed;
|
||||
bool mirror = plr->mirrored;
|
||||
if(plr->queue) {
|
||||
AniSequence *s = plr->queue;
|
||||
col = ((1-2*s->backwards)*s->clock/plr->ani->speed+s->duration) % plr->ani->cols;
|
||||
if(s->speed > 0)
|
||||
speed = s->speed;
|
||||
col = (s->clock/speed) % plr->ani->cols;
|
||||
if(s->backwards)
|
||||
col = ((s->duration-s->clock)/speed) % plr->ani->cols;
|
||||
row = s->row;
|
||||
|
||||
mirror = s->mirrored;
|
||||
|
|
|
@ -24,6 +24,7 @@ struct AniSequence{
|
|||
int duration; // number of frames this sequence will be drawn
|
||||
int clock;
|
||||
int delay; // after the sequence has played loops times before the next one is started.
|
||||
int speed; // overrides ani->speed if > 0
|
||||
|
||||
bool mirrored;
|
||||
bool backwards;
|
||||
|
@ -46,6 +47,7 @@ void aniplayer_free(AniPlayer *plr);
|
|||
void aniplayer_reset(AniPlayer *plr); // resets to a neutral state with empty queue.
|
||||
|
||||
AniSequence *aniplayer_queue(AniPlayer *plr, int row, int loops, int delay); // 0 loops: played one time
|
||||
AniSequence *aniplayer_queue_pro(AniPlayer *plr, int row, int start, int duration, int delay, int speed); // self-documenting pro version
|
||||
void aniplayer_update(AniPlayer *plr); // makes the inner clocks tick
|
||||
void aniplayer_play(AniPlayer *plr, float x, float y);
|
||||
|
||||
|
|
|
@ -214,9 +214,17 @@ int stage2_accel_circle(Enemy *e, int t) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void wriggle_ani_flyin(Boss *w) {
|
||||
aniplayer_queue_pro(&w->ani,1,3,3,120,0);
|
||||
aniplayer_queue_pro(&w->ani,1,3,21,0,7);
|
||||
aniplayer_queue_pro(&w->ani,1,3,33,0,3);
|
||||
aniplayer_queue_pro(&w->ani,1,3,12,0,0);
|
||||
}
|
||||
|
||||
void wriggle_intro(Boss *w, int t) {
|
||||
if(t != EVENT_DEATH)
|
||||
w->pos = VIEWPORT_W/2 + 100.0*I + 400*(1.0-t/(4.0*FPS))*cexp(I*(3-t*0.04));
|
||||
if(t < 0)
|
||||
return;
|
||||
w->pos = VIEWPORT_W/2 + 100.0*I + 300*(1.0-t/(4.0*FPS))*cexp(I*(3-t*0.04));
|
||||
}
|
||||
|
||||
int wriggle_bug(Projectile *p, int t) {
|
||||
|
@ -252,14 +260,16 @@ void wriggle_small_storm(Boss *w, int time) {
|
|||
|
||||
if(!(t%200)) {
|
||||
int i;
|
||||
aniplayer_queue(&w->ani,1,0,0)->speed=4;
|
||||
play_sound("shot_special1");
|
||||
for(i = 0; i < 10+global.diff; i++) {
|
||||
play_sound("shot_special1");
|
||||
create_projectile2c("bigball", w->pos, rgb(0.1,0.3,0.0), asymptotic, 2*cexp(I*i*2*M_PI/(10+global.diff)), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wiggle_mid_flee(Boss *w, int t) {
|
||||
w->ani.stdrow = 1;
|
||||
if(t >= 0) {
|
||||
GO_TO(w, VIEWPORT_W/2 - 3.0 * t - 300 * I, 0.01)
|
||||
}
|
||||
|
@ -267,6 +277,7 @@ void wiggle_mid_flee(Boss *w, int t) {
|
|||
|
||||
Boss *create_wriggle_mid(void) {
|
||||
Boss* wriggle = create_boss("Wriggle", "wriggle", "dialog/wriggle", VIEWPORT_W + 150 - 30.0*I);
|
||||
wriggle_ani_flyin(wriggle);
|
||||
boss_add_attack(wriggle, AT_Move, "Introduction", 4, 0, wriggle_intro, NULL);
|
||||
boss_add_attack(wriggle, AT_Normal, "Small Bug Storm", 20, 26000, wriggle_small_storm, NULL);
|
||||
boss_add_attack(wriggle, AT_Move, "Flee", 5, 0, wiggle_mid_flee, NULL);;
|
||||
|
|
Loading…
Reference in a new issue