update stage bg state separately from drawing
This commit is contained in:
parent
6eac178c39
commit
36f4182829
12 changed files with 130 additions and 114 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "credits.h"
|
||||
#include "global.h"
|
||||
#include "stageutils.h"
|
||||
#include "stages/stage6.h"
|
||||
#include "video.h"
|
||||
|
||||
typedef struct CreditsEntry {
|
||||
|
@ -79,9 +79,6 @@ void credits_add(char *data, int time) {
|
|||
credits.end += time + CREDITS_ENTRY_FADEOUT;
|
||||
}
|
||||
|
||||
Vector **stage6_towerwall_pos(Vector pos, float maxrange);
|
||||
void stage6_towerwall_draw(Vector pos);
|
||||
|
||||
void credits_skysphere_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -555,6 +555,8 @@ static bool stage_frame(void *arg) {
|
|||
stage_finish(GAMEOVER_WIN);
|
||||
fstate->transition_delay = 60;
|
||||
}
|
||||
|
||||
stage->procs->update();
|
||||
}
|
||||
|
||||
if(!global.timer && stage->type != STAGE_SPELL) {
|
||||
|
@ -617,6 +619,7 @@ void stage_loop(StageInfo *stage) {
|
|||
assert(stage->procs->end);
|
||||
assert(stage->procs->draw);
|
||||
assert(stage->procs->event);
|
||||
assert(stage->procs->update);
|
||||
assert(stage->procs->shader_rules);
|
||||
|
||||
if(global.game_over == GAMEOVER_WIN) {
|
||||
|
|
|
@ -76,6 +76,7 @@ struct StageProcs {
|
|||
StageProc end;
|
||||
StageProc draw;
|
||||
StageProc event;
|
||||
StageProc update;
|
||||
ShaderRule *shader_rules;
|
||||
ShaderRule *postprocess_rules;
|
||||
StageProcs *spellpractice_procs;
|
||||
|
|
|
@ -46,7 +46,7 @@ static bool particle_filter(Projectile *part) {
|
|||
return part->type < PlrProj;
|
||||
}
|
||||
|
||||
void stage1_bg_draw(Vector pos) {
|
||||
static void stage1_bg_draw(Vector pos) {
|
||||
glPushMatrix();
|
||||
glTranslatef(0,stage_3d_context.cx[1]+500,0);
|
||||
glRotatef(180,1,0,0);
|
||||
|
@ -84,12 +84,12 @@ void stage1_bg_draw(Vector pos) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
Vector **stage1_bg_pos(Vector p, float maxrange) {
|
||||
static Vector **stage1_bg_pos(Vector p, float maxrange) {
|
||||
Vector q = {0,0,0};
|
||||
return single3dpos(p, INFINITY, q);
|
||||
}
|
||||
|
||||
void stage1_smoke_draw(Vector pos) {
|
||||
static void stage1_smoke_draw(Vector pos) {
|
||||
float d = fabsf(pos[1]-stage_3d_context.cx[1]);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -107,13 +107,13 @@ void stage1_smoke_draw(Vector pos) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
Vector **stage1_smoke_pos(Vector p, float maxrange) {
|
||||
static Vector **stage1_smoke_pos(Vector p, float maxrange) {
|
||||
Vector q = {0,0,-300};
|
||||
Vector r = {0,300,0};
|
||||
return linear3dpos(p, maxrange/2.0, q, r);
|
||||
}
|
||||
|
||||
void stage1_fog(FBO *fbo) {
|
||||
static void stage1_fog(FBO *fbo) {
|
||||
Shader *shader = get_shader("zbuf_fog");
|
||||
|
||||
glUseProgram(shader->prog);
|
||||
|
@ -132,13 +132,16 @@ void stage1_fog(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage1_draw(void) {
|
||||
static void stage1_draw(void) {
|
||||
set_perspective(&stage_3d_context, 500, 5000);
|
||||
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
}
|
||||
|
||||
void stage1_reed_draw(Vector pos) {
|
||||
static void stage1_update(void) {
|
||||
update_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
static void stage1_reed_draw(Vector pos) {
|
||||
float d = -55+50*sin(pos[1]/25.0);
|
||||
glPushMatrix();
|
||||
glTranslatef(pos[0]+200*sin(pos[1]), pos[1], d);
|
||||
|
@ -161,7 +164,7 @@ void stage1_reed_draw(Vector pos) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void stage1_start(void) {
|
||||
static void stage1_start(void) {
|
||||
init_stage3d(&stage_3d_context);
|
||||
add_model(&stage_3d_context, stage1_bg_draw, stage1_bg_pos);
|
||||
add_model(&stage_3d_context, stage1_smoke_draw, stage1_smoke_pos);
|
||||
|
@ -172,7 +175,7 @@ void stage1_start(void) {
|
|||
stage_3d_context.cv[1] = 4;
|
||||
}
|
||||
|
||||
void stage1_preload(void) {
|
||||
static void stage1_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage1", "stage1boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage1/cirnobg",
|
||||
|
@ -191,11 +194,11 @@ void stage1_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage1_end(void) {
|
||||
static void stage1_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage1_spellpractice_events(void) {
|
||||
static void stage1_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
|
@ -215,6 +218,7 @@ StageProcs stage1_procs = {
|
|||
.preload = stage1_preload,
|
||||
.end = stage1_end,
|
||||
.draw = stage1_draw,
|
||||
.update = stage1_update,
|
||||
.event = stage1_events,
|
||||
.shader_rules = stage1_shaders,
|
||||
.spellpractice_procs = &stage1_spell_procs,
|
||||
|
@ -225,6 +229,7 @@ StageProcs stage1_spell_procs = {
|
|||
.begin = stage1_start,
|
||||
.end = stage1_end,
|
||||
.draw = stage1_draw,
|
||||
.update = stage1_update,
|
||||
.event = stage1_spellpractice_events,
|
||||
.shader_rules = stage1_shaders,
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ struct stage2_spells_s stage2_spells = {
|
|||
hina_monty, hina_spell_bg, BOSS_DEFAULT_GO_POS},
|
||||
};
|
||||
|
||||
void stage2_bg_leaves_draw(Vector pos) {
|
||||
static void stage2_bg_leaves_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glUseProgram(get_shader("alpha_depth")->prog);
|
||||
|
||||
|
@ -80,7 +80,6 @@ static void stage2_bg_grass_draw(Vector pos) {
|
|||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
}
|
||||
|
||||
static void stage2_bg_ground_draw(Vector pos) {
|
||||
|
@ -131,21 +130,21 @@ static void stage2_bg_ground_draw(Vector pos) {
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
Vector **stage2_bg_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage2_bg_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 0, 0};
|
||||
Vector r = {0, 1000, 0};
|
||||
|
||||
return linear3dpos(pos, maxrange, p, r);
|
||||
}
|
||||
|
||||
Vector **stage2_bg_grass_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage2_bg_grass_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 0, 0};
|
||||
Vector r = {0, 2000, 0};
|
||||
|
||||
return linear3dpos(pos, maxrange, p, r);
|
||||
}
|
||||
|
||||
Vector **stage2_bg_grass_pos2(Vector pos, float maxrange) {
|
||||
static Vector **stage2_bg_grass_pos2(Vector pos, float maxrange) {
|
||||
Vector p = {0, 1234, 40};
|
||||
Vector r = {0, 2000, 0};
|
||||
|
||||
|
@ -181,7 +180,7 @@ static void stage2_bloom(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage2_start(void) {
|
||||
static void stage2_start(void) {
|
||||
init_stage3d(&stage_3d_context);
|
||||
stage_3d_context.cx[2] = 1000;
|
||||
stage_3d_context.cx[0] = -850;
|
||||
|
@ -196,7 +195,7 @@ void stage2_start(void) {
|
|||
add_model(&stage_3d_context, stage2_bg_leaves_draw, stage2_bg_pos);
|
||||
}
|
||||
|
||||
void stage2_preload(void) {
|
||||
static void stage2_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage2", "stage2boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage2/border",
|
||||
|
@ -219,30 +218,32 @@ void stage2_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage2_end(void) {
|
||||
static void stage2_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage2_draw(void) {
|
||||
static void stage2_draw(void) {
|
||||
set_perspective(&stage_3d_context, 500, 5000);
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
}
|
||||
|
||||
static void stage2_update(void) {
|
||||
TIMER(&global.frames);
|
||||
|
||||
set_perspective(&stage_3d_context, 500, 5000);
|
||||
|
||||
FROM_TO(0,180,1) {
|
||||
FROM_TO(0, 180, 1) {
|
||||
stage_3d_context.cv[0] -= 0.05;
|
||||
stage_3d_context.cv[1] += 0.05;
|
||||
stage_3d_context.crot[2] += 0.5;
|
||||
}
|
||||
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
|
||||
update_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage2_spellpractice_events(void) {
|
||||
static void stage2_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
skip_background_anim(&stage_3d_context, stage2_draw, 180, &global.frames, NULL);
|
||||
skip_background_anim(&stage_3d_context, stage2_update, 180, &global.frames, NULL);
|
||||
|
||||
Boss* hina = stage2_spawn_hina(BOSS_DEFAULT_SPAWN_POS);
|
||||
boss_add_attack_from_info(hina, global.stage->spell, true);
|
||||
|
@ -260,6 +261,7 @@ StageProcs stage2_procs = {
|
|||
.preload = stage2_preload,
|
||||
.end = stage2_end,
|
||||
.draw = stage2_draw,
|
||||
.update = stage2_update,
|
||||
.event = stage2_events,
|
||||
.shader_rules = stage2_shaders,
|
||||
.spellpractice_procs = &stage2_spell_procs,
|
||||
|
@ -270,6 +272,7 @@ StageProcs stage2_spell_procs = {
|
|||
.begin = stage2_start,
|
||||
.end = stage2_end,
|
||||
.draw = stage2_draw,
|
||||
.update = stage2_update,
|
||||
.event = stage2_spellpractice_events,
|
||||
.shader_rules = stage2_shaders,
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ static struct {
|
|||
float tunnel_side;
|
||||
} stgstate;
|
||||
|
||||
Vector **stage3_bg_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage3_bg_pos(Vector pos, float maxrange) {
|
||||
//Vector p = {100 * cos(global.frames / 52.0), 100, 50 * sin(global.frames / 50.0)};
|
||||
Vector p = {
|
||||
stgstate.tunnel_side * cos(global.frames / 52.0),
|
||||
|
@ -64,7 +64,7 @@ Vector **stage3_bg_pos(Vector pos, float maxrange) {
|
|||
return linear3dpos(pos, maxrange, p, r);
|
||||
}
|
||||
|
||||
void stage3_bg_tunnel_draw(Vector pos) {
|
||||
static void stage3_bg_tunnel_draw(Vector pos) {
|
||||
int n = 6;
|
||||
float r = 300;
|
||||
int i;
|
||||
|
@ -88,7 +88,7 @@ void stage3_bg_tunnel_draw(Vector pos) {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void stage3_tunnel(FBO *fbo) {
|
||||
static void stage3_tunnel(FBO *fbo) {
|
||||
Shader *shader = get_shader("tunnel");
|
||||
assert(uniloc(shader, "mixfactor") >= 0); // just so people don't forget to 'make install'; remove this later
|
||||
|
||||
|
@ -104,7 +104,7 @@ void stage3_tunnel(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage3_fog(FBO *fbo) {
|
||||
static void stage3_fog(FBO *fbo) {
|
||||
Shader *shader = get_shader("zbuf_fog");
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
|
@ -123,7 +123,7 @@ void stage3_fog(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage3_glitch(FBO *fbo) {
|
||||
static void stage3_glitch(FBO *fbo) {
|
||||
Shader *shader = get_shader("glitch");
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
|
@ -147,7 +147,7 @@ void stage3_glitch(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage3_start(void) {
|
||||
static void stage3_start(void) {
|
||||
init_stage3d(&stage_3d_context);
|
||||
|
||||
stage_3d_context.cx[2] = -10;
|
||||
|
@ -164,7 +164,7 @@ void stage3_start(void) {
|
|||
stgstate.fog_brightness = 0.5;
|
||||
}
|
||||
|
||||
void stage3_preload(void) {
|
||||
static void stage3_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage3", "stage3boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage3/border",
|
||||
|
@ -186,23 +186,26 @@ void stage3_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage3_end(void) {
|
||||
static void stage3_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage3_draw(void) {
|
||||
static void stage3_draw(void) {
|
||||
set_perspective(&stage_3d_context, 300, 5000);
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
}
|
||||
|
||||
static void stage3_update(void) {
|
||||
TIMER(&global.timer)
|
||||
|
||||
set_perspective(&stage_3d_context, 300, 5000);
|
||||
stgstate.tunnel_angle += stgstate.tunnel_avel;
|
||||
stage_3d_context.crot[2] = -(creal(global.plr.pos)-VIEWPORT_W/2)/80.0;
|
||||
|
||||
if(global.dialog) {
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
update_stage3d(&stage_3d_context);
|
||||
return;
|
||||
}
|
||||
|
||||
#if 1
|
||||
FROM_TO(0, 160, 1) {
|
||||
stage_3d_context.cv[1] -= 0.5/2;
|
||||
stgstate.clr_r -= 0.2 / 160.0;
|
||||
|
@ -341,24 +344,22 @@ void stage3_draw(void) {
|
|||
stgstate.clr_r = approach(stgstate.clr_r, 0.6, 1.0/200.0);
|
||||
stgstate.clr_g = approach(stgstate.clr_g, 0.3, 1.0/200.0);
|
||||
stgstate.clr_b = approach(stgstate.clr_b, 0.4, 1.0/200.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
draw_stage3d(&stage_3d_context, 7000);
|
||||
update_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void scuttle_spellbg(Boss*, int t);
|
||||
|
||||
void stage3_spellpractice_events(void) {
|
||||
static void stage3_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
if(global.stage->spell->draw_rule == scuttle_spellbg) {
|
||||
skip_background_anim(&stage_3d_context, stage3_draw, 2800, &global.timer, NULL);
|
||||
skip_background_anim(&stage_3d_context, stage3_update, 2800, &global.timer, NULL);
|
||||
global.boss = stage3_spawn_scuttle(BOSS_DEFAULT_SPAWN_POS);
|
||||
} else {
|
||||
skip_background_anim(&stage_3d_context, stage3_draw, 5300 + STAGE3_MIDBOSS_TIME, &global.timer, NULL);
|
||||
skip_background_anim(&stage_3d_context, stage3_update, 5300 + STAGE3_MIDBOSS_TIME, &global.timer, NULL);
|
||||
global.boss = stage3_spawn_wriggle_ex(BOSS_DEFAULT_SPAWN_POS);
|
||||
}
|
||||
|
||||
|
@ -370,7 +371,7 @@ void stage3_spellpractice_events(void) {
|
|||
}
|
||||
|
||||
void stage3_skip(int t) {
|
||||
skip_background_anim(&stage_3d_context, stage3_draw, t, &global.timer, &global.frames);
|
||||
skip_background_anim(&stage_3d_context, stage3_update, t, &global.timer, &global.frames);
|
||||
audio_backend_music_set_position(global.timer / (double)FPS);
|
||||
}
|
||||
|
||||
|
@ -382,6 +383,7 @@ StageProcs stage3_procs = {
|
|||
.preload = stage3_preload,
|
||||
.end = stage3_end,
|
||||
.draw = stage3_draw,
|
||||
.update = stage3_update,
|
||||
.event = stage3_events,
|
||||
.shader_rules = stage3_shaders,
|
||||
.postprocess_rules = stage3_postprocess,
|
||||
|
@ -393,6 +395,7 @@ StageProcs stage3_spell_procs = {
|
|||
.begin = stage3_start,
|
||||
.end = stage3_end,
|
||||
.draw = stage3_draw,
|
||||
.update = stage3_update,
|
||||
.event = stage3_spellpractice_events,
|
||||
.shader_rules = stage3_shaders,
|
||||
.postprocess_rules = stage3_postprocess,
|
||||
|
|
|
@ -43,7 +43,7 @@ struct stage4_spells_s stage4_spells = {
|
|||
kurumi_extra, kurumi_spell_bg, BOSS_DEFAULT_GO_POS},
|
||||
};
|
||||
|
||||
void stage4_fog(FBO *fbo) {
|
||||
static void stage4_fog(FBO *fbo) {
|
||||
Shader *shader = get_shader("zbuf_fog");
|
||||
|
||||
float f = 0;
|
||||
|
@ -69,7 +69,7 @@ void stage4_fog(FBO *fbo) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
Vector **stage4_fountain_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage4_fountain_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 400, 1500};
|
||||
Vector r = {0, 0, 3000};
|
||||
|
||||
|
@ -85,7 +85,7 @@ Vector **stage4_fountain_pos(Vector pos, float maxrange) {
|
|||
return list;
|
||||
}
|
||||
|
||||
void stage4_fountain_draw(Vector pos) {
|
||||
static void stage4_fountain_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage2/border")->gltex);
|
||||
|
||||
|
@ -101,7 +101,7 @@ void stage4_fountain_draw(Vector pos) {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
Vector **stage4_lake_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage4_lake_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 600, 0};
|
||||
Vector d;
|
||||
|
||||
|
@ -124,7 +124,7 @@ Vector **stage4_lake_pos(Vector pos, float maxrange) {
|
|||
}
|
||||
}
|
||||
|
||||
void stage4_lake_draw(Vector pos) {
|
||||
static void stage4_lake_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage4/lake")->gltex);
|
||||
|
||||
|
@ -148,7 +148,7 @@ void stage4_lake_draw(Vector pos) {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
Vector **stage4_corridor_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage4_corridor_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 2400, 50};
|
||||
Vector r = {0, 2000, 0};
|
||||
|
||||
|
@ -164,7 +164,7 @@ Vector **stage4_corridor_pos(Vector pos, float maxrange) {
|
|||
return list;
|
||||
}
|
||||
|
||||
void stage4_corridor_draw(Vector pos) {
|
||||
static void stage4_corridor_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage4/planks")->gltex);
|
||||
|
||||
|
@ -222,7 +222,7 @@ void stage4_corridor_draw(Vector pos) {
|
|||
glColor3f(1,1,1);
|
||||
}
|
||||
|
||||
void stage4_start(void) {
|
||||
static void stage4_start(void) {
|
||||
init_stage3d(&stage_3d_context);
|
||||
|
||||
stage_3d_context.cx[2] = -10000;
|
||||
|
@ -240,7 +240,7 @@ void stage4_start(void) {
|
|||
add_model(&stage_3d_context, stage4_corridor_draw, stage4_corridor_pos);
|
||||
}
|
||||
|
||||
void stage4_preload(void) {
|
||||
static void stage4_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage4", "stage4boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage2/border", // Stage 2 is intentional!
|
||||
|
@ -265,14 +265,17 @@ void stage4_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage4_end(void) {
|
||||
static void stage4_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage4_draw(void) {
|
||||
static void stage4_draw(void) {
|
||||
set_perspective(&stage_3d_context, 130, 3000);
|
||||
|
||||
draw_stage3d(&stage_3d_context, 4000);
|
||||
}
|
||||
|
||||
static void stage4_update(void) {
|
||||
update_stage3d(&stage_3d_context);
|
||||
|
||||
if(stage_3d_context.cx[2] >= -1000 && stage_3d_context.cv[2] > 0)
|
||||
stage_3d_context.cv[2] -= 0.17;
|
||||
|
@ -287,11 +290,11 @@ void stage4_draw(void) {
|
|||
stage_3d_context.cv[1] += 0.02;
|
||||
}
|
||||
|
||||
void stage4_spellpractice_events(void) {
|
||||
static void stage4_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
skip_background_anim(&stage_3d_context, stage4_draw, 3200, &global.frames, NULL);
|
||||
skip_background_anim(&stage_3d_context, stage4_update, 3200, &global.frames, NULL);
|
||||
global.boss = stage4_spawn_kurumi(BOSS_DEFAULT_SPAWN_POS);
|
||||
boss_add_attack_from_info(global.boss, global.stage->spell, true);
|
||||
boss_start_attack(global.boss, global.boss->attacks);
|
||||
|
@ -301,7 +304,7 @@ void stage4_spellpractice_events(void) {
|
|||
}
|
||||
|
||||
void stage4_skip(int t) {
|
||||
skip_background_anim(&stage_3d_context, stage4_draw, t, &global.timer, &global.frames);
|
||||
skip_background_anim(&stage_3d_context, stage4_update, t, &global.timer, &global.frames);
|
||||
audio_backend_music_set_position(global.timer / (double)FPS);
|
||||
}
|
||||
|
||||
|
@ -312,6 +315,7 @@ StageProcs stage4_procs = {
|
|||
.preload = stage4_preload,
|
||||
.end = stage4_end,
|
||||
.draw = stage4_draw,
|
||||
.update = stage4_update,
|
||||
.event = stage4_events,
|
||||
.shader_rules = stage4_shaders,
|
||||
.spellpractice_procs = &stage4_spell_procs,
|
||||
|
@ -322,6 +326,7 @@ StageProcs stage4_spell_procs = {
|
|||
.begin = stage4_start,
|
||||
.end = stage4_end,
|
||||
.draw = stage4_draw,
|
||||
.update = stage4_update,
|
||||
.event = stage4_spellpractice_events,
|
||||
.shader_rules = stage4_shaders,
|
||||
};
|
||||
|
|
|
@ -44,14 +44,14 @@ struct {
|
|||
float rad;
|
||||
} stagedata;
|
||||
|
||||
Vector **stage5_stairs_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage5_stairs_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 0, 0};
|
||||
Vector r = {0, 0, 6000};
|
||||
|
||||
return linear3dpos(pos, maxrange, p, r);
|
||||
}
|
||||
|
||||
void stage5_stairs_draw(Vector pos) {
|
||||
static void stage5_stairs_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage5/tower")->gltex);
|
||||
|
||||
|
@ -74,9 +74,13 @@ void stage5_stairs_draw(Vector pos) {
|
|||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage5_draw(void) {
|
||||
static void stage5_draw(void) {
|
||||
set_perspective(&stage_3d_context, 100, 20000);
|
||||
draw_stage3d(&stage_3d_context, 30000);
|
||||
}
|
||||
|
||||
static void stage5_update(void) {
|
||||
update_stage3d(&stage_3d_context);
|
||||
|
||||
TIMER(&global.timer);
|
||||
float w = 0.005;
|
||||
|
@ -135,7 +139,7 @@ void iku_spell_bg(Boss *b, int t) {
|
|||
glColor4f(1,1,1,1);
|
||||
}
|
||||
|
||||
void stage5_start(void) {
|
||||
static void stage5_start(void) {
|
||||
memset(&stagedata, 0, sizeof(stagedata));
|
||||
|
||||
init_stage3d(&stage_3d_context);
|
||||
|
@ -146,7 +150,7 @@ void stage5_start(void) {
|
|||
stagedata.rad = 2800;
|
||||
}
|
||||
|
||||
void stage5_preload(void) {
|
||||
static void stage5_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage5", "stage5boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage5/noise",
|
||||
|
@ -168,12 +172,12 @@ void stage5_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage5_end(void) {
|
||||
static void stage5_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void stage5_skip(int t) {
|
||||
skip_background_anim(&stage_3d_context, stage5_draw, t, &global.timer, &global.frames);
|
||||
skip_background_anim(&stage_3d_context, stage5_update, t, &global.timer, &global.frames);
|
||||
|
||||
int mskip = global.timer;
|
||||
|
||||
|
@ -184,11 +188,11 @@ void stage5_skip(int t) {
|
|||
audio_backend_music_set_position(mskip / (double)FPS);
|
||||
}
|
||||
|
||||
void stage5_spellpractice_events(void) {
|
||||
static void stage5_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
skip_background_anim(&stage_3d_context, stage5_draw, 5300, &global.timer, NULL);
|
||||
skip_background_anim(&stage_3d_context, stage5_update, 6960, &global.timer, NULL);
|
||||
global.boss = stage5_spawn_iku(BOSS_DEFAULT_SPAWN_POS);
|
||||
boss_add_attack_from_info(global.boss, global.stage->spell, true);
|
||||
boss_start_attack(global.boss, global.boss->attacks);
|
||||
|
@ -204,6 +208,7 @@ StageProcs stage5_procs = {
|
|||
.preload = stage5_preload,
|
||||
.end = stage5_end,
|
||||
.draw = stage5_draw,
|
||||
.update = stage5_update,
|
||||
.event = stage5_events,
|
||||
.shader_rules = stage5_shaders,
|
||||
.spellpractice_procs = &stage5_spell_procs,
|
||||
|
@ -214,6 +219,7 @@ StageProcs stage5_spell_procs = {
|
|||
.begin = stage5_start,
|
||||
.end = stage5_end,
|
||||
.draw = stage5_draw,
|
||||
.update = stage5_update,
|
||||
.event = stage5_spellpractice_events,
|
||||
.shader_rules = stage5_shaders,
|
||||
};
|
||||
|
|
|
@ -74,7 +74,6 @@ Vector **stage6_towerwall_pos(Vector pos, float maxrange) {
|
|||
return list;
|
||||
}
|
||||
|
||||
|
||||
void stage6_towerwall_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
@ -94,13 +93,13 @@ void stage6_towerwall_draw(Vector pos) {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
Vector **stage6_towertop_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage6_towertop_pos(Vector pos, float maxrange) {
|
||||
Vector p = {0, 0, 70};
|
||||
|
||||
return single3dpos(pos, maxrange, p);
|
||||
}
|
||||
|
||||
void stage6_towertop_draw(Vector pos) {
|
||||
static void stage6_towertop_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage6/towertop")->gltex);
|
||||
|
@ -114,11 +113,11 @@ void stage6_towertop_draw(Vector pos) {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
Vector **stage6_skysphere_pos(Vector pos, float maxrange) {
|
||||
static Vector **stage6_skysphere_pos(Vector pos, float maxrange) {
|
||||
return single3dpos(pos, maxrange, stage_3d_context.cx);
|
||||
}
|
||||
|
||||
void stage6_skysphere_draw(Vector pos) {
|
||||
static void stage6_skysphere_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
Shader *s = get_shader("stage6_sky");
|
||||
|
@ -149,9 +148,13 @@ void stage6_skysphere_draw(Vector pos) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void stage6_draw(void) {
|
||||
static void stage6_draw(void) {
|
||||
set_perspective(&stage_3d_context, 100, 9000);
|
||||
draw_stage3d(&stage_3d_context, 10000);
|
||||
}
|
||||
|
||||
static void stage6_update(void) {
|
||||
update_stage3d(&stage_3d_context);
|
||||
|
||||
if(fall_over) {
|
||||
int t = global.frames - fall_over;
|
||||
|
@ -178,7 +181,6 @@ void stage6_draw(void) {
|
|||
|
||||
if(t > 470)
|
||||
stage_3d_context.cx[0] += 1-2*frand();
|
||||
|
||||
}
|
||||
|
||||
float w = 0.002;
|
||||
|
@ -191,7 +193,6 @@ void stage6_draw(void) {
|
|||
if(global.timer > 3628)
|
||||
g = max(0, g-0.01*(global.timer - 3628));
|
||||
|
||||
|
||||
stage_3d_context.cx[0] += -230*w*f*sin(w*global.frames-M_PI/2);
|
||||
stage_3d_context.cx[1] += 230*w*f*cos(w*global.frames-M_PI/2);
|
||||
stage_3d_context.cx[2] += w*f*140/M_PI;
|
||||
|
@ -203,7 +204,7 @@ void start_fall_over(void) { //troll
|
|||
fall_over = global.frames;
|
||||
}
|
||||
|
||||
void stage6_start(void) {
|
||||
static void stage6_start(void) {
|
||||
init_stage3d(&stage_3d_context);
|
||||
fall_over = 0;
|
||||
|
||||
|
@ -238,11 +239,9 @@ void stage6_start(void) {
|
|||
// stage_3d_context.cx[2] = 295;
|
||||
// stage_3d_context.crot[0] = 90;
|
||||
// stage_3d_context.crot[2] = 381.415100;
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
void stage6_preload(void) {
|
||||
static void stage6_preload(void) {
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage6", "stage6boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"stage6/baryon_connector",
|
||||
|
@ -271,18 +270,18 @@ void stage6_preload(void) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
void stage6_end(void) {
|
||||
static void stage6_end(void) {
|
||||
free_stage3d(&stage_3d_context);
|
||||
}
|
||||
|
||||
void elly_intro(Boss*, int);
|
||||
void elly_unbound(Boss*, int);
|
||||
|
||||
void stage6_spellpractice_events(void) {
|
||||
static void stage6_spellpractice_events(void) {
|
||||
TIMER(&global.timer);
|
||||
|
||||
AT(0) {
|
||||
skip_background_anim(&stage_3d_context, stage6_draw, 3800, &global.timer, &global.frames);
|
||||
skip_background_anim(&stage_3d_context, stage6_update, 3800, &global.timer, &global.frames);
|
||||
global.boss = stage6_spawn_elly(BOSS_DEFAULT_SPAWN_POS);
|
||||
|
||||
AttackInfo *s = global.stage->spell;
|
||||
|
@ -296,7 +295,7 @@ void stage6_spellpractice_events(void) {
|
|||
go = false;
|
||||
} else if(s == &stage6_spells.final.theory_of_everything) {
|
||||
start_fall_over();
|
||||
skip_background_anim(&stage_3d_context, stage6_draw, 300, &global.timer, &global.frames);
|
||||
skip_background_anim(&stage_3d_context, stage6_update, 300, &global.timer, &global.frames);
|
||||
}
|
||||
|
||||
boss_add_attack_from_info(global.boss, global.stage->spell, go);
|
||||
|
@ -317,6 +316,7 @@ StageProcs stage6_procs = {
|
|||
.preload = stage6_preload,
|
||||
.end = stage6_end,
|
||||
.draw = stage6_draw,
|
||||
.update = stage6_update,
|
||||
.event = stage6_events,
|
||||
.shader_rules = stage6_shaders,
|
||||
.spellpractice_procs = &stage6_spell_procs,
|
||||
|
@ -327,6 +327,7 @@ StageProcs stage6_spell_procs = {
|
|||
.begin = stage6_start,
|
||||
.end = stage6_end,
|
||||
.draw = stage6_draw,
|
||||
.update = stage6_update,
|
||||
.event = stage6_spellpractice_events,
|
||||
.shader_rules = stage6_shaders,
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "stage.h"
|
||||
#include "stageutils.h"
|
||||
|
||||
extern struct stage6_spells_s {
|
||||
// this struct must contain only fields of type AttackInfo
|
||||
|
@ -53,3 +54,6 @@ extern StageProcs stage6_procs;
|
|||
extern StageProcs stage6_spell_procs;
|
||||
|
||||
void start_fall_over(void);
|
||||
|
||||
Vector **stage6_towerwall_pos(Vector pos, float maxrange);
|
||||
void stage6_towerwall_draw(Vector pos);
|
||||
|
|
|
@ -43,14 +43,14 @@ void set_perspective(Stage3D *s, float n, float f) {
|
|||
set_perspective_viewport(s, n, f, VIEWPORT_X, VIEWPORT_Y, VIEWPORT_W, VIEWPORT_H);
|
||||
}
|
||||
|
||||
void draw_stage3d(Stage3D *s, float maxrange) {
|
||||
int i,j;
|
||||
for(i = 0; i < 3;i++)
|
||||
void update_stage3d(Stage3D *s) {
|
||||
for(int i = 0; i < 3;i++){
|
||||
s->cx[i] += s->cv[i];
|
||||
|
||||
if(s->nodraw) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void draw_stage3d(Stage3D *s, float maxrange) {
|
||||
int i, j;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
|
@ -147,28 +147,18 @@ Vector **single3dpos(Vector q, float maxrange, Vector p) {
|
|||
}
|
||||
}
|
||||
|
||||
void skip_background_anim(Stage3D *s3d, void (*drawfunc)(void), int frames, int *timer, int *timer2) {
|
||||
// two timers because stage 6 is so fucking special
|
||||
// second is optional
|
||||
|
||||
if(s3d) {
|
||||
s3d->nodraw = true;
|
||||
}
|
||||
|
||||
void skip_background_anim(Stage3D *s3d, void (*update_func)(void), int frames, int *timer, int *timer2) {
|
||||
int targetframes = *timer + frames;
|
||||
|
||||
while(++(*timer) < targetframes) {
|
||||
if(timer2) {
|
||||
++(*timer2);
|
||||
}
|
||||
drawfunc();
|
||||
|
||||
update_func();
|
||||
}
|
||||
|
||||
if(timer2) {
|
||||
++(*timer2);
|
||||
}
|
||||
|
||||
if(s3d) {
|
||||
s3d->nodraw = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,6 @@ struct Stage3D {
|
|||
Vector crot;
|
||||
|
||||
float projangle;
|
||||
|
||||
// hack to quickly skip through stage animations up to a specific frame
|
||||
char nodraw;
|
||||
};
|
||||
|
||||
extern Stage3D stage_3d_context;
|
||||
|
@ -46,6 +43,7 @@ void add_model(Stage3D *s, SegmentDrawRule draw, SegmentPositionRule pos);
|
|||
void set_perspective_viewport(Stage3D *s, float n, float f, int vx, int vy, int vw, int vh);
|
||||
void set_perspective(Stage3D *s, float near, float far);
|
||||
void draw_stage3d(Stage3D *s, float maxrange);
|
||||
void update_stage3d(Stage3D *s);
|
||||
|
||||
void free_stage3d(Stage3D *s);
|
||||
|
||||
|
@ -53,4 +51,4 @@ Vector **linear3dpos(Vector q, float maxrange, Vector p, Vector r);
|
|||
|
||||
Vector **single3dpos(Vector q, float maxrange, Vector p);
|
||||
|
||||
void skip_background_anim(Stage3D *s3d, void (*drawfunc)(void), int frames, int *timer, int *timer2);
|
||||
void skip_background_anim(Stage3D *s3d, void (*update_func)(void), int frames, int *timer, int *timer2);
|
||||
|
|
Loading…
Reference in a new issue