[Tux4kids-commits] r84 - tuxtype/trunk/tuxtype

calarndt at alioth.debian.org calarndt at alioth.debian.org
Thu Mar 8 21:35:49 CET 2007


Author: calarndt
Date: 2006-01-31 22:13:02 +0000 (Tue, 31 Jan 2006)
New Revision: 84

Modified:
   tuxtype/trunk/tuxtype/practice.c
Log:
remove redundant print_phrase(), calculate wrapped y position in print_at(), remove uneeded cast in Phrases()

Modified: tuxtype/trunk/tuxtype/practice.c
===================================================================
--- tuxtype/trunk/tuxtype/practice.c	2006-01-31 18:52:09 UTC (rev 83)
+++ tuxtype/trunk/tuxtype/practice.c	2006-01-31 22:13:02 UTC (rev 84)
@@ -138,7 +138,7 @@
 			if (pw[c]<598){
 				if ( c==0 ){
 					wp=strlen(phrase[c]);
-					print_phrase( phrase[0], wp );
+					print_at( phrase[0], wp, 40, 10 );
 				}
 			}else{
 				z=0;
@@ -157,39 +157,13 @@
 					}
 				}
 				if ( c==0 ){
-				print_phrase( phrase[0], wp );
+				print_at( phrase[0], wp, 40, 10 );
 				}
 			}
 	}
 	return(wp);
 }
 
-
-void print_phrase( char *pphrase, int wrap ) {
-	int z=0;
-	letter_loc.x = 40;
-	letter_loc.y = 10;
-	letter_loc.w = letters[65]->w;
-	letter_loc.h = letters[65]->h;
-	if ( wrap == strlen(pphrase) ){
-		for (z=0;z<strlen(pphrase);z++){
-			SDL_BlitSurface(letters[(int)pphrase[z]], NULL, screen, &letter_loc);
-			letter_loc.x = (letter_loc.x + letters[(int)pphrase[z]]->w)-5;
-		}
-	}else{
-		for (z=0;z<=wrap;z++){
-			SDL_BlitSurface(letters[(int)pphrase[z]], NULL, screen, &letter_loc);
-			letter_loc.x = (letter_loc.x + letters[(int)pphrase[z]]->w)-5;
-		}
-		letter_loc.x = 40;
-		letter_loc.y = 45;
-		for (z=wrap+2;z<strlen(pphrase);z++){
-			SDL_BlitSurface(letters[(int)pphrase[z]], NULL, screen, &letter_loc);
-			letter_loc.x = (letter_loc.x + letters[(int)pphrase[z]]->w)-5;
-		}
-	}
-}
-
 void print_at( char *pphrase, int wrap, int x, int y ) {
 	int z=0;
 	letter_loc.x = x;
@@ -207,7 +181,8 @@
 			letter_loc.x = (letter_loc.x + letters[(int)pphrase[z]]->w)-5;
 		}
 		letter_loc.x = 40;
-		letter_loc.y = 45;
+                // - (letter_loc.h/4) to account for free space at top and bottom of rendered letters
+		letter_loc.y = letter_loc.y + letter_loc.h - (letter_loc.h/4);
 		for (z=wrap+2;z<strlen(pphrase);z++){
 			SDL_BlitSurface(letters[(int)pphrase[z]], NULL, screen, &letter_loc);
 			letter_loc.x = (letter_loc.x + letters[(int)pphrase[z]]->w)-5;
@@ -251,11 +226,10 @@
  	dst3.x = 50;				dst3.y = 400;	dst3.w = 160;			dst3.h = 50;
  	dst4.x = 480;				dst4.y = 400;	dst4.w = 240;			dst4.h = 50;
  	dst5.x = 480;				dst5.y = 400;	dst5.w = 240;			dst5.h = 50;
-
-/*	SDL_BlitSurface(bkg, &dst, screen, &dst);
-	SDL_Flip(screen);*/
 	dst.x = 40;
+
 	start = SDL_GetTicks();
+
 	do {
 		switch (state) {
 		case 0:
@@ -323,7 +297,7 @@
 						}
 						dst.x = (dst.x + letters[KEYMAP[event.key.keysym.unicode]]->w) - 5;
 						if (c==(strlen(pphrase)-1)){
-							print_at((char *)"Great!",6 ,275 ,200);
+							print_at("Great!",6 ,275 ,200);
 							SDL_Flip(screen);
 							SDL_Delay(2500);
 							quit=1;




More information about the Tux4kids-commits mailing list