From 5c95629bc6923616ae9546db4097147dd1d11016 Mon Sep 17 00:00:00 2001 From: Deskull Date: Mon, 12 Jan 2015 20:21:47 +0900 Subject: [PATCH] =?utf8?q?GameSurfaceSDL=20=E3=82=AF=E3=83=A9=E3=82=B9?= =?utf8?q?=E3=81=AE=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA?= =?utf8?q?=E3=83=B3=E3=82=B0=20/=20Code=20refactoring=20of=20GameSurfaceSD?= =?utf8?q?L=20class.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Deeangband/GameSurfaceSDL.cpp | 8 ++++---- Deeangband/GameSurfaceSDL.h | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) 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ƒ‹) -- 2.11.0