virtual Actor * create ( ID id ) { Q_UNUSED( id ); Q_ASSERT( id == IdKind ); /* create new instance that gets inserted in the world */ Actor * ret = new Actor( world() ); /* set a default dan */ setDNA( ret ); return ret; }
void Vehicle::load(QString fileName) { QVector<double> dna; QFile *file = new QFile(fileName); if (! file -> open(QIODevice::ReadOnly | QIODevice::Text)) { // Error while trying to read file } else { // Everything is OK QTextStream in(file); in >> x; in >> y; in >> pointsNum; int dna_size; in >> dna_size; dna.resize(dna_size); in >> maxWheelsNum; in >> wheelsNum; in >> springSegmentsNum; in >> springWidth; in >> springLength; in >> wheelRemoveChance; in >> wheelAddChance; in >> vectorLength; in >> wheelRadius; for(int i = 0; i < dna.size(); ++i) { in >> dna[i]; } } setDNA(dna); file -> close(); lastUpdateTime = QTime::currentTime(); }