{
public:
Collision():mPos(0.0,0.0),color(0xFF00FF00){ }
- Point2D mPos;/**< The position of the center of the collision data */
+ Point2D mPos;/**< The position of the center of the collision data \todo need the parent object's position*/
bool checkCollisions(const vector<Collision*>& c); /**< Check collision with objects */
virtual bool collision(const Collision *c) = 0; /**< Check collision with objects */
/// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
}
Sprite* Level::findSpriteByName(string name){
+ /// \todo make this return a list of all sprites with the same name (or make it specifiable)
for(int i=0; i < mSprites.size(); i++){
if(mSprites[i]->getName()==name)//find the sprite with the same name
return mSprites[i];
if ( keys[SDLK_d] ) { mBackground->xadd(1); }
if ( keys[SDLK_w] ) { mBackground->yadd(-1); }
if ( keys[SDLK_s] ) { mBackground->yadd(1); }
-
+ Level::update();
}
SpriteFrame frame = mActor.mAnimations[mActor.mCurrentAnimation]->mAnim[mActor.mFrame];
//get the first sprite with this name
Sprite* s= Game::game()->getCurrentLevel()->findSpriteByName(name);
+ if(s==NULL)
+ return NULL;
for(int i=0; i < frame.collisionData.size(); i++)
if(frame.collisionData[i]->checkCollisions(s->getCollisionData()))//if there is a collision
return s;