From: unknown Date: Tue, 1 Feb 2011 03:03:13 +0000 (-0600) Subject: removed all warnings about casts and signedness X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=8efaef1c71ae0260eba57226d136c4486afe31d7;p=IvanGame.git removed all warnings about casts and signedness --- diff --git a/Background.cpp b/Background.cpp index d5a0284..0235d44 100644 --- a/Background.cpp +++ b/Background.cpp @@ -13,10 +13,10 @@ mScreen(screen), mScreenSize.w = screen->w; mScreenSize.h = screen->h; - source.w = bgSize.w; - source.h = bgSize.h; - source.x = bgSamplePos.x; - source.y = bgSamplePos.y; + source.w = (int)bgSize.w; + source.h = (int)bgSize.h; + source.x = (int)bgSamplePos.x; + source.y = (int)bgSamplePos.y; load(filename); @@ -128,19 +128,19 @@ void Background::draw(){ y += H; while(x > 0)//move back til we are at the spot to the left of the current background x -= W; - int initx = x; + int initx = (int)x; while(y > 0) y -= H; for(y; y < Y; y += H) for(x = initx; x < X; x += W){ - dest.x = x; - dest.y = y; + dest.x = (int)x; + dest.y = (int)y; SDL_BlitSurface(mBackground, NULL, mScreen, &dest); } } else { - dest.x = mPos.x; - dest.y = mPos.y; + dest.x = (int)mPos.x; + dest.y = (int)mPos.y; SDL_BlitSurface(mBackground, &source, mScreen, &dest); } } diff --git a/Collision.cpp b/Collision.cpp index b49c51c..6d82192 100644 --- a/Collision.cpp +++ b/Collision.cpp @@ -78,14 +78,14 @@ void DrawPixel(SDL_Surface *screen, int x, int y, Uint32 c) \param color the color to be drawn */ void DrawCircle(SDL_Surface* screen, const Point2D wPos, const Point2D pos, Uint32 color){ - DrawPixel(screen, wPos.x + pos.x, wPos.y + pos.y, color); - DrawPixel(screen, wPos.x - pos.x, wPos.y + pos.y, color); - DrawPixel(screen, wPos.x + pos.x, wPos.y - pos.y, color); - DrawPixel(screen, wPos.x - pos.x, wPos.y - pos.y, color); - DrawPixel(screen, wPos.x + pos.y, wPos.y + pos.x, color); - DrawPixel(screen, wPos.x - pos.y, wPos.y + pos.x, color); - DrawPixel(screen, wPos.x + pos.y, wPos.y - pos.x, color); - DrawPixel(screen, wPos.x - pos.y, wPos.y - pos.x, color); + DrawPixel(screen, int(wPos.x + pos.x), int(wPos.y + pos.y), color); + DrawPixel(screen, int(wPos.x - pos.x), int(wPos.y + pos.y), color); + DrawPixel(screen, int(wPos.x + pos.x), int(wPos.y - pos.y), color); + DrawPixel(screen, int(wPos.x - pos.x), int(wPos.y - pos.y), color); + DrawPixel(screen, int(wPos.x + pos.y), int(wPos.y + pos.x), color); + DrawPixel(screen, int(wPos.x - pos.y), int(wPos.y + pos.x), color); + DrawPixel(screen, int(wPos.x + pos.y), int(wPos.y - pos.x), color); + DrawPixel(screen, int(wPos.x - pos.y), int(wPos.y - pos.x), color); } /** This function is tasked with drawing lines by the midpoint method. @@ -102,16 +102,16 @@ void DrawLine(SDL_Surface* screen, const Point2D start, Point2D end, Uint32 colo //if the end point is lower swap em if(end.y < start.y){ - x = end.x; - y = end.y; - xMax = start.x; - yMax = start.y; + x = (int)end.x; + y = (int)end.y; + xMax = (int)start.x; + yMax = (int)start.y; } else { - x = start.x; - y = start.y; - xMax = end.x; - yMax = end.y; + x = (int)start.x; + y = (int)start.y; + xMax = (int)end.x; + yMax = (int)end.y; } //the change in x @@ -165,8 +165,8 @@ void CollisionRectangle::draw(const Point2D& pos){ void CollisionCircle::draw(const Point2D& pos){ Slock(Game::game()->Screen()); - int x=0,y=radius;///Screen(), pos + mPos, Point2D(x,y), color); //calculate other points @@ -185,7 +185,7 @@ void CollisionCircle::draw(const Point2D& pos){ } bool Collision::checkCollisions(const vector& c, const Point2D cPos, const Point2D pos){ - for(int i=0; i < c.size(); i++){ + for(unsigned int i=0; i < c.size(); i++){ if(collision(c[i], cPos, pos))//if any are true return true then and there return true; } @@ -195,15 +195,15 @@ bool Collision::checkCollisions(const vector& c, const Point2D cPos, bool CollisionRectangle::collision(const Collision *c, const Point2D cPos, const Point2D pos) const { if(const CollisionRectangle* rec = dynamic_cast(c)){ ///check rect vs rect really just axis aligned box check (simpler) - float r1Left = -width/2 + mPos.x + pos.x; - float r1Right = width/2 + mPos.x + pos.x; - float r1Top = -height/2 + mPos.y + pos.y; - float r1Bottom = height/2 + mPos.y + pos.y; + double r1Left = -width/2 + mPos.x + pos.x; + double r1Right = width/2 + mPos.x + pos.x; + double r1Top = -height/2 + mPos.y + pos.y; + double r1Bottom = height/2 + mPos.y + pos.y; - float r2Left = -rec->width/2 + rec->mPos.x + cPos.x; - float r2Right = rec->width/2 + rec->mPos.x + cPos.x; - float r2Top = -rec->height/2 + rec->mPos.y + cPos.y; - float r2Bottom = rec->height/2 + rec->mPos.y + cPos.y; + double r2Left = -rec->width/2 + rec->mPos.x + cPos.x; + double r2Right = rec->width/2 + rec->mPos.x + cPos.x; + double r2Top = -rec->height/2 + rec->mPos.y + cPos.y; + double r2Bottom = rec->height/2 + rec->mPos.y + cPos.y; bool outsideX = r1Right < r2Left || r1Left > r2Right; bool outsideY = r1Bottom < r2Top || r1Top > r2Bottom; diff --git a/Game.cpp b/Game.cpp index 87a84e5..7625146 100644 --- a/Game.cpp +++ b/Game.cpp @@ -137,7 +137,7 @@ void Game::run() } void Game::loadLevel(std::string levelName){ - for(int i=0; i< mLevels.size(); ++i) + for(unsigned int i=0; i< mLevels.size(); ++i) if(mLevels[i]->getName() == levelName) mCurrentLevel = i; else diff --git a/Game.h b/Game.h index 2b467fe..7c443b3 100644 --- a/Game.h +++ b/Game.h @@ -55,7 +55,7 @@ protected: private: static const Uint32 waitTime; - int mCurrentLevel; /**< Current Level index. */ + unsigned int mCurrentLevel; /**< Current Level index. */ std::vector mLevels;/**< Vector of pointers to all of the levels. \todo Make into map? */ SDL_Surface *mScreen;/**< The surface to draw to. */ diff --git a/Level.cpp b/Level.cpp index b96217d..04296a3 100644 --- a/Level.cpp +++ b/Level.cpp @@ -142,7 +142,7 @@ void Level::removeActor(string name){ 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++){ + for(unsigned int i=0; i < mSprites.size(); i++){ if(mSprites[i]->getName()==name)//find the sprite with the same name return mSprites[i]; } diff --git a/Sprite.cpp b/Sprite.cpp index ed9e49a..18f92c7 100644 --- a/Sprite.cpp +++ b/Sprite.cpp @@ -40,8 +40,8 @@ void Sprite::draw() } } SDL_Rect dest; - dest.x = mPos.x; - dest.y = mPos.y; + dest.x = (int)mPos.x; + dest.y = (int)mPos.y; if(mVisible == true) SDL_BlitSurface(frame->image,NULL,mScreen,&dest); @@ -67,7 +67,7 @@ Sprite* Sprite::collisionWithSprite(string name){ Sprite* s= Game::game()->getCurrentLevel()->findSpriteByName(name); if(s==NULL) return NULL; - for(int i=0; i < frame->collisionData.size(); i++) + for(unsigned int i=0; i < frame->collisionData.size(); i++) if(frame->collisionData[i]->checkCollisions(s->getCollisionData(), s->mPos + s->getAnimation()->animationPeg, mPos + frame->animationPeg))//if there is a collision return s; return NULL;//if there aren't collisions diff --git a/WorldObject.cpp b/WorldObject.cpp index 4dbffa8..3ed213f 100644 --- a/WorldObject.cpp +++ b/WorldObject.cpp @@ -3,7 +3,7 @@ void WorldObject::drawCollisions(vector &vec, const Point2D& pos){ - for(int i=0; i < vec.size(); i++){ + for(unsigned int i=0; i < vec.size(); i++){ vec[i]->draw(pos); } }