int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initSPI(); LCDinit(); LCDclear(); unsigned char player = initPlayer(); init_timer(); init_buttons(); __enable_interrupt(); printPlayer(player); while(1) { player = movementCheck(player); if(LOSE == 1){ LCDclear(); print("GAME"); secondLine(); print("OVER"); firstLine(); GAMEOVER = 1; waitForP1ButtonRelease(BIT1|BIT2|BIT3|BIT4); debounce(); } if(didPlayerWin(player)){ LCDclear(); print("YOU"); secondLine(); print("WON"); firstLine(); GAMEOVER = 1; waitForP1ButtonRelease(BIT1|BIT2|BIT3|BIT4); debounce(); } if(GAMEOVER){ char buttonsToPoll[4] = {BIT1, BIT2, BIT3, BIT4}; while(!pollP1Buttons(buttonsToPoll, 4)){ //poll until something is pressed } TAR = 0; LOSE = 0; TIMER = 0; GAMEOVER = 0; LCDclear(); player = initPlayer(); printPlayer(player); } } return 0; }
void messageScroll(char * string1, char * string2){ char * start1 = string1; char * current1 = string1; char * start2 = string2; char * current2 = string2; while(1){ firstLine(); current1 = scroll_help(start1, current1); secondLine(); current2 = scroll_help(start2, current2); _delay_cycles(10000); //add test comment } }
void MpcImportWindow::updateTexts() { QString linkText("<a href=\"http://www.minorplanetcenter.net/iau/MPEph/MPEph.html\">Minor Planet & Comet Ephemeris Service</a>"); // TRANSLATORS: A link showing the text "Minor Planet & Comet Ephemeris Service" is inserted. QString queryString(q_("Query the MPC's %1:")); ui->labelQueryLink->setText(QString(queryString).arg(linkText)); QString firstLine(q_("Only one result will be returned if the query is successful.")); QString secondLine(q_("Both comets and asteroids can be identified with their number, name (in English) or provisional designation.")); QString cPrefix("<b>C/</b>"); QString pPrefix("<b>P/</b>"); QString cometQuery("<tt>C/Halley</tt>"); QString cometName("1P/Halley"); QString asteroidQuery("<tt>Halley</tt>"); QString asteroidName("(2688) Halley"); QString nameWarning(q_("Comet <i>names</i> need to be prefixed with %1 or %2. If more than one comet matches a name, only the first result will be returned. For example, searching for \"%3\" will return %4, Halley's Comet, but a search for \"%5\" will return the asteroid %6.")); QString thirdLine = QString(nameWarning).arg(cPrefix, pPrefix, cometQuery, cometName, asteroidQuery, asteroidName); ui->labelQueryInstructions->setText(QString("%1<br/>%2<br/>%3").arg(firstLine, secondLine, thirdLine)); }
QSize ItemDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) return QSize(); QFont normalfont = option.font; QFont boldfont = normalfont; boldfont.setBold(true); // Extract the items we want to measure QString firstRow = firstLine(index); QString secondRow = secondLine(index); // Compute the height QFontMetrics fm1(boldfont); QFontMetrics fm2(normalfont); int height = fm1.lineSpacing() + fm2.lineSpacing(); height = qMax(height, option.decorationSize.height()); // Compute the text width int width = fm1.width(firstRow); width = qMax(width, fm2.width(secondRow)); // Add decoration width + margin width += option.decorationSize.width()+decorationMargin; return QSize(width, height+16); }
QList<Data::SurfaceType> QChemPlot::parseForProperties(TextStream& textStream) { QString firstLine; while (!textStream.atEnd() && !firstLine.contains("Grid point positions")) { firstLine = textStream.nextLine(); } bool esp(firstLine.contains("esp values")); bool rho(firstLine.contains("electronic density values")); textStream.skipLine(); QString secondLine(textStream.nextLine()); QList<Data::SurfaceType> surfaceTypes; unsigned count(1); while (!secondLine.isEmpty()) { QString field(secondLine.left(13)); secondLine.remove(0, 13); field = field.trimmed(); if (field == "X" || field == "Y" || field == "Z") { // ignore }else if(field.contains("ALPHA")) { surfaceTypes.append( Data::SurfaceType(Data::SurfaceType::AlphaOrbital, count++)); }else if(field.contains("BETA")) { surfaceTypes.append( Data::SurfaceType(Data::SurfaceType::BetaOrbital, count++)); }else if (esp) { surfaceTypes.append( Data::SurfaceType(Data::SurfaceType::ElectrostaticPotential, count++)); }else if (rho) { surfaceTypes.append( Data::SurfaceType(Data::SurfaceType::TotalDensity, count++)); } } return surfaceTypes; }
bool TinkerFile::ID_Tinker(CpptrajFile& fileIn) { // NOTE: ASSUME FILE SET UP FOR READ if (fileIn.OpenFile()) return false; ArgList firstLine( fileIn.NextLine() ); ArgList secondLine( fileIn.NextLine() ); ArgList thirdLine( fileIn.NextLine() ); fileIn.CloseFile(); // First line should have <natom> <title> only int natom = 0; std::string title; if ( SetNatomAndTitle(firstLine, natom, title) != 0 ) return false; //mprinterr("Past SetNatomAndTitle\n"); if (secondLine.Nargs() == 6) { bool isBoxLine = true; for (int i = 0; i < 6; i++) { // It is a box line if all 6 tokens are doubles try { convertToDouble( secondLine.GetStringNext() ); } catch (std::runtime_error e) { if (i != 1) return false; // We found a non-double on the second character -- it could be an atom // name. Check that the rest of the line matches an atom record isBoxLine = false; break; } } // If we are here it is not a box line, so make sure if (!isBoxLine) { return IsAtomLine(secondLine); } else { // our second line WAS a box, now check the 3rd line return IsAtomLine(thirdLine); } } // There is no box, check that the second line is an atom line return IsAtomLine(secondLine); }