Beispiel #1
0
void Engine::drawMap()
{

    for(int i = 0; i < m_CurrentMap->getDimensions().y; i++)
    {
        for(int n = 0; n < m_CurrentMap->getDimensions().x; n++)
        {
            MapTile *ttile = getMapTile( m_CurrentMap->getTile(n, i));

            if(posInViewport(n, i))
            {
                if( inFOV(m_Player->getPosition().x, m_Player->getPosition().y, n, i) )
                {
                    drawTileInViewport(n, i, ttile->getTileID(), ttile->getFGColor(), ttile->getBGColor());

                    if(!m_CurrentMap->tileExplored(n,i)) m_CurrentMap->setExplored(n, i, true);
                }
                else
                    if( m_CurrentMap->tileExplored(n, i) ) drawTileInViewport(n, i, ttile->getTileID(), SFC_WHITE, SFC_BLACK);

            }

        }
    }
}
Beispiel #2
0
void Map::draw() {
     for (int x = 0; x < MAP_WIDTH; x++) {
         for (int y = 0; y < MAP_HEIGHT; y++) {
             Tile *t = getMapTile(x,y);
             int drawX = cam.getMapDrawX(x);
             int drawY = cam.getMapDrawY(y);
             
             if (!t->drawMe()) {              
              continue;      
             }
             
             if (!t->isVisible()) {
                 if (t->alpha > 128) t->alpha -= FOG_FADE_SPEED;
                // if (t->alpha < 128) continue;                     
             }
             
            if (!inFOV(x, y, zFocus)) continue;

            // if (z != zFocus) continue;
             
             //if (z < zFocus) continue;
             
             if (t->isVisible())  t->alpha += FOG_FADE_SPEED;
           
               
//               if (t->alpha < 255) {
//                    boxRGBA(screen, drawX, drawY, 32, 32, 0, 0, 0, 255);
//               }
               boxRGBA(screen, drawX, drawY, drawX+31, drawY+31, 0, 0, 0, 255); 
               drawtile(0, t->getGridX(), t->getGridY(), drawX, drawY, 0, false, t->alpha);                      
         }    
     }
}
Beispiel #3
0
void Engine::drawItems()
{
    for(int i = 0; i < int(m_CurrentMap->getMapItems()->size()); i++)
    {
        Item *titem = (*m_CurrentMap->getMapItems())[i];

        sf::Vector2i tpos = titem->getPosition();

        if(posInViewport(tpos))
        if( inFOV(m_Player->getPosition().x, m_Player->getPosition().y, tpos.x, tpos.y) ) drawTileInViewport(titem->getPosition().x, titem->getPosition().y, titem->getTileID(), titem->getFGColor(),
                 titem->getBGColor());
    }
}
Beispiel #4
0
void Engine::drawMonsters()
{
    for(int i = 0; i < int(m_CurrentMap->getMapMonsters()->size()); i++)
    {
        Monster *tmonster = (*m_CurrentMap->getMapMonsters())[i];

        sf::Vector2i tpos = tmonster->getPosition();

        if(posInViewport(tpos))
        if( inFOV(m_Player->getPosition().x, m_Player->getPosition().y, tpos.x, tpos.y) )
            drawTileInViewport(tmonster->getPosition().x, tmonster->getPosition().y, tmonster->getTileID(),
                    tmonster->getFGColor(), tmonster->getBGColor());
    }
}
Beispiel #5
0
bool FOVMap::inFOV(Point p) const { return inFOV(p.x, p.y); }