CIF::CIF(istream &is, const bool interpret,const bool verbose) { string s; (*fpObjCrystInformUser)("CIF: Opening CIF"); Chronometer chrono; chrono.start(); //Copy to an iostream so that we can put back characters if necessary stringstream in; char c; while(is.get(c))in.put(c); const float t0read=chrono.seconds(); s=(boost::format("CIF: Parsing CIF (reading dt=%5.3fs)")%t0read).str(); (*fpObjCrystInformUser)(s); this->Parse(in); const float t1parse=chrono.seconds(); s=(boost::format("CIF: Finished Parsing, Extracting...(parsing dt=%5.3fs)") % (t1parse-t0read)).str(); (*fpObjCrystInformUser)(s); // Extract structure from blocks if(interpret) for(map<string,CIFData>::iterator posd=mvData.begin();posd!=mvData.end();++posd) posd->second.ExtractAll(verbose); const float t2interpret=chrono.seconds(); s=(boost::format("CIF: Finished Import...(interpret dt=%5.3fs, total CIF import=%5.3fs)")%(t2interpret-t1parse)%t2interpret).str(); (*fpObjCrystInformUser)(s); }
void perform_logic() { const float time_passed = m_chrono.seconds(); const float time_step = time_passed - m_time_passed; m_time_passed = time_passed; // without a multiplier, this will rotate a full turn after ~6.28s // this rotates clockwise of c-clockwise depending on m_turn_???? //m_tank.turn_left((m_turn_left - m_turn_right) * time_step); m_tank.move_lr((m_turn_left - m_turn_right) * time_step * 100.0f); // without the '100.0f', it would move at ~1px/s m_tank.move_ud((m_forward - m_backward) * time_step * 100.0f); if(m_fire) { m_fire = false; m_bullets.push_back(m_tank.fire()); } // move bullets for(list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end(); ++it) (*it)->move_ud(time_step * 200.0f); // remove off screen bullets for perfrmance boost for(list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end();) { const Point2f &p = (*it)->get_position(); if(p.x < -10.0f || p.x > 10.0f + get_Window().get_width() || p.y < -10.0f || p.y > 10.0f + get_Window().get_height()) { delete *it; it = m_bullets.erase(it); } else ++it; } }