void Map::draw(sf::RenderTarget & target, sf::RenderStates states) const { if (_hasChanged) { _bools = getBoolMap(); _mapOutline = getOutline(); _hasChanged = false; } target.draw(_mapOutline, states); if (_flashActif) { if (_clockFlash.getElapsedTime().asMilliseconds() < _dureeFlash) target.draw(_texteFlash); else if (_clockFlash.getElapsedTime().asMilliseconds() > _frequenceFlash) _clockFlash.restart(); } }
void Map::lireMap(std::istream & map) { if (!_map.empty()) _map.clear(); auto linePos = readNumFromStream<float, false>(map, 0, "(, )\n", '.'); if (linePos.size() % 4) throw std::invalid_argument("Le format de la map est invalide!"); for (int i = 0; i < linePos.size(); i += 4) { ajouterLigne(Ligne(linePos[i], linePos[i + 1], linePos[i + 2], linePos[i + 3])); } _bools = getBoolMap(); _mapOutline = getOutline(); }
void task1p5(std::ifstream & inputfile, std::ofstream & outputfile) { std::string line; getline (inputfile,line); int linesize = line.size(); std::vector<bool*> map; getBoolRow(map,line,linesize); getBoolMap(inputfile,map,linesize); int count ; int mapsize = map.size(); for(int i =0 ; i< mapsize ; i++) { for (int j =0 ; j < linesize ; j++ ) { if (sink(map,i,j,mapsize,linesize)) { count++; } } } std::cout << count; }