[Tux4kids-commits] r1712 - tuxmath/trunk/src
Jesús Manuel Mager Hois
fongog-guest at alioth.debian.org
Thu Dec 31 22:34:23 UTC 2009
Author: fongog-guest
Date: 2009-12-31 22:34:23 +0000 (Thu, 31 Dec 2009)
New Revision: 1712
Modified:
tuxmath/trunk/src/factoroids.c
Log:
Fixed bugs: Factoroids allowing you to get a huge score typing numerator
of a fraction or typing the number of a prime asteroid.
Modified: tuxmath/trunk/src/factoroids.c
===================================================================
--- tuxmath/trunk/src/factoroids.c 2009-12-31 13:34:17 UTC (rev 1711)
+++ tuxmath/trunk/src/factoroids.c 2009-12-31 22:34:23 UTC (rev 1712)
@@ -1456,7 +1456,7 @@
/*Return -1 if no laser is available*/
int FF_add_laser(void)
{
- int i, k, zapIndex;
+ int i, k, zapIndex, zapScore;
float ux, uy, s, smin,dx,dy,dx2, dy2, d2, thresh;
int screensize;
SDL_Surface *asteroid_image;
@@ -1492,7 +1492,10 @@
// With this parametrization, it's easy to calculate the
// closest approach to the asteroid center, etc.
zapIndex = -1; // keep track of the closest "hit" asteroid
+ zapScore = 0;
smin = 10*screensize;
+
+
for (k=0; k<MAX_ASTEROIDS; k++)
{
if (!asteroid[k].alive)
@@ -1514,18 +1517,32 @@
{
// The laser intersects the asteroid. Check to see if
// the answer works
- if((asteroid[k].isprime && ((num==asteroid[k].fact_number)||(num==0))) ||
- (FF_game==FACTOROIDS_GAME && num > 1 && ((asteroid[k].fact_number%num)==0) && (num!=asteroid[k].fact_number)) ||
- (FF_game==FRACTIONS_GAME && num > 1 && ((asteroid[k].a%num)==0) && ((asteroid[k].a%num)==0) && (num!=asteroid[k].fact_number)))
+
+ if( (FF_game==FACTOROIDS_GAME && (asteroid[k].isprime && ((num==asteroid[k].fact_number)||(num==0)))) ||
+ (FF_game==FRACTIONS_GAME && (asteroid[k].isprime && num==0))
+ )
{
// It's valid, check to see if it's closest
if (s < smin)
{
- // It's the closest yet examined
+ // It's the closest yet examined but has not score
smin = s;
zapIndex = k;
+ zapScore = 0;
}
}
+ else if((FF_game==FACTOROIDS_GAME && num > 1 && ((asteroid[k].fact_number%num)==0) && (num!=asteroid[k].fact_number)) ||
+ (FF_game==FRACTIONS_GAME && num > 1 && ((asteroid[k].a%num)==0) && ((asteroid[k].b%num)==0) && (num!=asteroid[k].fact_number)))
+ {
+ // It's valid, check to see if it's closest
+ if (s < smin)
+ {
+ // It's the closest yet examined and has socre
+ smin = s;
+ zapIndex = k;
+ zapScore = 1;
+ }
+ }
}
}
}
@@ -1541,7 +1558,10 @@
if (floor((float)score/100) < floor((float)(score+num)/100))
tuxship.lives++;
- score += num;
+ if(zapScore)
+ {
+ score += num;
+ }
}
return 1;
}
@@ -2155,7 +2175,7 @@
{
return GAME_OVER_LOST;
}
- if(score>=10000 || wave >= 30 )
+ if(score>=10000 || wave >= 20 )
{
return GAME_OVER_WON;
}
More information about the Tux4kids-commits
mailing list