From 038a8a4aaa54b7b60e7fbb6a0f988dd852fb8970 Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Sun, 26 Mar 2006 01:25:34 +0000 Subject: [PATCH] easy mode; messages at game over. --- config.h | 9 +++++++-- globals.h | 3 +++ main.c | 46 ++++++++++++++++++++++++++++++++++++++-------- rocks.c | 11 +++++++---- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/config.h b/config.h index f857291..57095cb 100644 --- a/config.h +++ b/config.h @@ -23,8 +23,13 @@ #define NROCKS 50 // initial/final counts for rocks-on-screen -#define I_ROCKS 20 -#define F_ROCKS 35 +#define NORMAL_I_ROCKS 20 +#define NORMAL_F_ROCKS 35 +#define NORMAL_GAMESPEED 1.0 + +#define EASY_I_ROCKS 10 +#define EASY_F_ROCKS 25 +#define EASY_GAMESPEED 0.85 // number of rock structs to allocate #define MAXROCKS 120 diff --git a/globals.h b/globals.h index 7dc6569..0ac8a5d 100644 --- a/globals.h +++ b/globals.h @@ -2,6 +2,7 @@ #define VOR_GLOBALS_H #include +#include #include "SFont.h" struct bangdots { @@ -66,4 +67,6 @@ extern Uint16 heatcolor[W*3]; extern char *data_dir; +extern uint32_t initial_rocks, final_rocks; + #endif // VOR_GLOBALS_H diff --git a/main.c b/main.c index b8b03c3..94c8e9a 100644 --- a/main.c +++ b/main.c @@ -99,9 +99,10 @@ enum states { enum states state = TITLE_PAGE; float state_timeout = 600.0; -#define NSEQUENCE 2 +#define NSEQUENCE 3 char *sequence[] = { - "Press SPACE to start", + "Press SPACE for normal game", + "Or 'e' for easy game", "http://jasonwoof.org/vor" }; @@ -423,8 +424,10 @@ show_lives(void) void draw_game_over(void) { - float a_game = 0, a_over = 0; + int x; + char *text0, *text1; SDL_Rect dest; + float a_game = 0, a_over = 0; // fade in "GAME", then "OVER". a_game = min(1.0, faderate*fadetimer/3.0); @@ -441,6 +444,23 @@ draw_game_over(void) dest.y = (YSIZE-surf_b_over->h)/2 + 40; SDL_SetAlpha(surf_b_over, SDL_SRCALPHA, (int)(a_over*(200 + 55*sin(fadetimer)))); SDL_BlitSurface(surf_b_over,NULL,surf_screen,&dest); + + if(new_high_score(score)) { + text0 = "New High Score!"; + text1 = "Press SPACE to continue"; + } else if(opt_gamespeed == EASY_GAMESPEED) { + text0 = "Press SPACE to start a new game"; + text1 = "Press 'e' to start an easy game"; + } else { + text0 = "Press SPACE to start an easy game"; + text1 = "Press 'n' to start a normal game"; + } + + x = (XSIZE-SFont_TextWidth(g_font,text0))/2 + cos(fadetimer/4.5)*10; + SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/3)*5,text0); + + x = (XSIZE-SFont_TextWidth(g_font,text1))/2 + sin(fadetimer/4.5)*10; + SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text1); } void @@ -467,13 +487,13 @@ draw_title_page(void) SDL_SetAlpha(surf_b_rockdodger, SDL_SRCALPHA, (int)(200 + 55*sin(fadetimer-2.0))); SDL_BlitSurface(surf_b_rockdodger,NULL,surf_screen,&dest); - text = "Version " VERSION; - x = (XSIZE-SFont_TextWidth(g_font,text))/2 + sin(fadetimer/4.5)*10; - SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text); - text = sequence[(int)(fadetimer/40)%NSEQUENCE]; x = (XSIZE-SFont_TextWidth(g_font,text))/2 + cos(fadetimer/4.5)*10; SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/3)*5,text); + + text = "Version " VERSION; + x = (XSIZE-SFont_TextWidth(g_font,text))/2 + sin(fadetimer/4.5)*10; + SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text); } void @@ -671,13 +691,23 @@ gameloop() { } // new game - if(keystate[SDLK_SPACE] + if((keystate[SDLK_SPACE] || keystate[SDLK_e] || keystate[SDLK_n]) && (state == HIGH_SCORE_DISPLAY || state == TITLE_PAGE || state == GAME_OVER)) { if(state == GAME_OVER && new_high_score(score)) init_score_entry(); else { + if(keystate[SDLK_n] || (keystate[SDLK_SPACE] && !initial_rocks)) { + initial_rocks = NORMAL_I_ROCKS; + final_rocks = NORMAL_F_ROCKS; + if(opt_gamespeed == EASY_GAMESPEED) + opt_gamespeed = NORMAL_GAMESPEED; + } else if(keystate[SDLK_e]) { + initial_rocks = EASY_I_ROCKS; + final_rocks = EASY_F_ROCKS; + opt_gamespeed = EASY_GAMESPEED; + } reset_sprites(); reset_rocks(); screendx = SCREENDXMIN; screendy = 0; diff --git a/rocks.c b/rocks.c index 701e5a5..ed98cac 100644 --- a/rocks.c +++ b/rocks.c @@ -17,9 +17,11 @@ static struct rock prototypes[NROCKS]; // timers for rock generation. static float rtimers[4]; -uint32_t nrocks = I_ROCKS; +uint32_t nrocks = NORMAL_I_ROCKS; +uint32_t initial_rocks = NORMAL_I_ROCKS; +uint32_t final_rocks = NORMAL_F_ROCKS; float nrocks_timer = 0; -float nrocks_inc_ticks = 2*60*20/(F_ROCKS-I_ROCKS); +float nrocks_inc_ticks = 2*60*20/(NORMAL_F_ROCKS-NORMAL_I_ROCKS); // constants for rock generation. #define KH (32*20) // 32 s for a speed=1 rock to cross the screen horizontally. @@ -30,7 +32,8 @@ float nrocks_inc_ticks = 2*60*20/(F_ROCKS-I_ROCKS); void reset_rocks(void) { - nrocks = I_ROCKS; + nrocks = initial_rocks; + nrocks_inc_ticks = 2*60*20/(final_rocks-initial_rocks); nrocks_timer = 0; } @@ -134,7 +137,7 @@ new_rocks(void) float rmin[4]; float rmax[4]; - if(nrocks < F_ROCKS) { + if(nrocks < final_rocks) { nrocks_timer += t_frame; if(nrocks_timer >= nrocks_inc_ticks) { nrocks_timer -= nrocks_inc_ticks; -- 1.7.10.4