Merge branch 'newmenu' of github.com:laochailan/taisei into newmenu

This commit is contained in:
laochailan 2012-08-13 18:08:15 +02:00
commit 0799f127e8
11 changed files with 130 additions and 37 deletions

BIN
sfx/graze.wav Normal file

Binary file not shown.

View file

@ -23,6 +23,13 @@ Boss *create_boss(char *name, char *ani, complex pos) {
return buf;
}
void draw_boss_text(Alignment align, float x, float y, const char *text) {
glColor4f(0,0,0,1);
draw_text(align, x+1, y+1, text, _fonts.standard);
glColor4f(1,1,1,1);
draw_text(align, x, y, text, _fonts.standard);
}
void spell_opening(Boss *b, int time) {
float y = VIEWPORT_H - 15;
if(time > 40 && time <= 100)
@ -31,12 +38,12 @@ void spell_opening(Boss *b, int time) {
y = 35;
}
draw_text(AL_Right, VIEWPORT_W, y, b->current->name, _fonts.standard);
draw_boss_text(AL_Right, VIEWPORT_W, y, b->current->name);
}
void draw_boss(Boss *boss) {
draw_animation_p(creal(boss->pos), cimag(boss->pos) + 6*sin(global.frames/25.0), boss->anirow, boss->ani);
draw_text(AL_Left, 10, 20, boss->name, _fonts.standard);
draw_boss_text(AL_Left, 10, 20, boss->name);
if(!boss->current)
return;
@ -47,7 +54,7 @@ void draw_boss(Boss *boss) {
if(boss->current->type != AT_Move) {
char buf[16];
snprintf(buf, sizeof(buf), "%.2f", (boss->current->timeout - global.frames + boss->current->starttime)/(float)FPS);
draw_text(AL_Center, VIEWPORT_W - 20, 10, buf, _fonts.standard);
draw_boss_text(AL_Center, VIEWPORT_W - 20, 10, buf);
int nextspell, lastspell;
for(nextspell = 0; nextspell < boss->acount - 1; nextspell++) {

View file

@ -222,8 +222,10 @@ void global_processevent(SDL_Event *event)
{
if(sym == tconfig.intval[KEY_SCREENSHOT])
take_screenshot();
#ifndef WIN32 // TODO: remove when we're on SDL2
if((sym == SDLK_RETURN && (keys[SDLK_LALT] || keys[SDLK_RALT])) || sym == tconfig.intval[KEY_FULLSCREEN])
video_toggle_fullscreen();
#endif
} else if(event->type == SDL_QUIT) {
exit(0);
}

View file

@ -251,7 +251,7 @@ int bind_common_onoffset_inverted(void *b, int v)
int bind_fullscreen_set(void *b, int v)
{
#ifndef WIN32
#ifndef WIN32 // TODO: remove when we're on SDL2
video_toggle_fullscreen();
#endif
return bind_common_onoffset(b, v);
@ -329,9 +329,13 @@ void destroy_options_menu(MenuData *m)
for(i = 0; i < m->ecount; ++i) {
if(binds[i].type == BT_Resolution) {
if(binds[i].selected != -1) {
#ifndef WIN32
VideoMode *m = &(video.modes[binds[i].selected]);
#ifndef WIN32 // TODO: remove when we're on SDL2
video_setmode(m->width, m->height, tconfig.intval[FULLSCREEN]);
#else
video.intended.width = m->width;
video.intended.height = m->height;
#endif
tconfig.intval[VID_WIDTH] = video.intended.width;
@ -428,10 +432,12 @@ void create_options_menu(MenuData *m) {
add_menu_separator(m);
allocate_binding(m);
#ifndef WIN32 // TODO: remove when we're on SDL2
add_menu_entry(m, "Toggle fullscreen", do_nothing, NULL);
bind_keybinding(m, "key_fullscreen", KEY_FULLSCREEN);
#endif
add_menu_entry(m, "Take a screenshot", do_nothing, NULL);
bind_keybinding(m, "key_screenshot", KEY_SCREENSHOT);

View file

@ -242,10 +242,15 @@ void player_setmoveflag(Player* plr, int key, int mode) {
if(!flag)
return;
if(mode)
if(mode) {
plr->prevmove = plr->curmove;
plr->prevmovetime = plr->movetime;
plr->curmove = flag;
plr->moveflags |= flag;
else
plr->movetime = global.frames;
} else {
plr->moveflags &= ~flag;
}
}
void player_event(Player* plr, int type, int key) {
@ -328,6 +333,9 @@ void player_applymovement(Player* plr) {
if(!keys[tconfig.intval[KEY_SHOT]] && plr->fire) {
player_event(plr, EV_RELEASE, KEY_SHOT);
replay_event(&global.replay, EV_RELEASE, KEY_SHOT);
} else if(keys[tconfig.intval[KEY_SHOT]] && !plr->fire) {
player_event(plr, EV_PRESS, KEY_SHOT);
replay_event(&global.replay, EV_PRESS, KEY_SHOT);
}
if(!keys[tconfig.intval[KEY_FOCUS]] && plr->focus > 0) {

View file

@ -60,6 +60,10 @@ typedef struct {
Enemy *slaves;
int moveflags;
int curmove;
int movetime;
int prevmove;
int prevmovetime;
} Player;
void init_player(Player*);

View file

@ -137,13 +137,39 @@ int youmu_opposite_myon(Enemy *e, int t) {
float arg = carg(e->pos0);
float rad = cabs(e->pos0);
if(plr->focus < 15)
arg -= (carg(e->pos0)-carg(e->pos-plr->pos))*2;
if(plr->focus < 1) {
if(plr->moveflags && !creal(e->args[0]))
arg -= (carg(e->pos0)-carg(e->pos-plr->pos))*2;
//if(global.frames - plr->prevmovetime <= 10 && global.frames == plr->movetime) {
if(global.frames == plr->movetime) {
int new = plr->curmove;
int old = plr->prevmove;
if(new == MOVEFLAG_UP && old == MOVEFLAG_DOWN) {
arg = M_PI/2;
e->args[0] = plr->movetime;
} else if(new == MOVEFLAG_DOWN && old == MOVEFLAG_UP) {
arg = 3*M_PI/2;
e->args[0] = plr->movetime;
} else if(new == MOVEFLAG_LEFT && old == MOVEFLAG_RIGHT) {
arg = 0;
e->args[0] = plr->movetime;
} else if(new == MOVEFLAG_RIGHT && old == MOVEFLAG_LEFT) {
arg = M_PI;
e->args[0] = plr->movetime;
}
}
}
e->pos0 = rad*cexp(I*arg);
e->pos = e->pos0 + plr->pos;
if(creal(e->args[0]) && plr->movetime != creal(e->args[0]))
e->args[0] = 0;
if(plr->fire && !(global.frames % 6)) {
e->pos0 = rad * cexp(I*arg);
complex target = plr->pos + e->pos0;
e->pos += cexp(I*carg(target - e->pos)) * min(10, 0.07 * cabs(target - e->pos));
if(plr->fire && !(global.frames % 6) && global.plr.deathtime >= -1) {
int a = 20;
if(plr->power >= 3) {
@ -167,18 +193,23 @@ int youmu_split(Enemy *e, int t) {
TIMER(&t);
FROM_TO(30,260,1) {
FROM_TO(30,200,1) {
tsrand_fill(2);
create_particle2c("smoke", VIEWPORT_W/2 + VIEWPORT_H/2*I, rgba(0.4,0.4,0.4,afrand(0)*0.2+0.4), PartDraw, spin, 300, 6*cexp(I*afrand(1)*2*M_PI));
}
FROM_TO(100,220,10) {
FROM_TO(100,170,10) {
tsrand_fill(3);
create_particle1c("youmu_slice", VIEWPORT_W/2.0 + VIEWPORT_H/2.0*I - 200-200I + 400*afrand(0)+400I*afrand(1), NULL, Slice, timeout, 100-_i)->angle = 360.0*afrand(2);
}
float talt = atan((t-e->args[0]/2)/30.0)*10+atan(-e->args[0]/2);
global.plr.pos = VIEWPORT_W/2.0 + (VIEWPORT_H-80)*I + VIEWPORT_W/3.0*sin(talt);
FROM_TO(0, 220, 1) {
float talt = atan((t-e->args[0]/2)/30.0)*10+atan(-e->args[0]/2);
global.plr.pos = VIEWPORT_W/2.0 + (VIEWPORT_H-80)*I + VIEWPORT_W/3.0*sin(talt);
global.plr.moving = 1;
global.plr.dir = 1.0/(pow(e->args[0]/2-t,2) + 1)*cos(talt) < 0;
}
return 1;
}
@ -264,6 +295,10 @@ int mari_laser(Projectile *p, int t) {
if(REF(p->args[1]) == NULL)
return ACTION_DESTROY;
float angle = creal(p->args[2]);
float factor = (1-abs(global.plr.focus)/30.0) * !!angle;
complex dir = -cexp(I*((angle+0.025*sin(global.frames/50.0)*(angle > 0? 1 : -1))*factor + M_PI/2));
p->args[0] = 20*dir;
linear(p, t);
p->pos = ((Enemy *)REF(p->args[1]))->pos + p->pos;
@ -272,13 +307,13 @@ int mari_laser(Projectile *p, int t) {
}
int marisa_laser_slave(Enemy *e, int t) {
if(global.plr.fire && global.frames - global.plr.recovery >= 0) {
if(global.plr.fire && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
if(!(global.frames % 4))
create_projectile_p(&global.projs, get_tex("proj/marilaser"), 0, NULL, MariLaser, mari_laser, -20I, add_ref(e),0,0)->type = PlrProj+e->args[1]*4;
create_projectile_p(&global.projs, get_tex("proj/marilaser"), 0, NULL, MariLaser, mari_laser, 0, add_ref(e),e->args[2],0)->type = PlrProj+e->args[1]*4;
if(!(global.frames % 3)) {
float s = 0.5 + 0.3*sin(global.frames/7.0);
create_particle2c("marilaser_part0", 0, rgb(1-s,0.5,s), PartDraw, mari_laser, -15I, add_ref(e));
create_particle3c("marilaser_part0", 0, rgb(1-s,0.5,s), PartDraw, mari_laser, 0, add_ref(e), e->args[2]);
}
create_particle1c("lasercurve", e->pos, NULL, Fade, timeout, 4)->type = PlrProj;
}
@ -374,11 +409,11 @@ void MariStar(Projectile *p, int t) {
void MariStarBomb(Projectile *p, int t) {
MariStar(p, t);
create_particle1c("maristar_orbit", p->pos, NULL, GrowFade, timeout, 40);
create_particle1c("maristar_orbit", p->pos, NULL, GrowFadeAdd, timeout, 40);
}
int marisa_star_slave(Enemy *e, int t) {
if(global.plr.fire && global.frames - global.plr.recovery >= 0) {
if(global.plr.fire && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
if(!(global.frames % 20))
create_projectile_p(&global.projs, get_tex("proj/maristar"), e->pos, NULL, MariStar, accelerated, e->args[1], e->args[2], 0, 0)->type = PlrProj+e->args[3]*20;
}
@ -394,12 +429,12 @@ int marisa_star_orbit(Projectile *p, int t) { // a[0]: x' a[1]: x''
if(t < 0)
return 1;
if(t > 400)
if(t > 300)
return ACTION_DESTROY;
float r = cabs(p->pos0 - p->pos);
p->args[1] = (1e5-t*t)*cexp(I*carg(p->pos0 - p->pos))/(r*r);
p->args[1] = (0.5e5-t*t)*cexp(I*carg(p->pos0 - p->pos))/(r*r);
p->args[0] += p->args[1]*0.2;
p->pos += p->args[0];
@ -431,7 +466,7 @@ void marisa_bomb(Player *plr) {
break;
case MarisaStar:
for(i = 0; i < 20; i++) {
r = frand()*50 + 100;
r = frand()*40 + 100;
phi = frand()*2*M_PI;
create_particle1c("maristar_orbit", plr->pos + r*cexp(I*phi), NULL, MariStarBomb, marisa_star_orbit, I*r*cexp(I*(phi+frand()*0.5))/10);
}
@ -457,19 +492,19 @@ void marisa_power(Player *plr, float npow) {
switch(plr->shot) {
case MarisaLaser:
if((int)npow == 1)
create_enemy_p(&plr->slaves, -40I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -40I,5,0,0);
create_enemy_p(&plr->slaves, -40I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -40I, 5, 0, 0);
if(npow >= 2) {
create_enemy_p(&plr->slaves, 25-5I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, 8-40I,5,0,0);
create_enemy_p(&plr->slaves, -25-5I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -8-40I,5,0,0);
create_enemy_p(&plr->slaves, 25-5I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, 8-40I, 5, M_PI/30, 0);
create_enemy_p(&plr->slaves, -25-5I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -8-40I, 5, -M_PI/30, 0);
}
if((int)npow == 3)
create_enemy_p(&plr->slaves, -30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -50I,5,0,0);
create_enemy_p(&plr->slaves, -30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -50I, 5, 0, 0);
if(npow >= 4) {
create_enemy_p(&plr->slaves, 17-30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, 4-45I,5,0,0);
create_enemy_p(&plr->slaves, -17-30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -4-45I,5,0,0);
create_enemy_p(&plr->slaves, 17-30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, 4-45I, 5, 0, 0);
create_enemy_p(&plr->slaves, -17-30I, ENEMY_IMMUNE, MariLaserSlave, marisa_laser_slave, -4-45I, 5, 0, 0);
}
break;
case MarisaStar:

View file

@ -37,6 +37,7 @@ Projectile *create_projectile_p(Projectile **dest, Texture *tex, complex pos, Co
p->tex = tex;
p->type = FairyProj;
p->clr = clr;
p->grazed = 0;
p->args[0] = a1;
p->args[1] = a2;
@ -67,10 +68,24 @@ void delete_projectiles(Projectile **projs) {
int collision_projectile(Projectile *p) {
if(p->type == FairyProj) {
float angle = carg(global.plr.pos - p->pos) + p->angle;
int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*5/10.0 + pow(p->tex->h/2*sin(angle)*5/10.0,2));
int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*5/10.0 + pow(p->tex->h/2*sin(angle)*5/10.0,2));
double grazer = max(p->tex->w, p->tex->h);
grazer = (0.9 * sqrt(grazer) + 0.1 * grazer) * 5;
int dst = cabs(global.plr.pos - p->pos);
if(cabs(global.plr.pos - p->pos) < projr + 1)
if(dst < projr + 1)
return 1;
if(!p->grazed && dst < grazer) {
p->grazed = True;
global.points += 10;
play_sound("graze");
int i = 0; for(i = 0; i < 10; ++i) {
tsrand_fill(3);
create_particle2c("flare", p->pos - grazer * 0.3 * cexp(I*carg(p->pos - global.plr.pos)), NULL, Shrink, timeout_linear, 10 + 10 * afrand(2), (1+afrand(0)*5)*cexp(I*tsrand_a(1)));
}
}
} else if(p->type >= PlrProj) {
Enemy *e = global.enemies;
while(e != NULL) {
@ -82,7 +97,7 @@ int collision_projectile(Projectile *p) {
e = e->next;
}
if(global.boss && cabs(global.boss->pos - p->pos) < 15
if(global.boss && cabs(global.boss->pos - p->pos) < 42
&& global.boss->current->type != AT_Move && global.boss->current->type != AT_SurvivalSpell && global.boss->current->starttime < global.frames) {
global.boss->dmg += p->type - PlrProj;
return 2;

View file

@ -46,6 +46,7 @@ typedef struct Projectile {
Color *clr;
complex args[RULE_ARGC];
int grazed;
} Projectile;
Color *rgba(float r, float g, float b, float a);

View file

@ -472,6 +472,7 @@ void stage_loop(StageInfo* info, StageRule start, StageRule end, StageRule draw,
}
player_set_power(&global.plr, power);
global.plr.movetime = global.plr.prevmove = global.plr.prevmovetime = 0;
start();

View file

@ -561,8 +561,22 @@ int stage1_tritoss(Enemy *e, int t) {
void stage1_events(void) {
TIMER(&global.timer);
// AT(0)
// global.timer = 5000;
/*
// graze testing
AT(0) {
create_projectile1c("rice", 0.5*(VIEWPORT_W+VIEWPORT_H*1.3*I), rgb(1, 0.3, 0.3), linear, 0);
create_projectile1c("ball", 0.5*(VIEWPORT_W+VIEWPORT_H*1.5*I), rgb(1, 0.3, 0.3), linear, 0);
create_projectile1c("soul", 0.5*(VIEWPORT_W+VIEWPORT_H*I), rgb(1, 0.3, 0.3), linear, 0);
int i;
for(i = 0; i < 20; ++i) {
create_projectile1c("crystal", VIEWPORT_W/2+30 + (30+10*i)*I, rgb(0.7, 0.7, 1), linear, 0.01I);
create_projectile1c("crystal", VIEWPORT_W/2-30 + (30+10*i)*I, rgb(0.7, 0.7, 1), linear, 0.01I);
}
}
return;
*/
// opening. projectile bursts
FROM_TO(100, 160, 25) {