OSDN Git Service

Implement creature drawing on floor.
authorDeskull <desull@users.sourceforge.jp>
Sat, 31 May 2014 11:41:44 +0000 (20:41 +0900)
committerDeskull <desull@users.sourceforge.jp>
Sat, 31 May 2014 11:41:44 +0000 (20:41 +0900)
Deeangband/Creature.cpp
Deeangband/Creature.h
Deeangband/GameSurfaceSDL.cpp
Deeangband/GameWorld.cpp
Deeangband/GameWorld.h

index 252632f..b23b493 100644 (file)
@@ -281,6 +281,11 @@ namespace Deeangband
                return this->savings.GetVolition();
        }
 
+       Coordinates *Creature::GetPosition(void)
+       {
+               return &(this->position);
+       }
+
        SOUL Creature::GetCurrentSoul(void)
        {
                return this->currentSoul;
@@ -401,6 +406,16 @@ namespace Deeangband
                return this->campID;
        }
 
+       SYMBOL Creature::GetSymbol(void)
+       {
+               return this->symbol;
+       }
+
+       Color Creature::GetSymbolColor(void)
+       {
+               return this->symbolColor;
+       }
+
        bool Creature::Walk(DIRECTION dir)
        {
                this->position += Direction::DirectionVector[dir];
index 78b9205..914496e 100644 (file)
@@ -92,7 +92,7 @@ namespace Deeangband
                std::vector<Item> itemList;  //!< \8f\8a\8e\9d\83A\83C\83e\83\80\83\8a\83X\83g
                std::map<TAG, SKILL_EXP> skillExpList; //!< \83X\83L\83\8b\8co\8c±\92l\83\8a\83X\83g
 
-               char symbol;       //!< \83V\83\93\83{\83\8b\83L\83\83\83\89
+               SYMBOL symbol;       //!< \83V\83\93\83{\83\8b\83L\83\83\83\89
                Color symbolColor; //!< \83V\83\93\83{\83\8b\83J\83\89\81[
                ID tileID;         //!< \83^\83C\83\8bID
 
@@ -322,7 +322,7 @@ namespace Deeangband
                * @brief \83N\83\8a\81[\83`\83\83\81[\82Ì\8c»\8dÝ\88Ê\92u\82ð\95Ô\82·
                * @return \83N\83\8a\81[\83`\83\83\81[\8c»\8dÝ\88Ê\92u\82ð\8e¦\82·Coordinates
                */
-               Coordinates *Creature::getCorrdinates(void);
+               Coordinates *Creature::GetPosition(void);
 
                /*!
                * @brief \83N\83\8a\81[\83`\83\83\81[\82Ì\8f\8a\8e\9d\95i\83\8a\83X\83g\82ð\95Ô\82·
@@ -459,6 +459,18 @@ namespace Deeangband
                ID Creature::GetCampID(void);
 
                /*!
+               * @brief \83N\83\8a\81[\83`\83\83\81[\82Ì\83V\83\93\83{\83\8b\82ð\95Ô\82·
+               * @return \83N\83\8a\81[\83`\83\83\81[\82Ì\83V\83\93\83{\83\8b
+               */
+               SYMBOL Creature::GetSymbol(void);
+
+               /*!
+               * @brief \83N\83\8a\81[\83`\83\83\81[\82Ì\83V\83\93\83{\83\8b\83J\83\89\81[\82ð\95Ô\82·
+               * @return \83N\83\8a\81[\83`\83\83\81[\82Ì\83V\83\93\83{\83\8b\83J\83\89\81[
+               */
+               Color Creature::GetSymbolColor(void);
+
+               /*!
                * @brief XML\83V\83\8a\83A\83\89\83C\83Y\82É\82æ\82é\83Q\81[\83\80\83f\81[\83^\95Û\91\8f\88\97\9d
                * @return \82È\82µ
                */
index 7f91e46..506547a 100644 (file)
@@ -555,8 +555,17 @@ namespace Deeangband
                        }
                }
 
-               for(creatureIt = gameWorld->GetCreatureList().begin(); creatureIt != gameWorld->GetCreatureList().end(); creatureIt++)
+               for(creatureIt = gameWorld->GetCreatureList()->begin(); creatureIt != gameWorld->GetCreatureList()->end(); creatureIt++)
                {
+                       Color symColor = creatureIt->second->GetSymbolColor();
+                       SDL_Color sdlSymCol = {(Uint8)symColor.GetRed(), (Uint8)symColor.GetGreen(), (Uint8)symColor.GetBlue(), (Uint8)symColor.GetAlpha()};
+                       sprintf_s(symBuf, 5, "%s", creatureIt->second->GetSymbol().c_str()); 
+                       SDL_Rect blitRect = {240 + creatureIt->second->GetPosition()->GetX() * 24, creatureIt->second->GetPosition()->GetY() * 24 , 24, 24};
+                       symbolSurface = TTF_RenderUTF8_Blended(font, toUTF8(symBuf).c_str(), sdlSymCol);
+                       blitRect.x += (24 - symbolSurface->w) / 2;
+                       blitRect.y += (24 - symbolSurface->h) / 2;
+                       SDL_BlitSurface(symbolSurface, &symbolRect, windowSurface, &blitRect); 
+                       SDL_FreeSurface(symbolSurface);
            }
        }
 
index ea9ef8b..7ff5574 100644 (file)
@@ -442,9 +442,9 @@ namespace Deeangband
                return &(*creatureList[id]);
        }
 
-       std::map<ID, boost::shared_ptr<Creature>> GameWorld::GetCreatureList(void)
+       std::map<ID, boost::shared_ptr<Creature>> *GameWorld::GetCreatureList(void)
        {
-               return this->creatureList;
+               return &(this->creatureList);
        }
 
        Quest *GameWorld::GetQuest(TAG tag)
index 56999cc..dd8e739 100644 (file)
@@ -374,7 +374,7 @@ namespace Deeangband
                * @brief GameWorld\92\86\82É\91\8dÝ\82·\82é\83N\83\8a\81[\83`\83\83\81[\82ð\95Ô\82·
                * @return \83N\83\8a\81[\83`\83\83\81[\82Ì\83\8a\83X\83g
                */
-               std::map<ID, boost::shared_ptr<Creature>> GameWorld::GetCreatureList(void);
+               std::map<ID, boost::shared_ptr<Creature>> *GameWorld::GetCreatureList(void);
 
                /*!
                * @brief GameWorld\92\86\82É\91\8dÝ\82·\82é\83N\83G\83X\83g\82ð\95Ô\82·