void Gui::renderMouseLook() { auto engine = Engine::getSingleton(); auto map = engine->getMap(); auto mouse_pos = Vec2i(engine->getMouse().cx, engine->getMouse().cy); if (!map->isInFov(mouse_pos)) { // if mouse is out of fov, nothing to render return; } std::string buf; bool first=true; auto actors = engine->getActors(); for (unsigned int i = 0; i < actors.size(); i++) { auto actor = actors[i]; // find actors under the mouse cursor if (actor->getPosition() == mouse_pos) { if(!first) buf+=", "; else first=false; buf += actor->getOwner()->getName(); } } // display the list of actors under the mouse cursor con->setDefaultForeground(TCODColor::lightGrey); con->print(1,0,buf.c_str()); }
void MeshComponent::onDraw(render::RenderQueue *ops) { if (!m_meshData || !m_meshData->isInitialized()) return; if (!m_visible || !isInFov()) return; m_meshData->populateRenderQueue(ops, getHolder()->transform()->getTransformation()); }
// // Retourne la liste des items fixes dans le fov du joueur // TCODList<EntityFixedItem*> Level::getFixedItemsInFov() { TCODList<EntityFixedItem*> result; for (EntityFixedItem* itemFixed: fixedItems_) { if (isInFov(itemFixed->x, itemFixed->y)) result.push(itemFixed); } return result; }
void Map::computeFov() { map->computeFov(engine.player->x, engine.player->y, engine.fovRadius); for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) if (isInFov(x, y)) { unsigned int oldScent = getScent(x, y); int dx = x - engine.player->x; int dy = y - engine.player->y; long distance = (int)sqrt(1.0 * dx * dx + dy * dy); unsigned int newScent = currentScentValue - distance; if (newScent > oldScent) tiles[x + y * width].scent = newScent; } }
void tMap::render() const { for (int x = 0; x < m_Width; x++) { for (int y = 0; y < m_Height; y++) { if ( isInFov(x,y) ) { TCODConsole::root->setCharBackground(x, y, isWall(x,y) ? m_cLightWall :m_cLightGround ); } else if ( isExplored(x,y) ) { TCODConsole::root->setCharBackground(x, y, isWall(x,y) ? m_cDarkWallColor : m_cDarkGroundColor ); } } } }
void Map::render() const { /* static const TCODColor darkWall(200, 0, 150); static const TCODColor darkGround(50, 50, 50); static const TCODColor lightWall(255,0, 225); static const TCODColor lightGround(75,75,75);*/ static const TCODColor darkWall(125, 0, 110); static const TCODColor darkGround(25, 25, 25); static const TCODColor lightWall(250, 0, 220); static const TCODColor lightGround(50, 50, 50); for (int x=0; x < width; x++) { for (int y=0; y < height; y++) { // VISIBLE SMELL /* int scent = SCENT_THRESHOLD - (currentScentValue - getScent(x, y)); scent = CLAMP(0, 10, scent); float sc = scent * 0.1f; if (isInFov(x, y)) TCODConsole::root->setCharBackground(x, y, isWall(x, y) ? lightWall : TCODColor::lightGrey * sc); else if (isExplored(x, y)) TCODConsole::root->setCharBackground(x, y, isWall(x, y) ? darkWall : TCODColor::lightGrey * sc); else if (!isWall(x, y)) TCODConsole::root->setCharBackground(x, y, TCODColor::white * sc);*/ if (isInFov(x,y)) { TCODConsole::root->setCharBackground(x, y, isWall(x,y) ? lightWall : lightGround); } else if ( isExplored(x,y) ) { TCODConsole::root->setCharBackground(x, y, isWall(x,y) ? darkWall : darkGround ); } } } }
void Map::render() const { static const TCODColor darkWall(0,0,100); static const TCODColor darkGround(50,50,150); static const TCODColor lightWall(130,110,50); static const TCODColor lightGround(200,180,50); for (int x=0; x < width; x++) { for (int y=0; y < height; y++) { if ( isInFov(x,y) ) { TCODConsole::root->setCharBackground(x,y, isWall(x,y) ? lightWall :lightGround ); } else if ( isExplored(x,y) ) { TCODConsole::root->setCharBackground(x,y, isWall(x,y) ? darkWall : darkGround ); } } } }
// // Dessin du level // void Level::render() { EntityPlayer& player = Engine::getInstance()->getPlayer(); float squaredTorchRadius = player.fov * player.fov; TCODColor lightColor; //dessin du fond de carte for (int x = 0; x < width_; x++) { for (int y = 0; y < height_; y++) { if (!isInFov(x, y)) continue; // // Données // Tile currentTile = tiles_[x + y * width_]; // // Caractères // char baseChar = isWall(x, y) ? CH_WALL : CH_FLOOR; // // Couleurs // //couleur hors de portée TCODColor baseColor = isWall(x, y) ? C_DARKWALL : ((currentTile.isFall) ? C_DARKFALL : C_DARKGROUND); if (currentTile.mutationAffect > 0) baseColor = baseColor * TCODColor::green; //couleur lorsque vue lightColor = isWall(x, y) ? C_LIGHTWALL : ( (currentTile.isFall) ? C_LIGHTFALL : C_LIGHTGROUND); //distance entre la case et la source de lumière sans appliquer la racine par optimisation float distance = (float)((x - player.x + player.lightX) * (x - player.x + player.lightX) + (y - player.y + player.lightY) * (y - player.y + player.lightY)); //la distance est inférieur au rayon de la torche //par optimisation, on n'applique pas la racine à la distance calculée //et on la compare au rayon de la torche au carré if (distance < squaredTorchRadius) { //détermination du coef d'interpolation pour la couleur //coef = 1.0 au centre du rayonnement //coef = 0.0 au rayon du rayonnement // // float coefInterColor = (squaredTorchRadius - distance) / squaredTorchRadius + player.lightIntensity; //garde le coef d'interpolation pour la couleur //entre 2 valeurs min / max //si coefInterColor < 0.0f => 0.0f //si coefInterColor > 1.0f => 1.0f //si coefInterColor compris dans l'interval on utilise sa valeur coefInterColor = CLAMP(0.0f, 1.0f, coefInterColor); //interpolation de la couleur entre baseColor / lightColor //avec le coef déterminé par la distance du joueur baseColor = TCODColor::lerp(baseColor, lightColor, coefInterColor); lightColor = baseColor; TCODConsole::root->setCharBackground(x, y, lightColor); TCODConsole::root->setCharForeground(x, y, TCODColor::lighterGrey); //affichage d'un caractère ou pas ?! //TCODConsole::root->setChar(x, y, baseChar); } } } //dessin des PNJ for (EntityPnj *pnj: pnjs_) { if (isInFov(pnj->x, pnj->y) || Engine::getInstance()->IsRevealMode) pnj->render(); } //dessin des items for (EntityItem *item: items_) { if (isInFov(item->x, item->y) || Engine::getInstance()->IsRevealMode) item->render(); } //dessin des items fixes for (EntityFixedItem *itemFixed: fixedItems_) { if (isInFov(itemFixed->x, itemFixed->y) || Engine::getInstance()->IsRevealMode) itemFixed->render(); } }