Example #1
0
Oro::Oro(int x,int y) {
	TheTextureManager::Instance()->load("assets/resources.png","oro", TheGame::Instance()->getRenderer());


	float possx = (x+1) * TheGame::TILE_WIDTH/2;
	float possy = (y+1) * TheGame::TILE_HEIGHT;
	Vector2D* vec = new Vector2D(0,0);
	vec->setX(possx);
	vec->setY(possy);
	vec->toIsometric();
	GameObject::load( vec->getX(), vec->getY(),  width, height, destWidth, destHeight, numFrames, "oro",false);
	m_mapPosition2.setX(x);
	m_mapPosition2.setY(y);
	GameObject::setFrame(frame);
	GameObject::setOffset(offsetX,offsetY);
	GameObject::setRow(row);
	GameObject::setAlto(1);
	GameObject::setAncho(1);

	this->recurso = true;
	this->name = "Oro";
	this->cantidad = 1;

	delete vec;
}
Example #2
0
void Pantalla::draw(SDL_Renderer* m_pRenderer, Map* m_pMap ,vector<GameObject*> entidades) {

    SDL_Rect sector;

    //////////////////////////////////////////////////////////////////
    sector = sectores.at("barra");
    TheTextureManager::Instance()->drawArea("barra",sector,m_pRenderer);

    SDL_Color textColor = { 255, 255, 255 };

    map<string, int>myMap = TheGame::Instance()->m_pBarra->getMapRecursos();

    int acum =0;
    for (const auto& recurso : myMap) {
        ostringstream convert;   // stream used for the conversion
        convert << (recurso.second);
        string text = recurso.first+ ": " + convert.str();
        sector.x=5+acum;
        sector.y=5;
        acum+= 100;

        TheTextureManager::Instance()->drawText(text,textColor,sector,m_pRenderer);

    }

    //////////////////////////////////////////////////////////////////
    sector = sectores.at("barra_bajo");
    TheTextureManager::Instance()->drawArea("barra_bajo",sector,m_pRenderer);

    textColor = { 0, 0, 0 };
    for (uint i=0; i<entidades.size(); i++) {
        if (entidades[i]->m_isClicked) {

            string text = "NOMBRE: " + entidades[i]->name;
            sector.x = 20;
            sector.y= 30;

            TheTextureManager::Instance()->drawText(text,textColor,sector,m_pRenderer);

            text = "DESCRIPCION: " + entidades[i]->descripcion;
            sector.x = 20;
            sector.y += 30;

            TheTextureManager::Instance()->drawText(text,textColor,sector,m_pRenderer);

        }
    }
    //////////////////////////////////////////////////////////////////
    sector = sectores.at("minimapa");
    //TheTextureManager::Instance()->drawArea("minimapa",sector,m_pRenderer);

    SDL_RenderSetViewport( m_pRenderer, &sector );
    for(int i = 0 ; i <  m_pMap->getMapSize().getX(); i++) {
        for(int j = 0 ; j < m_pMap->getMapSize().getY() ; j++) {
            if (m_pMap->getVisionMapValue(i,j) == 1 || m_pMap->getVisionMapValue(i,j) == 2) {
                Vector2D* vector = new Vector2D(0,0);
                vector->setX(i);
                vector->setY(j);
                vector->toIsometric();


                int tileValue1 = TheGame::Instance()->m_pMap->getValue(i,j);
                if (tileValue1 == 3 ) {
                    TheTextureManager::Instance()->drawFrame("puntoRojo",vector->getX()+95,vector->getY()-5,180,150,50,50,1,0,m_pRenderer);

                }
                else if (tileValue1 == 0) {
                    TheTextureManager::Instance()->drawFrame("puntoAmarillo",vector->getX()+95,vector->getY()-5,180,150,50,50,1,0,m_pRenderer);
                }
                else
                    TheTextureManager::Instance()->drawFrame("puntoVerde",vector->getX()+100,vector->getY(),180,150,50,50,1,0,m_pRenderer);


                delete vector;

            }
        }
    }


    //////////////////////////////////////////////////////////////////
    sector = sectores.at("mapa");

    SDL_RenderSetViewport( m_pRenderer, &sector );

    m_pMap->draw();

    //primero dibuja entidades, luego el personaje (siempre aparece por arriba de las cosas
    for (uint i=0; i<entidades.size(); i++) {
        if (entidades[i]->m_isClicked) {
            entidades[i]->drawSelected();

        }

        //SDL_RenderSetViewport( m_pRenderer, &sector );
        if (entidades[i] && (entidades[i]->m_atSight || entidades[i]->m_wasSeen))
            entidades[i]->draw();

    }

    SDL_RenderPresent(m_pRenderer);

    //////////////////////////////////////////////////////////////////


}