Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- new point view

- improved settings menu
- switched start and select ingame
  • Loading branch information...
commit 2bd1e7f08ff387855fb405848e7522fc152f5451 1 parent a3ab193
@theZiz authored
View
12 ToDo
@@ -1,13 +1,7 @@
ToDo:
-- Switching Start and Select ingame
-- every point in the settings menu with axis
-- left Notices as "stack", what happens as last, e.g.
- 6 stones broken <- small font
- + 2000 <- middle font
- 5 stones broken <- small font
- + 1500 <- middle font
- DOUBLE! <- big font
-- Noticed on the left, if you killed a stone on the other side, too
++ Switching Start and Select ingame
++ every point in the settings menu with axis
++ left Notices as "stack", what happens as last, e.g.
- new design for the modes without textures
- new background with prerenderd stars
- new game mode: reach points as fast as possible
View
183 game.c
@@ -57,10 +57,6 @@ int gameTime;
int timeStep;
int realTime;
-#define MAX_LETTERING 2000
-SDL_Surface* momLettering;
-int letteringTimeOut;
-
#define START_TIME 180000
pchange firstchange;
@@ -92,10 +88,6 @@ void add_pointVis(int p)
#define POINTAGE 4000
-char name[4]="AAA";
-char insert_name;
-int selected_letter;
-
void calc_pointVis(int steps)
{
pPointVis mom = first_pointVis;
@@ -129,12 +121,6 @@ void delete_pointVis()
}
}
-void show_lettering(char* name)
-{
- momLettering = get_lettering(name);
- letteringTimeOut = MAX_LETTERING;
-}
-
void test_and_set_chain()
{
char found = 0;
@@ -483,6 +469,7 @@ void prepare_game_objects(char complete,int colornumber_)
init_stars();
}
init_light();
+ delete_all_lettering();
}
void delete_game_objects()
@@ -595,6 +582,9 @@ pchange is_in_change(int x,int y)
void make_win_situations_invalid()
{
+ spFontPointer font = settings_get_font();
+ spFontPointer small_font = settings_get_small_font();
+ spFontPointer middle_font = settings_get_middle_font();
int new_points = 0;
pwinsituation situation;
char found = 0;
@@ -637,28 +627,34 @@ void make_win_situations_invalid()
printf("%i:%i\n",temp->x,temp->y);
temp=temp->next;
}
+ if (i>0)
+ {
+ new_points = (int)(pow((float)(i),1.5)*100.0);
+ char buffer[32];
+ //sprintf(buffer,"%i Stones",i);
+ //add_lettering(buffer,middle_font);
+ sprintf(buffer,"+%i (%i)",new_points,i);
+ add_line();
+ add_lettering(buffer,small_font);
+ }
if (i<7)
{}
else
- if (i<9)
- show_lettering("well");
- else
- if (i<12)
- show_lettering("great");
+ if (i<10)
+ add_lettering("Well!",middle_font);
else
- if (i<16)
- show_lettering("fantastic");
+ if (i<14)
+ add_lettering("Great!",middle_font);
else
- if (i<20)
- show_lettering("incredible");
+ if (i<19)
+ add_lettering("Fantastic!",middle_font);
else
- show_lettering("supercalifragilisticexpialidocious");
- if (i>0)
- new_points = (int)(pow((float)(i),1.5)*100.0);
+ if (i<25)
+ add_lettering("Incredible",middle_font);
delete_win_situation(situation);
if (count>1)
{
- show_lettering("combo");
+ add_lettering("Combo!",middle_font);
new_points*=3;
}
}
@@ -670,12 +666,12 @@ void make_win_situations_invalid()
{
switch (chain)
{
- case 2: show_lettering("chain");break;
- case 3: show_lettering("chain_2x"); break;
- case 4: show_lettering("chain_3x"); break;
- case 5: show_lettering("chain_4x"); break;
- case 6: show_lettering("chain_5x"); break;
- default: show_lettering("hyper_chain"); break;
+ case 2: add_lettering("Chain!",middle_font);break;
+ case 3: add_lettering("2x Chain!",middle_font); break;
+ case 4: add_lettering("3x Chain!",middle_font); break;
+ case 5: add_lettering("4x Chain!",middle_font); break;
+ case 6: add_lettering("5x Chain!",middle_font); break;
+ default: add_lettering("Mega Chain!",middle_font); break;
}
new_points = new_points * 3 / 2;
}
@@ -745,6 +741,8 @@ void draw_game(void)
spFontPointer font = settings_get_font();
spFontPointer small_font = settings_get_small_font();
spFontPointer middle_font = settings_get_middle_font();
+ spFontPointer countdown_font = settings_get_countdown_font();
+ SDL_Surface* screen = spGetWindowSurface();
Sint32* modellViewMatrix=spGetMatrix();
//plight light=engineGetLightPointer();
int engineWindowX=spGetWindowSurface()->w;
@@ -766,6 +764,27 @@ void draw_game(void)
draw_stars();
spRotate(0,-1<<SP_ACCURACY,0,star_add);
}
+
+ //Countdown
+ spSetZSet(1);
+ spSetZTest(0);
+ if (countdown>0)
+ {
+ int factor = (countdown % 1000)+200;
+ SDL_Surface* surface = NULL;
+ switch (countdown / 1000)
+ {
+ case 3: surface = spFontGetLetter(countdown_font,'3')->surface; break;
+ case 2: surface = spFontGetLetter(countdown_font,'2')->surface; break;
+ case 1: surface = spFontGetLetter(countdown_font,'1')->surface; break;
+ default: surface = spFontGetLetter(countdown_font,'0')->surface; break;
+ }
+ spBindTexture(surface);
+ spQuad_tex(screen->w/2-factor*screen->w/2000,screen->h/2-factor*screen->w/2000,-1,0,0,
+ screen->w/2+factor*screen->w/2000,screen->h/2-factor*screen->w/2000,-1,surface->w-SP_FONT_EXTRASPACE-1,0,
+ screen->w/2+factor*screen->w/2000,screen->h/2+factor*screen->w/2000,-1,surface->w-SP_FONT_EXTRASPACE-1,surface->h-SP_FONT_EXTRASPACE-1,
+ screen->w/2-factor*screen->w/2000,screen->h/2+factor*screen->w/2000,-1,0,surface->h-SP_FONT_EXTRASPACE-1,65535);
+ }
spSetZSet(1);
spSetZTest(1);
@@ -986,37 +1005,16 @@ void draw_game(void)
spSetZSet(0);
spSetZTest(0);
+
//HUD on the left side
- SDL_Surface* shown = NULL;
-
- //setting "shown"
- if (countdown>0)
- switch ((countdown)/1000)
- {
- case 3: shown = get_lettering("3"); break;
- case 2: shown = get_lettering("2"); break;
- case 1: shown = get_lettering("1"); break;
- case 0: shown = get_lettering("go"); break;
- }
- else
- {
- if ((mode & timeMode) && gameTime<START_TIME/5 && momLettering == NULL)
- shown = get_lettering("hurry_up");
- else
- shown = momLettering;
- }
- //Name
- if (insert_name)
+ plettering lettering = get_first_lettering();
+ while (lettering)
{
- //drawtextMX(engineGetSurface(SURFACE_SURFACE),engineWindowX/7, 9*engineWindowY/20,"Name:",engineGetSurface(SURFACE_KEYMAP));
- //drawtextMX(engineGetSurface(SURFACE_SURFACE),engineWindowX/7,11*engineWindowY/20,name,engineGetSurface(SURFACE_KEYMAP));
- shown = NULL;
+ if (lettering->text)
+ spFontDrawMiddle(engineWindowX/7,lettering->y,-1,lettering->text,lettering->font);
+ lettering = lettering->next;
}
-
-
- if (shown != NULL)
- spBlitSurface(1*engineWindowX/7,engineWindowY/2,-1,shown);
//pointVis
@@ -1031,30 +1029,30 @@ void draw_game(void)
}
//HUD on the right side
- spFontDrawMiddle(6*engineWindowX/7,1*engineWindowY/16,-1,"Game Mode:",middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,1*engineWindowY/16,-1,"Game Mode:",small_font);
if (mode & timeMode)
sprintf(buffer,"Time Stole");
else
sprintf(buffer,"Points");
- spFontDrawMiddle(6*engineWindowX/7,2*engineWindowY/16,-1,buffer,middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,2*engineWindowY/16,-1,buffer,font);
if (mode & timeMode)
{
- spFontDrawMiddle(6*engineWindowX/7,4*engineWindowY/16,-1,"Time Past:",middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,4*engineWindowY/16,-1,"Time Past:",small_font);
sprintf(buffer,"%i Seconds",realTime/1000);
- spFontDrawMiddle(6*engineWindowX/7,5*engineWindowY/16,-1,buffer,middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,5*engineWindowY/16,-1,buffer,font);
}
else
{
- spFontDrawMiddle(6*engineWindowX/7,4*engineWindowY/16,-1,"Points:",middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,4*engineWindowY/16,-1,"Points:",small_font);
sprintf(buffer,"%i",points);
- spFontDrawMiddle(6*engineWindowX/7,5*engineWindowY/16,-1,buffer,middle_font);
+ spFontDrawMiddle(6*engineWindowX/7,5*engineWindowY/16,-1,buffer,font);
}
spBlitSurfacePart(6*engineWindowX/7,13*engineWindowY/32,-1,getTimeSurface(),0,0,gameTime*getTimeSurface()->w/START_TIME,getTimeSurface()->h);
- spFontDrawMiddle(6*engineWindowX/7,20*engineWindowY/32,-1,"Select:",small_font);
+ spFontDrawMiddle(6*engineWindowX/7,20*engineWindowY/32,-1,"Start:",small_font);
spFontDrawMiddle(6*engineWindowX/7,22*engineWindowY/32,-1,"Pause",small_font);
- spFontDrawMiddle(6*engineWindowX/7,25*engineWindowY/32,-1,"Start:",small_font);
+ spFontDrawMiddle(6*engineWindowX/7,25*engineWindowY/32,-1,"Select:",small_font);
spFontDrawMiddle(6*engineWindowX/7,27*engineWindowY/32,-1,"Back to Menu",small_font);
@@ -1068,45 +1066,10 @@ void draw_game(void)
int calc_game(Uint32 steps)
{
PspInput engineInput = spGetInput();
- if (engineInput->button[SP_BUTTON_SELECT])
+ if (engineInput->button[SP_BUTTON_START])
{
pause=!pause;
- engineInput->button[SP_BUTTON_SELECT]=0;
- }
-
- if (insert_name)
- {
- if (engineInput->axis[0]>0)
- {
- selected_letter = (selected_letter+1)%3;
- engineInput->axis[0] = 0;
- }
- if (engineInput->axis[0]<0)
- {
- selected_letter = (selected_letter+2)%3;
- engineInput->axis[0] = 0;
- }
- if (engineInput->axis[1]>0)
- {
- name[selected_letter] = (name[selected_letter]-'A' +25)%26+'A';
- engineInput->axis[1] = 0;
- }
- if (engineInput->axis[1]<0)
- {
- name[selected_letter] = (name[selected_letter]-'A' +1)%26+'A';
- engineInput->axis[1] = 0;
- }
-
- if (engineInput->button[SP_BUTTON_START])
- {
- if (mode & timeMode)
- insert_highscore(mode,colornumber-4,difficult,name,realTime);
- else
- insert_highscore(mode,colornumber-4,difficult,name,points);
- highscore_save();
- return 1;
- }
- return 0;
+ engineInput->button[SP_BUTTON_START]=0;
}
if (pause)
@@ -1117,10 +1080,6 @@ int calc_game(Uint32 steps)
countdown-=steps;
return 0;
}
- if (letteringTimeOut>0)
- letteringTimeOut -= steps;
- else
- momLettering = NULL;
calc_pointVis(steps);
game_counter+=steps;
int i;
@@ -1397,9 +1356,11 @@ int calc_game(Uint32 steps)
}
}
}
+
+ calc_lettering(steps);
w+=(steps*16)%(2*SP_PI);
- if (engineInput->button[SP_BUTTON_START])
+ if (engineInput->button[SP_BUTTON_SELECT])
return 1;
return 0;
}
@@ -1413,8 +1374,6 @@ int run_game(int playernumber_,GameMode mode_,int difficult_ /*0..9*/,int starAd
timeStep = difficult/2+2;
star_add = starAdd;
first_pointVis = NULL;
- insert_name = 0;
- selected_letter = 0;
switch (rand()%4)
{
View
109 lettering.c
@@ -23,68 +23,89 @@
#include <string.h>
plettering first_lettering = NULL;
-plettering dummy_lettering = NULL;
-plettering add_lettering(char* name,int windowx,int windowy)
+void add_lettering(char* text,spFontPointer font)
{
- int globalzoom=spMin(windowx/320,windowy/240);
+ //Create
plettering lettering = (plettering)malloc(sizeof(tlettering));
- lettering->name = (char*)malloc(strlen(name)+1);
- sprintf(lettering->name,"%s",name);
- char buffer[256];
- if (globalzoom<=1)
- sprintf(buffer,"./images/%s_small.png",name);
- else
- sprintf(buffer,"./images/%s.png",name);
- lettering->surface = spLoadSurface(buffer);
+ lettering->text = (char*)malloc(strlen(text)+1);
+ sprintf(lettering->text,"%s",text);
+ lettering->age = LETTERING_TIMEOUT;
+ lettering->y = spGetWindowSurface()->h/20;
+ lettering->font = font;
lettering->next = first_lettering;
first_lettering = lettering;
- return lettering;
+
+ //Recalculate the y-values
+ lettering = first_lettering->next;
+ while (lettering)
+ {
+ lettering->y += first_lettering->font->maxheight;
+ lettering = lettering->next;
+ }
+}
+
+void add_line()
+{
+ //Create
+ plettering lettering = (plettering)malloc(sizeof(tlettering));
+ lettering->text = NULL;
+ lettering->age = LETTERING_TIMEOUT;
+ lettering->y = spGetWindowSurface()->h/16;
+ lettering->font = NULL;
+ lettering->next = first_lettering;
+ first_lettering = lettering;
+
+ //Recalculate the y-values
+ lettering = first_lettering->next;
+ while (lettering)
+ {
+ lettering->y += spGetWindowSurface()->h/32;
+ lettering = lettering->next;
+ }
}
-void refresh_lettering(int windowx,int windowy)
+void calc_lettering(int steps)
{
- delete_lettering();
- dummy_lettering = add_lettering("dummy",windowx,windowy);
- add_lettering("1",windowx,windowy);
- add_lettering("2",windowx,windowy);
- add_lettering("3",windowx,windowy);
- add_lettering("go",windowx,windowy);
- add_lettering("chain",windowx,windowy);
- add_lettering("chain_2x",windowx,windowy);
- add_lettering("chain_3x",windowx,windowy);
- add_lettering("chain_4x",windowx,windowy);
- add_lettering("chain_5x",windowx,windowy);
- add_lettering("hyper_chain",windowx,windowy);
- add_lettering("combo",windowx,windowy);
- add_lettering("well",windowx,windowy);
- add_lettering("great",windowx,windowy);
- add_lettering("fantastic",windowx,windowy);
- add_lettering("incredible",windowx,windowy);
- add_lettering("supercalifragilisticexpialidocious",windowx,windowy);
- add_lettering("hurry_up",windowx,windowy);
+ plettering lettering = first_lettering;
+ plettering last_lettering = NULL;
+ //Adding
+ while (lettering)
+ {
+ lettering->age -= steps;
+ if (lettering->age<=0 || lettering->y > spGetWindowSurface()->h)
+ break;
+ last_lettering = lettering;
+ lettering = lettering->next;
+ }
+ //Deleting if too old or to low (y)
+ while (lettering)
+ {
+ plettering next = lettering->next;
+ if (lettering->text)
+ free(lettering->text);
+ free(lettering);
+ lettering = next;
+ }
+ if (last_lettering)
+ last_lettering->next = NULL;
+ else
+ first_lettering = NULL;
}
-void delete_lettering()
+void delete_all_lettering()
{
while (first_lettering)
{
plettering next = first_lettering->next;
- free(first_lettering->name);
- SDL_FreeSurface(first_lettering->surface);
+ if (first_lettering->text)
+ free(first_lettering->text);
free(first_lettering);
first_lettering = next;
}
}
-SDL_Surface* get_lettering(char* name)
+plettering get_first_lettering()
{
- plettering lettering = first_lettering;
- while (lettering != dummy_lettering)
- {
- if (strcmp(lettering->name,name)==0)
- break;
- lettering = lettering->next;
- }
- return lettering->surface;
+ return first_lettering;
}
View
17 lettering.h
@@ -25,16 +25,21 @@
#include <SDL_image.h>
#include "../sparrow3d/sparrow3d.h"
+#define LETTERING_TIMEOUT 10000
+
typedef struct slettering *plettering;
typedef struct slettering {
- char* name;
- SDL_Surface *surface;
+ char* text;
+ spFontPointer font;
+ int age;
+ int y;
plettering next;
} tlettering;
-plettering add_lettering(char* name,int windowx,int windowy);
-void refresh_lettering(int windowx,int windowy);
-void delete_lettering();
-SDL_Surface* get_lettering(char* name);
+void add_lettering(char* text,spFontPointer font);
+void add_line();
+void calc_lettering(int steps);
+void delete_all_lettering();
+plettering get_first_lettering();
#endif
View
15 menu.c
@@ -324,6 +324,16 @@ int calc_menu(Uint32 steps)
settings_set_stars_rotating(settings_get_stars_rotating()+1);
menu_block = 1;
}
+ if (!menu_block && menu_move == 0 && (menu_choice>>SP_ACCURACY) == 2 && engineInput->axis[0]<0 && menu_wait <= 0 && settings_get_particles()>0)
+ {
+ settings_set_particles(settings_get_particles()-1);
+ menu_block = 1;
+ }
+ if (!menu_block && menu_move == 0 && (menu_choice>>SP_ACCURACY) == 2 && engineInput->axis[0]>0 && menu_wait <= 0 && settings_get_particles()<1)
+ {
+ settings_set_particles(settings_get_particles()+1);
+ menu_block = 1;
+ }
if (engineInput->axis[0] == 0)
menu_block = 0;
if (menu_move == 0 && (engineInput->button[SP_BUTTON_START] ||
@@ -373,6 +383,11 @@ int calc_menu(Uint32 steps)
}
else
move_sound_off();
+ if (!menu_block && menu_move == 0 && (menu_choice>>SP_ACCURACY) == 1 && engineInput->axis[0]!=0 && menu_wait <= 0)
+ {
+ settings_set_mode((settings_get_mode()+1)%2);
+ menu_block = 1;
+ }
if (!menu_block && menu_move == 0 && (menu_choice>>SP_ACCURACY) == 2 && engineInput->axis[0]<0 && menu_wait <= 0 && settings_get_color()>4)
{
settings_set_color(settings_get_color()-1);
View
12 puzzletube.c
@@ -30,6 +30,7 @@ SDL_Surface* screen;
spFontPointer font = NULL;
spFontPointer small_font = NULL;
spFontPointer middle_font = NULL;
+spFontPointer countdown_font = NULL;
void resize(Uint16 w,Uint16 h)
{
@@ -54,13 +55,20 @@ void resize(Uint16 w,Uint16 h)
if (middle_font)
spFontDelete(middle_font);
- middle_font = spFontLoad("./font/StayPuft.ttf",16*spGetSizeFactor()>>SP_ACCURACY);
+ middle_font = spFontLoad("./font/StayPuft.ttf",14*spGetSizeFactor()>>SP_ACCURACY);
spFontAddRange(middle_font,' ','~',0);//whole ASCII
spFontAddBorder(middle_font,65535);
settings_set_middle_font(middle_font);
+
+ if (countdown_font)
+ spFontDelete(countdown_font);
+ countdown_font = spFontLoad("./font/StayPuft.ttf",128*spGetSizeFactor()>>SP_ACCURACY);
+ spFontAddRange(countdown_font,' ','~',0);//whole ASCII
+ spFontAddBorder(countdown_font,65535);
+ settings_set_countdown_font(countdown_font);
+
//Particles
resize_particle(w,h);
- refresh_lettering(w,h);
}
int main(int argc, char **argv)
View
11 settings.c
@@ -35,6 +35,7 @@ int highscore_choice;
spFontPointer settings_font;
spFontPointer settings_small_font;
spFontPointer settings_middle_font;
+spFontPointer settings_countdown_font;
int highscore[2][6][10][6];
char highscore_name[2][6][10][6][3];
@@ -287,3 +288,13 @@ void settings_set_middle_font(spFontPointer middle_font)
{
settings_middle_font = middle_font;
}
+
+spFontPointer settings_get_countdown_font()
+{
+ return settings_countdown_font;
+}
+
+void settings_set_countdown_font(spFontPointer countdown_font)
+{
+ settings_countdown_font = countdown_font;
+}
View
2  settings.h
@@ -57,5 +57,7 @@ spFontPointer settings_get_small_font();
void settings_set_small_font(spFontPointer small_font);
spFontPointer settings_get_middle_font();
void settings_set_middle_font(spFontPointer middle_font);
+spFontPointer settings_get_countdown_font();
+void settings_set_countdown_font(spFontPointer countdown_font);
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.