added stage title display

This commit is contained in:
laochailan 2012-07-27 12:18:21 +02:00
parent dcc17dc6c4
commit 577f0ef204
3 changed files with 37 additions and 20 deletions

View file

@ -17,11 +17,11 @@
#include "menu/savereplay.h"
StageInfo stages[] = {
{1, stage0_loop, False, "Stage 1", "Misty Lake"},
{2, stage1_loop, False, "Stage 2", "Walk Along the Border"},
{3, stage2_loop, False, "Stage 3", "Through the Tunnel of Light"},
{4, stage3_loop, False, "Stage 4", "Forgotten Mansion"},
{5, stage4_loop, False, "Stage 5", "Climbing the Tower of Babel"},
{1, stage0_loop, False, "Stage 1", "Misty Lake", {1, 1, 1}},
{2, stage1_loop, False, "Stage 2", "Walk Along the Border", {1, 1, 1}},
{3, stage2_loop, False, "Stage 3", "Through the Tunnel of Light", {0, 0, 0}},
{4, stage3_loop, False, "Stage 4", "Forgotten Mansion", {0, 0, 0}},
{5, stage4_loop, False, "Stage 5", "Climbing the Tower of Babel", {1, 1, 1}},
{0, NULL, False, NULL, NULL}
};
@ -169,7 +169,7 @@ void draw_hud() {
draw_texture(VIEWPORT_X+creal(global.boss->pos), 590, "boss_indicator");
}
void stage_draw(StageRule bgdraw, ShaderRule *shaderrules, int time) {
void stage_draw(StageInfo *info, StageRule bgdraw, ShaderRule *shaderrules, int time) {
if(!tconfig.intval[NO_SHADER]) {
glBindFramebuffer(GL_FRAMEBUFFER, resources.fbg[0].fbo);
if(!global.menu)
@ -235,22 +235,24 @@ void stage_draw(StageRule bgdraw, ShaderRule *shaderrules, int time) {
draw_projectiles(global.particles);
draw_enemies(global.enemies);
draw_lasers();
if(global.boss)
draw_boss(global.boss);
if(global.dialog)
draw_dialog(global.dialog);
draw_stage_title(info);
if(!tconfig.intval[NO_SHADER]) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0,0,RESX,RESY);
glPushMatrix();
if(global.plr.cha == Marisa && global.plr.shot == MarisaLaser && global.frames - global.plr.recovery < 0)
glTranslatef(8*sin(global.frames),8*sin(global.frames+3),0);
// glColor4f(1,1,1,0.2);
draw_fbo_viewport(&resources.fsec);
// glColor4f(1,1,1,1);
glPopMatrix();
}
@ -451,7 +453,7 @@ void stage_loop(StageInfo* info, StageRule start, StageRule end, StageRule draw,
calc_fps(&global.fps);
stage_draw(draw, shaderrules, endtime);
stage_draw(info, draw, shaderrules, endtime);
SDL_GL_SwapBuffers();
frame_rate(&global.lasttime);
@ -463,7 +465,7 @@ void stage_loop(StageInfo* info, StageRule start, StageRule end, StageRule draw,
if(REPLAY_ASKSAVE) {
global.menu = create_saverpy_menu();
while(global.menu) {
stage_draw(draw, shaderrules, endtime);
stage_draw(info, draw, shaderrules, endtime);
ingame_menu_logic(&global.menu);
if(!global.menu)
@ -483,9 +485,22 @@ void stage_loop(StageInfo* info, StageRule start, StageRule end, StageRule draw,
stage_end();
}
void draw_stage_title(int t, int dur, char *stage, char *subtitle) {
if(t < 0 || t > dur)
void draw_stage_title(StageInfo *info) {
int t = global.timer;
int i;
float f = 0;
if(t < 30 || t > 220)
return;
draw_text(AL_Center, VIEWPORT_W/2, VIEWPORT_H/2, stage, _fonts.mainmenu);
if((i = abs(t-135)) >= 50) {
i -= 50;
f = 1/35.0*i;
}
glColor4f(info->titleclr.r,info->titleclr.g,info->titleclr.b,1.0-f);
draw_text(AL_Center, VIEWPORT_W/2, VIEWPORT_H/2-40, info->title, _fonts.mainmenu);
draw_text(AL_Center, VIEWPORT_W/2, VIEWPORT_H/2, info->subtitle, _fonts.standard);
glColor4f(1,1,1,1);
}

View file

@ -17,6 +17,8 @@
*
*/
#include <projectile.h>
#define TIMER(ptr) int *__timep = ptr; int _i = 0, _ni = 0; _i = _ni = _i;
#define AT(t) if(*__timep == t)
#define FROM_TO(start,end,step) _ni = _ni; _i = (*__timep - (start))/(step); if(*__timep >= (start) && *__timep <= (end) && !((*__timep - (start)) % (step)))
@ -37,6 +39,8 @@ typedef struct StageInfo {
// reserved for draw_stage_title when/if it's used
char *title;
char *subtitle;
Color titleclr;
} StageInfo;
extern StageInfo stages[];
@ -45,7 +49,8 @@ StageInfo* stage_get(int);
void stage_loop(StageInfo *info, StageRule start, StageRule end, StageRule draw, StageRule event, ShaderRule *shaderrules, int endtime);
void apply_bg_shaders(ShaderRule *shaderrules);
void draw_stage_title(int t, int dur, char *stage, char *subtitle);
void draw_stage_title(StageInfo *info);
void stage0_loop();
void stage1_loop();

View file

@ -460,10 +460,7 @@ Boss *create_iku() {
void stage4_events() {
TIMER(&global.timer);
AT(0)
global.timer = 870;
FROM_TO(60, 120, 10)
create_enemy1c(VIEWPORT_W+70I+50*_i*I, 300, Fairy, stage4_greeter, -3);