Stage 2 Background Added
Candy corridor!
This commit is contained in:
parent
38a4d43d20
commit
7b88814030
2 changed files with 121 additions and 4 deletions
|
@ -13,8 +13,65 @@
|
|||
|
||||
static Stage3D bgcontext;
|
||||
|
||||
Vector **stage2_bg_pos(Vector pos, float maxrange) {
|
||||
Vector p = {-320, 0, 0};
|
||||
Vector r = {0, 3000, 0};
|
||||
|
||||
return linear3dpos(pos, maxrange, p, r);
|
||||
}
|
||||
|
||||
void stage2_bg_tunnel_draw(Vector pos) {
|
||||
int n = 7;
|
||||
float r = 300;
|
||||
int i;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(pos[0], pos[1], pos[2]);
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
glPushMatrix();
|
||||
glRotatef(360/n*i, 0, 1, 0);
|
||||
glTranslatef(0,0,-r);
|
||||
glScalef(2*r/tan((n-2)*M_PI/n), 3000, 1);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage1/border")->gltex);
|
||||
|
||||
draw_quad();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
// bgcontext.crot[1] = (creal(global.plr.pos)-VIEWPORT_W/2)/10.0;
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void stage2_fog(int fbonum) {
|
||||
Shader *shader = get_shader("zbuf_fog");
|
||||
|
||||
glUseProgram(shader->prog);
|
||||
glUniform1i(uniloc(shader, "depth"),2);
|
||||
glUniform4f(uniloc(shader, "fog_color"),1,1,1,1.0);
|
||||
glUniform1f(uniloc(shader, "start"),0.2);
|
||||
glUniform1f(uniloc(shader, "end"),0.8);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, resources.fbg[fbonum].depth);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
draw_fbo_viewport(&resources.fbg[fbonum]);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void stage2_start() {
|
||||
init_stage3d(&bgcontext);
|
||||
|
||||
// bgcontext.cx[2] = -10;
|
||||
bgcontext.crot[0] = -70;
|
||||
bgcontext.cv[1] = 20;
|
||||
|
||||
add_model(&bgcontext, stage2_bg_tunnel_draw, stage2_bg_pos);
|
||||
|
||||
}
|
||||
|
||||
void stage2_end() {
|
||||
|
@ -22,12 +79,17 @@ void stage2_end() {
|
|||
}
|
||||
|
||||
void stage2_draw() {
|
||||
TIMER(&global.frames)
|
||||
|
||||
set_perspective(&bgcontext, 500, 5000);
|
||||
|
||||
FROM_TO(0, 160, 1)
|
||||
bgcontext.cv[1] -= 0.5;
|
||||
|
||||
draw_stage3d(&bgcontext, 7000);
|
||||
}
|
||||
|
||||
void stage2_loop() {
|
||||
// ShaderRule shaderrules[] = { stage1_fog, stage1_bloom, NULL };
|
||||
stage_loop(stage2_start, stage2_end, stage2_draw, stage2_events, NULL, 5500);
|
||||
ShaderRule shaderrules[] = { stage2_fog, NULL };
|
||||
stage_loop(stage2_start, stage2_end, stage2_draw, stage2_events, shaderrules, 5500);
|
||||
}
|
|
@ -11,11 +11,66 @@
|
|||
#include "enemy.h"
|
||||
#include "laser.h"
|
||||
|
||||
int stage3_splasher(Enemy *e, int t) {
|
||||
TIMER(&t);
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 1,3,0,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FROM_TO(0, 50, 1)
|
||||
e->pos += e->args[0]*(1-t/50.0);
|
||||
|
||||
FROM_TO(60, 150, 5-global.diff)
|
||||
create_projectile2c(frand() > 0.5 ? "rice" : "thickrice", e->pos, rgb(1,0.6-0.2*frand(),0.8), accelerated, e->args[0]/2+(1-2*frand())+(1-2*frand())*I, 0.02I);
|
||||
|
||||
FROM_TO(200, 300, 1)
|
||||
e->pos -= creal(e->args[0])*(t-200)/100.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int stage3_fodder(Enemy *e, int t) {
|
||||
TIMER(&t);
|
||||
AT(EVENT_DEATH) {
|
||||
spawn_items(e->pos, 0,1,0,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FROM_TO(0, 60, 1)
|
||||
e->pos += e->args[0]*(1-t/60.0);
|
||||
|
||||
AT(100) {
|
||||
if(global.diff > D_Easy) {
|
||||
int i;
|
||||
for(i = 0; i <= global.diff/2; i++) {
|
||||
create_projectile2c("ball", e->pos, rgb(0, 0, 0.4), asymptotic, 3*cexp(I*carg(global.plr.pos - e->pos)+I*0.2*(i-global.diff/2.0)), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FROM_TO(200, 300, 1) {
|
||||
e->pos -= 3*e->args[0]*(t-200)/100.0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void stage3_events() {
|
||||
TIMER(&global.timer);
|
||||
|
||||
FROM_TO(30, 200, 20) {
|
||||
create_laser(LT_Line, VIEWPORT_W/2, 20*cexp(I*0.3*_i), 40, 200, rgb(0.9,0.9,0.0), NULL, 0);
|
||||
// FROM_TO(30, 200, 20) {
|
||||
// create_laser(LT_Line, VIEWPORT_W/2, 20*cexp(I*0.3*_i), 40, 200, rgb(0.9,0.9,0.0), NULL, 0);
|
||||
// }
|
||||
|
||||
AT(70) {
|
||||
create_enemy1c(VIEWPORT_H/4*3*I, 9000, BigFairy, stage3_splasher, 3-4I);
|
||||
create_enemy1c(VIEWPORT_W + VIEWPORT_H/4*3*I, 9000, BigFairy, stage3_splasher, -3-4I);
|
||||
}
|
||||
|
||||
FROM_TO(300, 350, 10) {
|
||||
create_enemy1c(VIEWPORT_H/3*2*I-60*_i*I, 1000, Fairy, stage3_fodder, 2);
|
||||
create_enemy1c(VIEWPORT_W + VIEWPORT_H/3*2*I-60*_i*I, 1000, Fairy, stage3_fodder, -2);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue