From: Joshua Grams Date: Sun, 26 Mar 2006 02:52:35 +0000 (+0000) Subject: separate scores for easy mode. X-Git-Tag: 0.4~7 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=f1768e98ddbe134b9f6fd6056caf2393b666bb5a separate scores for easy mode. --- diff --git a/file.c b/file.c index 4b7872a..0c6177f 100644 --- a/file.c +++ b/file.c @@ -132,7 +132,7 @@ find_score_file(void) if(s) { g_score_file = s; g_score_mask = 0177; - return is_file(s); + return true; } else return false; } diff --git a/globals.h b/globals.h index 0ac8a5d..a16e9f8 100644 --- a/globals.h +++ b/globals.h @@ -55,6 +55,7 @@ extern float screendx, screendy; extern float t_frame; // length of this frame (in ticks = 1/20th second) extern int score; +extern int g_easy; extern float fadetimer, faderate; extern int pausedown, paused; diff --git a/main.c b/main.c index 927d2bb..aa1c801 100644 --- a/main.c +++ b/main.c @@ -583,6 +583,7 @@ init_score_entry(void) SDL_EnableUNICODE(1); while(SDL_PollEvent(&e)) ; + insert_score(score); } void @@ -710,11 +711,13 @@ gameloop() { init_score_entry(); else { if((keystate[SDLK_SPACE] && !initial_rocks) || keystate[SDLK_n]) { + g_easy = 0; initial_rocks = NORMAL_I_ROCKS; final_rocks = NORMAL_F_ROCKS; if(opt_gamespeed == EASY_GAMESPEED) opt_gamespeed = NORMAL_GAMESPEED; } else if(keystate[SDLK_e]) { + g_easy = 1; initial_rocks = EASY_I_ROCKS; final_rocks = EASY_F_ROCKS; opt_gamespeed = EASY_GAMESPEED; @@ -760,6 +763,11 @@ gameloop() { } } + if(state == TITLE_PAGE && keystate[SDLK_h]) { + state = HIGH_SCORE_DISPLAY; + state_timeout = 400; + } + if(state != HIGH_SCORE_ENTRY && (keystate[SDLK_q] || keystate[SDLK_ESCAPE])) return; diff --git a/score.c b/score.c index 77e8ab3..406576c 100644 --- a/score.c +++ b/score.c @@ -31,32 +31,50 @@ #include "score.h" // High score table -struct highscore g_scores[N_SCORES] = { - {1*60*1000,"-"}, - {45*1000,"-"}, - {30*1000,"-"}, - {20*1000,"-"}, - {10*1000,"-"}, - {7*1000,"-"}, - {5*1000,"-"}, - {3*1000,"-"} +struct highscore g_scores[2][N_SCORES] = { + { + {1*60*1000,"-"}, + {45*1000,"-"}, + {30*1000,"-"}, + {20*1000,"-"}, + {10*1000,"-"}, + {7*1000,"-"}, + {5*1000,"-"}, + {3*1000,"-"} + }, + { + {1*60*1000,"-"}, + {45*1000,"-"}, + {30*1000,"-"}, + {20*1000,"-"}, + {10*1000,"-"}, + {7*1000,"-"}, + {5*1000,"-"}, + {3*1000,"-"} + } }; +static char *titles[2] = { "Normal\n", "Easy\n" }; + extern SFont_Font *g_font; +int g_easy = 0; int cur_score = -1; // which score we're currently entering. void read_high_score_table() { FILE *f; - int i; + int i, j; f = open_score_file("r"); if(f) { // If the file exists, read from it - for(i = 0; i g_scores[i].score) return i; + if(score > g_scores[g_easy][i].score) return i; } return -1; } @@ -92,20 +113,26 @@ score_rank(int score) int new_high_score(int score) { - int i; - cur_score = -1; // assume not a new high score - if(score <= g_scores[LOW_SCORE].score) return false; + if(score <= g_scores[g_easy][LOW_SCORE].score) return false; read_high_score_table(); cur_score = score_rank(score); - if(cur_score < 0) return false; + return cur_score >= 0; +} + +int +insert_score(int score) +{ + int i; // Move all lower scores down a notch, losing lowest score forever. - for(i=LOW_SCORE; i>cur_score; i--) g_scores[i] = g_scores[i-1]; + if(strcmp(g_scores[g_easy][cur_score].name, "-") != 0) + for(i=LOW_SCORE; i>cur_score; i--) + g_scores[g_easy][i] = g_scores[g_easy][i-1]; // initialize new score entry. - g_scores[cur_score].score = score; - for(i=0; i<32; i++) g_scores[cur_score].name[i] = 0; + g_scores[g_easy][cur_score].score = score; + for(i=0; i<32; i++) g_scores[g_easy][cur_score].name[i] = 0; return true; } @@ -139,14 +166,16 @@ display_scores(SDL_Surface *s, uint32_t x, uint32_t y) SFont_Write(s,g_font,x+30,y,"High scores"); y += h; + if(g_easy) SFont_Write(s,g_font,x+75,y,"(easy)"); + else SFont_Write(s,g_font,x+60,y,"(normal)"); for(i = 0; i