Skip to content
Browse files

FIX sprite position according to its physic

attempt to fix collision issue by using bit or instead of '+'
MOD remove useless comment "end of namespace xxx"
  • Loading branch information...
1 parent 9833688 commit 639b0c00ddfdb5d42f86a3929d9cc6c0f54da466 @PowerKiKi committed Nov 21, 2010
Showing with 82 additions and 69 deletions.
  1. +1 −2 application/source/Actor.cpp
  2. +1 −1 application/source/Actor.h
  3. +1 −1 application/source/ActorAction.h
  4. +1 −1 application/source/ActorState.h
  5. +1 −1 application/source/Bullets/Bullet.cpp
  6. +1 −1 application/source/Bullets/Bullet.h
  7. +2 −2 application/source/CollisionCategories.h
  8. +1 −1 application/source/Constants.cpp
  9. +1 −1 application/source/Effect.cpp
  10. +1 −1 application/source/Effect.h
  11. +1 −1 application/source/Element.h
  12. +2 −2 application/source/Ennemies/Bee.cpp
  13. +1 −1 application/source/Ennemies/Bee.h
  14. +1 −1 application/source/Ennemies/Earthworm.cpp
  15. +1 −1 application/source/Ennemies/Earthworm.h
  16. +1 −1 application/source/Ennemies/Ennemy.cpp
  17. +1 −1 application/source/Ennemies/Ennemy.h
  18. +1 −1 application/source/Ennemies/EnnemyGenerator.cpp
  19. +1 −1 application/source/Ennemies/EnnemyGenerator.h
  20. +1 −1 application/source/Ennemies/Spider.cpp
  21. +1 −1 application/source/Ennemies/Spider.h
  22. +1 −1 application/source/Game.cpp
  23. +1 −1 application/source/Game.h
  24. +1 −1 application/source/ImageLibrary.cpp
  25. +1 −1 application/source/ImageLibrary.h
  26. +2 −2 application/source/Items/Deodorant.cpp
  27. +2 −2 application/source/Items/Deodorant.h
  28. +2 −2 application/source/Items/Flyswater.cpp
  29. +2 −2 application/source/Items/Flyswater.h
  30. +2 −2 application/source/Items/Item.cpp
  31. +2 −2 application/source/Items/Item.h
  32. +2 −2 application/source/Items/Ligther.cpp
  33. +2 −2 application/source/Items/Ligther.h
  34. +2 −2 application/source/Items/Matches.cpp
  35. +2 −2 application/source/Items/Matches.h
  36. +2 −2 application/source/Level.cpp
  37. +1 −1 application/source/Level.h
  38. +1 −1 application/source/Pets/Ladybird.cpp
  39. +1 −1 application/source/Pets/Ladybird.h
  40. +1 −1 application/source/Pets/Pet.cpp
  41. +1 −1 application/source/Pets/Pet.h
  42. +1 −1 application/source/Players/Kiki.h
  43. +1 −1 application/source/Players/Lila.h
  44. +1 −1 application/source/Players/Luna.h
  45. +2 −2 application/source/Players/Player.cpp
  46. +1 −1 application/source/Players/Player.h
  47. +1 −1 application/source/Players/Poupa.h
  48. +1 −1 application/source/Rubbish.cpp
  49. +1 −1 application/source/Rubbish.h
  50. +9 −2 application/source/Sprite.cpp
  51. +8 −1 application/source/Sprite.h
  52. +1 −1 application/source/Warpzone.cpp
  53. +1 −1 application/source/Warpzone.h
View
3 application/source/Actor.cpp
@@ -75,8 +75,7 @@ namespace Polukili
{
GRRLIB_texImg* image = this->level->game->imageLibrary.get(this->getImagePath());
this->sprite = new Sprite(image, this->getImageWidth(), this->getImageHeight());
- // this->sprite->SetRefPixelPositioning(wsp::REFPIXEL_POS_PIXEL);
- // this->sprite->SetRefPixelPosition(((int)this->getImageWidth()/2),(int)(this->getImageHeight()/2));
+ this->sprite->setReferencePosition(((int)this->getImageWidth()/2),(int)(this->getImageHeight()/2));
}
/*************************************************/
View
2 application/source/Actor.h
@@ -164,7 +164,7 @@ namespace Polukili
Effect* effect;
};
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/ActorAction.h
@@ -21,6 +21,6 @@ namespace Polukili
movingDown = 512,
};
-}/* End of namespace Polukili */
+}
#endif
View
2 application/source/ActorState.h
@@ -18,6 +18,6 @@ namespace Polukili
dying = 64,
};
-}/* End of namespace Polukili */
+}
#endif
View
2 application/source/Bullets/Bullet.cpp
@@ -35,7 +35,7 @@ namespace Polukili
bulletDef.friction = Constants::defaultFriction;
bulletDef.restitution = Constants::defaultRestitution;
bulletDef.filter.categoryBits = bullets;
- bulletDef.filter.maskBits = ground + enemies;
+ bulletDef.filter.maskBits = ground | enemies;
this->body->CreateFixture(&bulletDef);
b2Vec2 shotImpulse;
View
2 application/source/Bullets/Bullet.h
@@ -58,7 +58,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Bullets */
-} /* End of namespace Polukili */
+}
#endif
View
4 application/source/CollisionCategories.h
@@ -4,7 +4,7 @@
namespace Polukili
{
/**
- * The possible collsision categories ( box2d can handle up to 16 categories.
+ * The possible collision categories ( box2d can handle up to 16 categories.
*/
enum CollisionCategories
{
@@ -17,6 +17,6 @@ namespace Polukili
};
-}/* End of namespace Polukili */
+}
#endif
View
2 application/source/Constants.cpp
@@ -14,4 +14,4 @@ namespace Polukili
const int Constants::iterations = 10;
const int Constants::maximumPlayers = 4;
const int Constants::physicMargin = 640;
-} /* End of namespace Polukili */
+}
View
2 application/source/Effect.cpp
@@ -9,5 +9,5 @@ namespace Polukili
{
}
-} /* End of namespace Polukili */
+}
View
2 application/source/Effect.h
@@ -27,7 +27,7 @@ namespace Polukili
//end of class Effect
};
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Element.h
@@ -17,6 +17,6 @@ namespace Polukili
electricity = 64,
ice = 128
};
-}/* End of namespace Polukili */
+}
#endif
View
4 application/source/Ennemies/Bee.cpp
@@ -45,7 +45,7 @@ namespace Polukili
beeDef.friction = Constants::defaultFriction;
beeDef.restitution = Constants::defaultRestitution;
beeDef.filter.categoryBits = enemies;
- beeDef.filter.maskBits = players + ground + bullets;
+ beeDef.filter.maskBits = players | ground | bullets;
this->body->CreateFixture(&beeDef);
@@ -96,5 +96,5 @@ namespace Polukili
}
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
View
2 application/source/Ennemies/Bee.h
@@ -44,7 +44,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Ennemies/Earthworm.cpp
@@ -13,5 +13,5 @@ namespace Polukili
}
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
View
2 application/source/Ennemies/Earthworm.h
@@ -21,7 +21,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Ennemies/Ennemy.cpp
@@ -39,5 +39,5 @@ namespace Polukili
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
View
2 application/source/Ennemies/Ennemy.h
@@ -41,7 +41,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Ennemies/EnnemyGenerator.cpp
@@ -13,5 +13,5 @@ namespace Polukili
}
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
View
2 application/source/Ennemies/EnnemyGenerator.h
@@ -26,7 +26,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Ennemies/Spider.cpp
@@ -13,5 +13,5 @@ namespace Polukili
}
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
View
2 application/source/Ennemies/Spider.h
@@ -21,7 +21,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Ennemies */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Game.cpp
@@ -148,5 +148,5 @@ namespace Polukili
Console::log(LOG_INFO, "Game::changeLevel() - end");
}
-} /* End of namespace Polukili */
+}
View
2 application/source/Game.h
@@ -71,7 +71,7 @@ namespace Polukili
bool debugDrawEnabled;
};
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/ImageLibrary.cpp
@@ -55,5 +55,5 @@ namespace Polukili
}
}
-} /* End of namespace Polukili */
+}
View
2 application/source/ImageLibrary.h
@@ -48,7 +48,7 @@ namespace Polukili
//end of class Game
};
-} /* End of namespace Polukili */
+}
#endif
View
4 application/source/Items/Deodorant.cpp
@@ -8,6 +8,6 @@ namespace Polukili
{
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
View
4 application/source/Items/Deodorant.h
@@ -13,8 +13,8 @@ namespace Polukili
//end of class Deodorant
};
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
#endif
View
4 application/source/Items/Flyswater.cpp
@@ -8,6 +8,6 @@ namespace Polukili
{
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
View
4 application/source/Items/Flyswater.h
@@ -13,8 +13,8 @@ namespace Polukili
//end of class Flyswater
};
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
#endif
View
4 application/source/Items/Item.cpp
@@ -8,6 +8,6 @@ namespace Polukili
{
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
View
4 application/source/Items/Item.h
@@ -16,8 +16,8 @@ namespace Polukili
//end of class Item
};
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
#endif
View
4 application/source/Items/Ligther.cpp
@@ -8,6 +8,6 @@ namespace Polukili
{
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
View
4 application/source/Items/Ligther.h
@@ -13,8 +13,8 @@ namespace Polukili
//end of class Ligther
};
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
#endif
View
4 application/source/Items/Matches.cpp
@@ -8,6 +8,6 @@ namespace Polukili
{
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
View
4 application/source/Items/Matches.h
@@ -13,8 +13,8 @@ namespace Polukili
//end of class Matches
};
- } /* End of namespace Polukili::Items */
-} /* End of namespace Polukili */
+ }
+}
#endif
View
4 application/source/Level.cpp
@@ -148,7 +148,7 @@ namespace Polukili
b2FixtureDef polygonDef;
polygonDef.shape = &polygonShape;
- polygonDef.filter.categoryBits = ground;
+ polygonDef.filter.categoryBits = ground;
this->body->CreateFixture(&polygonDef);
Console::log(LOG_INFO, "Level::loadFromXML() - polygon read");
@@ -345,5 +345,5 @@ namespace Polukili
return true;
}
-} /* End of namespace Polukili */
+}
View
2 application/source/Level.h
@@ -104,7 +104,7 @@ namespace Polukili
};
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Pets/Ladybird.cpp
@@ -9,5 +9,5 @@ namespace Polukili
} /* End of namespace Polukili::Pets */
-} /* End of namespace Polukili */
+}
View
2 application/source/Pets/Ladybird.h
@@ -14,7 +14,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Pets */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Pets/Pet.cpp
@@ -19,5 +19,5 @@ namespace Polukili
this->level->pets.remove(this);
}
} /* End of namespace Polukili::Pets */
-} /* End of namespace Polukili */
+}
View
2 application/source/Pets/Pet.h
@@ -28,7 +28,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Pets */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Players/Kiki.h
@@ -24,7 +24,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Players/Lila.h
@@ -24,7 +24,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Players/Luna.h
@@ -24,7 +24,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
#endif
View
4 application/source/Players/Player.cpp
@@ -44,7 +44,7 @@ namespace Polukili
playerDef.friction = Constants::defaultFriction;
playerDef.restitution = Constants::defaultRestitution;
playerDef.filter.categoryBits = players;
- playerDef.filter.maskBits = ground + enemies;
+ playerDef.filter.maskBits = ground | enemies;
this->body->CreateFixture(&playerDef);
@@ -196,5 +196,5 @@ namespace Polukili
}
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
View
2 application/source/Players/Player.h
@@ -85,7 +85,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Players/Poupa.h
@@ -26,7 +26,7 @@ namespace Polukili
};
} /* End of namespace Polukili::Players */
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Rubbish.cpp
@@ -6,5 +6,5 @@ namespace Polukili
{
-} /* End of namespace Polukili */
+}
View
2 application/source/Rubbish.h
@@ -14,7 +14,7 @@ namespace Polukili
//end of class Rubbish
};
-} /* End of namespace Polukili */
+}
#endif
View
11 application/source/Sprite.cpp
@@ -10,7 +10,7 @@ namespace Polukili
{
/*************************************************/
Sprite::Sprite(GRRLIB_texImg* image, int width, int height)
- : image(image), x(0), y(0), factor(1), angle(0)
+ : image(image), x(0), y(0), referenceX(0), referenceY(0), factor(1), angle(0)
{
Console::log(LOG_INFO, "new Sprite");
}
@@ -24,7 +24,7 @@ namespace Polukili
/*************************************************/
void Sprite::draw()
{
- GRRLIB_DrawImg(this->x, this->y, this->image, this->angle, this->factor, this->factor, 0xFFFFFFFF);
+ GRRLIB_DrawImg(this->x - this->referenceX, this->y - this->referenceY, this->image, this->angle, this->factor, this->factor, 0xFFFFFFFF);
}
/*************************************************/
@@ -35,6 +35,13 @@ namespace Polukili
}
/*************************************************/
+ void Sprite::setReferencePosition(int x, int y)
+ {
+ this->referenceX = x;
+ this->referenceY = y;
+ }
+
+ /*************************************************/
void Sprite::setZoom(float factor)
{
this->factor = factor;
View
9 application/source/Sprite.h
@@ -39,6 +39,11 @@ namespace Polukili
void setPosition(int x, int y);
/**
+ * Defines the reference position for the sprite (or offset)
+ */
+ void setReferencePosition(int x, int y);
+
+ /**
* Defines the current zoom factor
*/
void setZoom(float factor);
@@ -57,11 +62,13 @@ namespace Polukili
int x;
int y;
+ int referenceX;
+ int referenceY;
float factor;
int angle;
};
-} /* End of namespace Polukili */
+}
#endif
View
2 application/source/Warpzone.cpp
@@ -5,5 +5,5 @@
namespace Polukili
{
-} /* End of namespace Polukili */
+}
View
2 application/source/Warpzone.h
@@ -14,7 +14,7 @@ namespace Polukili
//end of class Warpzone
};
-} /* End of namespace Polukili */
+}
#endif

0 comments on commit 639b0c0

Please sign in to comment.
Something went wrong with that request. Please try again.