OSDN Git Service

視界範囲処理再実装中。 / Implementing processes of sight range.
authorDeskull <desull@users.sourceforge.jp>
Thu, 8 Jan 2015 14:26:13 +0000 (23:26 +0900)
committerDeskull <desull@users.sourceforge.jp>
Thu, 8 Jan 2015 14:26:13 +0000 (23:26 +0900)
Deeangband/Field.cpp
Deeangband/Field.h
Deeangband/GameSurfaceSDL.cpp

index 1a2f70f..c803a77 100644 (file)
@@ -34,6 +34,8 @@ namespace Deeangband
                        }
                }
 
+               Field::UpdateSight();
+
                creatures.resize(0);
                doors.resize(0);
                traps.resize(0);
@@ -96,15 +98,15 @@ namespace Deeangband
        void Field::UpdateSight(void)
        {
                int x, y;
-               this->sightPass.resize((this->width * 2 + 1) * (this->height * 2 + 1));
-               this->physicalPass.resize((this->width * 2 + 1) * (this->height * 2 + 1));
+               this->SightPass.resize((this->width * 2 + 1) * (this->height * 2 + 1));
+               this->PhysicalPass.resize((this->width * 2 + 1) * (this->height * 2 + 1));
 
                for(y = 1; y < this->height * 2 + 1; y += 2)
                {
                        for(x = 1; x < this->width * 2 + 1; x += 2)
                        {
-                               this->sightPass[y * this->width + x] = !this->GetSquare(x / 2, y / 2)->IsWall();
-                               this->physicalPass[y * this->width + x] = !this->GetSquare(x / 2, y / 2)->IsWall();
+                               this->SightPass[y * this->width + x] = !this->GetSquare(x / 2, y / 2)->IsWall();
+                               this->PhysicalPass[y * this->width + x] = !this->GetSquare(x / 2, y / 2)->IsWall();
                        }
                }
 
@@ -114,18 +116,18 @@ namespace Deeangband
                        {
                                if(!this->GetSquare(x / 2 - 1, y / 2 - 1) || !this->GetSquare(x / 2 - 1, y / 2) || !this->GetSquare(x / 2, y / 2 - 1) || !this->GetSquare(x / 2, y / 2))
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else if(this->GetSquare(x / 2 - 1, y / 2 - 1)->IsWall() || this->GetSquare(x / 2, y / 2 - 1)->IsWall() || this->GetSquare(x / 2 - 1, y / 2)->IsWall() || this->GetSquare(x / 2, y / 2 )->IsWall())
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else
                                {
-                                       this->sightPass[y * this->width + x] = true;
-                                       this->physicalPass[y * this->width + x] = true;
+                                       this->SightPass[y * this->width + x] = true;
+                                       this->PhysicalPass[y * this->width + x] = true;
                                }
                        }
                }
@@ -136,18 +138,18 @@ namespace Deeangband
                        {
                                if(!this->GetSquare(x / 2, y / 2 - 1) || !this->GetSquare(x / 2, y / 2))
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else if(this->GetSquare(x / 2, y / 2 - 1)->IsWall() || this->GetSquare(x / 2, y / 2)->IsWall())
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else
                                {
-                                       this->sightPass[y * this->width + x] = true;
-                                       this->physicalPass[y * this->width + x] = true;
+                                       this->SightPass[y * this->width + x] = true;
+                                       this->PhysicalPass[y * this->width + x] = true;
                                }
                        }
                }
@@ -158,18 +160,18 @@ namespace Deeangband
                        {
                                if(!this->GetSquare(x / 2 - 1, y / 2) || !this->GetSquare(x / 2, y / 2))
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else if(this->GetSquare(x / 2 - 1, y / 2)->IsWall() || this->GetSquare(x / 2, y / 2)->IsWall())
                                {
-                                       this->sightPass[y * this->width + x] = false;
-                                       this->physicalPass[y * this->width + x] = false;
+                                       this->SightPass[y * this->width + x] = false;
+                                       this->PhysicalPass[y * this->width + x] = false;
                                }
                                else
                                {
-                                       this->sightPass[y * this->width + x] = true;
-                                       this->physicalPass[y * this->width + x] = true;
+                                       this->SightPass[y * this->width + x] = true;
+                                       this->PhysicalPass[y * this->width + x] = true;
                                }
                        }
                }
index 6d5806a..8c96ace 100644 (file)
@@ -36,9 +36,6 @@ namespace Deeangband
                std::vector<boost::shared_ptr<Trap>> traps; //!<\83g\83\89\83b\83v\83C\83\93\83X\83^\83\93\83X\82Ì\94z\97ñ
                std::vector<boost::shared_ptr<Item>> items; //!<\83A\83C\83e\83\80\83C\83\93\83X\83^\83\93\83X\82Ì\94z\97ñ
 
-               std::vector<bool> sightPass; //!< \8el\8b÷\8e\8b\8ao\92Ê\89ß\83t\83\89\83O
-               std::vector<bool> physicalPass; //!< \8el\8b÷\95¨\97\9d\92Ê\89ß\83t\83\89\83O
-
                MAP_LENGTH width;  //!< \83t\83\8d\83A\82Ì\89¡\83T\83C\83Y
                MAP_LENGTH height; //!< \83t\83\8d\83A\82Ì\8fc\83T\83C\83Y
                bool generated; //!< \83t\83\8d\83A\90\90¬\8dÏ\82Ý
@@ -155,6 +152,9 @@ namespace Deeangband
                 */
                void Field::UpdateSight(void);
 
+               std::vector<bool> SightPass; //!< \8el\8b÷\8e\8b\8ao\92Ê\89ß\83t\83\89\83O
+               std::vector<bool> PhysicalPass; //!< \8el\8b÷\95¨\97\9d\92Ê\89ß\83t\83\89\83O
+
        };
 
 }
index 674b228..47a9356 100644 (file)
@@ -562,6 +562,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
        CREATURE_IT creatureIt;
        Creature *subJectCreaturePtr = subjectCreatureIt->second.get();
 
+
        int px, py;
        for(py = y; py < y + h; py++)
        {
@@ -569,6 +570,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
                {
                        if(px < fieldPtr->GetWidth() && py < fieldPtr->GetHeight())
                        {
+                               SDL_Rect checkRect = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 3, 30 + (py - y) * squareGraphicHeight - 3, 6, 6};
                                SDL_Rect blitRect = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth, 30 + (py - y) * squareGraphicHeight , squareGraphicWidth, squareGraphicHeight};
                                if(subJectCreaturePtr->GetLore()->GetFieldLore(0, px, py) > 0)
                                {
@@ -585,6 +587,11 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
                                        SDL_Rect fieldRect = {blitRect.x % 128, blitRect.y % 128, blitRect.x % 128 + squareGraphicWidth, blitRect.y % 128 + squareGraphicHeight};
                                        SDL_BlitSurface(unknownFieldSurface, &fieldRect, windowSurface, &blitRect); 
                                }
+
+                               if(fieldPtr->SightPass[(py * 2 + 1) * fieldPtr->GetWidth() + (px * 2 + 1)])
+                                       SDL_FillRect(windowSurface, &checkRect, SDL_MapRGBA(windowSurface->format, 255, 255, 255, 255));
+                               else
+                                       SDL_FillRect(windowSurface, &checkRect, SDL_MapRGBA(windowSurface->format, 255, 0, 0, 255));
                        }
                }
        }
@@ -601,6 +608,9 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
                        SDL_BlitSurface(creatureSurfaces[creatureIt->first], &symbolRect, windowSurface, &blitRect); 
                }
        }
+
+
+
 }
 
        void GameSurfaceSDL::FocusField(int x, int y)