OSDN Git Service

Creature クラスに sightRange メンバ変数を追加。 / Add sightRange to Creature class.
authorDeskull <desull@users.sourceforge.jp>
Mon, 12 Jan 2015 03:47:08 +0000 (12:47 +0900)
committerDeskull <desull@users.sourceforge.jp>
Mon, 12 Jan 2015 03:47:08 +0000 (12:47 +0900)
Deeangband/Creature.cpp
Deeangband/Creature.h
Deeangband/Deeangband.h
Deeangband/GameSurfaceSDL.cpp

index 1cee585..44dbc0d 100644 (file)
@@ -92,8 +92,8 @@ namespace Deeangband
                : GameInstance(), HaveSymbol(), HaveHp(), HaveGameTime(), HavePosition(fieldIt, x, y), HaveInventory(), HaveSize()
        {
                WipeData();
-               sightList.resize((12*2+1)*(12*2+1));
-               fieldIt->second->GetSight(sightList, 12, x, y);
+               sightList.resize((this->sightRange * 2 + 1)*(this->sightRange * 2 + 1));
+               fieldIt->second->GetSight(sightList, this->sightRange, x, y);
                SetSpeciesData(speciesIt->second.get());
        }
 
@@ -143,6 +143,8 @@ namespace Deeangband
                maxStatus.Set(8, 8, 8, 8, 8, 8);
                maxMaxStatus.Set(20, 20, 20, 20, 20, 20);
 
+               sightRange = BASE_SIGHT_RANGE;
+
                this->calcHPTable();
                this->currentHp = this->maxHp = this->GetNorMaxHP();
 
@@ -430,12 +432,12 @@ namespace Deeangband
                cx = this->position.GetX();
                cy = this->position.GetY();
 
-               fieldPtr->GetSight(this->sightList, 12, cx, cy);
-               for(y = -12; y < 12; y++)
+               fieldPtr->GetSight(this->sightList, this->sightRange, cx, cy);
+               for(y = -this->sightRange; y < this->sightRange; y++)
                {
-                       for(x = -12; x < 12; x++)
+                       for(x = -this->sightRange; x < this->sightRange; x++)
                        {
-                               if(this->sightList[(y + 12) * 25 + x + 12]) this->GetLore()->PutFieldLore(0, cx + x, cy + y); 
+                               if(this->sightList[(y + this->sightRange) * (this->sightRange * 2 + 1) + x + this->sightRange]) this->GetLore()->PutFieldLore(0, cx + x, cy + y); 
                        }
                }
        }
@@ -452,7 +454,7 @@ namespace Deeangband
        {
                MAP_LENGTH rx = x - this->position.GetX();
                MAP_LENGTH ry = y - this->position.GetY();
-               if(rx > 12 || ry > 12 || rx < -12 || ry < -12)
+               if(rx > this->sightRange || ry > this->sightRange || rx < -this->sightRange || ry < -this->sightRange)
                {
                        return false;
                }
@@ -462,7 +464,7 @@ namespace Deeangband
                        return false;
                }
 
-               return this->sightList[(ry + 12) * 25 + rx + 12];
+               return this->sightList[(ry + this->sightRange) * (this->sightRange * 2 + 1) + rx + this->sightRange];
        }
 
 }
\ No newline at end of file
index c446b19..d815bf1 100644 (file)
@@ -108,6 +108,8 @@ namespace Deeangband
 
                HP hpTable[CREATURE_MAX_LEVEL]; //!< \83q\83b\83g\83_\83C\83X\82É\8aî\82Ã\82«\90\90¬\82³\82ê\82½\83\8c\83x\83\8b\96\88\82Ì\8aî\96{HP
 
+               MAP_LENGTH sightRange; //!< \95W\8f\80\8e\8b\8aE\94Í\88Í
+
                Lore lore; //!< \8bL\89¯\8fî\95ñ
                std::map<int, std::map<int, bool>> sight; //!<\8e\8b\8aE\8fî\95ñ
                std::vector<bool> sightList; //!<\8e\8b\8aE\8fî\95ñ
index e758cb9..a0e9d28 100644 (file)
@@ -24,6 +24,8 @@ namespace Deeangband
 
 #define TAG_VARIABLE "VARIABLE" //!< \97v\91f\89Â\95Ï\83^\83O
 
+#define BASE_SIGHT_RANGE 12; //!< \95W\8f\80\8e\8b\8aE\94Í\88Í
+
 /*!
  * \83Q\81[\83\80\83R\83}\83\93\83h\92è\8b`
  */
index 29ac1e5..6370ffe 100644 (file)
@@ -631,7 +631,7 @@ void GameSurfaceSDL::drawField(const CREATURE_IT &subjectCreatureIt, GameWorld *
                                SDL_Rect checkRect4 = {GameSurfaceSDL::sideBarWidth + (px - x) * squareGraphicWidth - 1, 30 + (py - y) * squareGraphicHeight - 6 + 12, 2, 12};
                                */
 
-                               if(subJectCreaturePtr->GetLore()->GetFieldLore(0, px, py) > 0)
+                               if(subJectCreaturePtr->InSight(px, py))
                                {
                                        TAG tag = fieldPtr->GetSquare(px, py)->GetFloorTag();
                                        SDL_RenderCopy(renderer, floorTextures[tag], &symbolRect, &blitRect);