From: Deskull Date: Mon, 12 Jan 2015 11:21:47 +0000 (+0900) Subject: GameSurfaceSDL クラスのリファクタリング / Code refactoring of GameSurfaceSDL class. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5c95629bc6923616ae9546db4097147dd1d11016;p=deeangband%2FDeeangband-new.git GameSurfaceSDL クラスのリファクタリング / Code refactoring of GameSurfaceSDL class. --- diff --git a/Deeangband/GameSurfaceSDL.cpp b/Deeangband/GameSurfaceSDL.cpp index a4586d3..4a6fd6d 100644 --- a/Deeangband/GameSurfaceSDL.cpp +++ b/Deeangband/GameSurfaceSDL.cpp @@ -221,7 +221,7 @@ namespace Deeangband SDL_RenderClear(renderer); SDL_GetWindowSize(window, &rectTemp.w, &rectTemp.h); - this->rectMainMapDst.Set(200, 20, rectTemp.w - 210, rectTemp.h - 40); + this->rectMainMapDst.Set(240, 20, rectTemp.w - 210, rectTemp.h - 40); SDL_SetRenderDrawColor(renderer, 50, 20, 0, 255); SDL_RenderCopy(renderer, titleTexture, &rectTitleSrc, &rectTitleDst); @@ -601,7 +601,7 @@ void GameSurfaceSDL::calcMapDrawingSize(Coordinates *size) { int x, y; SDL_GetWindowSize(window, &x, &y); - size->Set((x - GameSurfaceSDL::sideBarWidth) / squareGraphicWidth, y / squareGraphicHeight - 1); + size->Set((x - 240) / squareGraphicWidth, y / squareGraphicHeight - 1); return; } @@ -620,7 +620,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld * { if(px >= 0 && py >= 0 && px < fieldPtr->GetWidth() && py < fieldPtr->GetHeight()) { - SDL_Rect blitRect = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth, 30 + (py - y) * squareGraphicHeight , squareGraphicWidth, squareGraphicHeight}; + SDL_Rect blitRect = {rectDraw.x + (px - x) * squareGraphicWidth, rectDraw.y + (py - y) * squareGraphicHeight , squareGraphicWidth, squareGraphicHeight}; /* SDL_Rect checkRect1 = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 2 + 12, 30 + (py - y) * squareGraphicHeight - 2 + 12, 4, 4}; SDL_Rect checkRect2 = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 2, 30 + (py - y) * squareGraphicHeight - 2, 4, 4}; @@ -679,7 +679,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld * if(subJectCreaturePtr->InSight(creatureIt->second->GetPosition().GetX(), creatureIt->second->GetPosition().GetY())) { - SDL_Rect blitRect = {GameSurfaceSDL::sideBarWidth + (creatureIt->second->GetPosition().GetX() - x) * squareGraphicWidth, 30 + (creatureIt->second->GetPosition().GetY()- y) * squareGraphicHeight, squareGraphicWidth, squareGraphicHeight}; + SDL_Rect blitRect = {rectDraw.x + (creatureIt->second->GetPosition().GetX() - x) * squareGraphicWidth, rectDraw.y + (creatureIt->second->GetPosition().GetY()- y) * squareGraphicHeight, squareGraphicWidth, squareGraphicHeight}; SDL_RenderCopy(renderer, creatureTextures[creatureIt->first], &symbolRect, &blitRect); } diff --git a/Deeangband/GameSurfaceSDL.h b/Deeangband/GameSurfaceSDL.h index 7a4352b..735ca2d 100644 --- a/Deeangband/GameSurfaceSDL.h +++ b/Deeangband/GameSurfaceSDL.h @@ -44,6 +44,12 @@ namespace Deeangband this->h = h; } + SDL_Rect_Dee SDL_Rect_Dee::operator+(const SDL_Rect_Dee& plus) + { + this->x += plus.x; + this->y += plus.y; + return *this; + } SDL_Rect_Dee() { @@ -62,7 +68,6 @@ namespace Deeangband { private: - static const int sideBarWidth = 240; //!< ƒTƒCƒhƒo[‚Ì• static const int squareGraphicWidth = 24; //!< 1ƒ}ƒX‚̃Oƒ‰ƒtƒBƒbƒN•(ƒsƒNƒZƒ‹) static const int squareGraphicHeight = 24; //!< 1ƒ}ƒX‚̃Oƒ‰ƒtƒBƒbƒN‚‚³(ƒsƒNƒZƒ‹)