[Super-tux-commit] supertux/src collision.cpp,1.6,1.7 player.cpp,1.14,1.15
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-03-25 19:03:24
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3771 Modified Files: collision.cpp player.cpp Log Message: - fixed brick-bug (or maybe not, they still behave a bit weird - moved some int's into the for-loops to reduce variable recycling Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- player.cpp 25 Mar 2004 11:07:02 -0000 1.14 +++ player.cpp 25 Mar 2004 18:52:34 -0000 1.15 @@ -242,13 +242,13 @@ if(size == SMALL) { Tile* tile = gettile(base.x, base.y); - Tile* tile2 = gettile(base.x + 31, base.y); /* Get a distro from a brick? */ if (tile->brick) { add_bouncy_distro((((int)base.x) / 32) * 32, ((int)base.y / 32) * 32); + if (counting_distros == false) { counting_distros = true; @@ -262,7 +262,11 @@ score = score + SCORE_DISTRO; distros++; } - else if (tile2->brick) + } + else + { + Tile* tile2 = gettile(base.x + 31, base.y); + if (tile2->brick) { add_bouncy_distro((((int)base.x + 31) / 32) * 32, Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- collision.cpp 24 Mar 2004 17:41:04 -0000 1.6 +++ collision.cpp 25 Mar 2004 18:52:34 -0000 1.7 @@ -33,10 +33,8 @@ bool collision_object_map(base_type* pbase) { - int v,h,i; - - v = (int)pbase->height / 16; - h = (int)pbase->width / 16; + int v = (int)pbase->height / 16; + int h = (int)pbase->width / 16; if(issolid(pbase->x + 1, pbase->y + 1) || issolid(pbase->x + pbase->width -1, pbase->y + 1) || @@ -44,24 +42,24 @@ issolid(pbase->x + pbase->width -1, pbase->y + pbase->height - 1)) return true; - for(i = 1; i < h; ++i) + for(int i = 1; i < h; ++i) { if(issolid(pbase->x + i*16,pbase->y + 1)) return true; } - for(i = 1; i < h; ++i) + for(int i = 1; i < h; ++i) { if( issolid(pbase->x + i*16,pbase->y + pbase->height - 1)) return true; } - for(i = 1; i < v; ++i) + for(int i = 1; i < v; ++i) { if( issolid(pbase->x + 1, pbase->y + i*16)) return true; } - for(i = 1; i < v; ++i) + for(int i = 1; i < v; ++i) { if( issolid(pbase->x + pbase->width - 1, pbase->y + i*16)) return true; @@ -75,7 +73,6 @@ { int steps; /* Used to speed up the collision tests, by stepping every 16pixels in the path. */ int h; - float i; float lpath; /* Holds the longest path, which is either in X or Y direction. */ float xd,yd; /* Hold the smallest steps in X and Y directions. */ float temp, xt, yt; /* Temporary variable. */ @@ -138,7 +135,7 @@ old->x += xd; old->y += yd; - for(i = 0; i <= lpath; old->x += xd, old->y += yd, ++i) + for(float i = 0; i <= lpath; old->x += xd, old->y += yd, ++i) { if(steps > 0) { @@ -206,18 +203,17 @@ void collision_handler() { - unsigned int i,j; - - /* CO_BULLET & CO_BADGUY check */ - for(i = 0; i < bullets.size(); ++i) + // CO_BULLET & CO_BADGUY check + for(unsigned int i = 0; i < bullets.size(); ++i) { - for(j = 0; j < bad_guys.size(); ++j) + for(unsigned int j = 0; j < bad_guys.size(); ++j) { if(bad_guys[j].dying == DYING_NOT) { if(rectcollision(&bullets[i].base,&bad_guys[j].base)) { - /* We have detected a collision and now call the collision functions of the collided objects. */ + // We have detected a collision and now call the + // collision functions of the collided objects. bullet_collision(&bullets[i], CO_BADGUY); bad_guys[j].collision(&bullets[i], CO_BULLET); } @@ -226,17 +222,18 @@ } /* CO_BADGUY & CO_BADGUY check */ - for(i = 0; i < bad_guys.size(); ++i) + for(unsigned int i = 0; i < bad_guys.size(); ++i) { if(bad_guys[i].dying == DYING_NOT) { - for(j = i+1; j < bad_guys.size(); ++j) + for(unsigned int j = i+1; j < bad_guys.size(); ++j) { if(j != i && !bad_guys[j].dying) { if(rectcollision(&bad_guys[i].base, &bad_guys[j].base)) { - /* We have detected a collision and now call the collision functions of the collided objects. */ + // We have detected a collision and now call the + // collision functions of the collided objects. bad_guys[j].collision(&bad_guys[i], CO_BADGUY); bad_guys[i].collision(&bad_guys[j], CO_BADGUY); } @@ -245,14 +242,13 @@ } } - - - /* CO_BADGUY & CO_PLAYER check */ - for(i = 0; i < bad_guys.size(); ++i) + // CO_BADGUY & CO_PLAYER check + for(unsigned int i = 0; i < bad_guys.size(); ++i) { if(bad_guys[i].dying == DYING_NOT && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0)) { - /* We have detected a collision and now call the collision functions of the collided objects. */ + // We have detected a collision and now call the collision + // functions of the collided objects. if (tux.previous_base.y < tux.base.y && tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 && bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD) @@ -266,12 +262,13 @@ } } - /* CO_UPGRADE & CO_PLAYER check */ - for(i = 0; i < upgrades.size(); ++i) + // CO_UPGRADE & CO_PLAYER check + for(unsigned int i = 0; i < upgrades.size(); ++i) { if(rectcollision(&upgrades[i].base,&tux.base)) { - /* We have detected a collision and now call the collision functions of the collided objects. */ + // We have detected a collision and now call the collision + // functions of the collided objects. upgrade_collision(&upgrades[i], &tux, CO_PLAYER); } } |