void super_init() { int i; for (i=0;i<4;i++) { addr[i]=til311New(); til311SetPosition(&addr[i],300+28*i,140); til311Paint(&addr[i],display,window); } for (i=0;i<2;i++) { data[i]=til311New(); til311SetPosition(&data[i],430+28*i,140); til311Paint(&data[i],display,window); } q=redLedNew(); redLedSetPosition(&q,280,210); redLedSetState(&q,0); redLedPaint(&q,display,window); for (i=0; i<8; i++) { superLeds[i] = redLedNew(); redLedSetPosition(&superLeds[i],280,233+15*i); redLedSetState(&superLeds[i],0); redLedPaint(&superLeds[i],display,window); } power=toggleNew(); toggleSetPosition(&power,460,40); toggleSetState(&power,1); togglePaint(&power,display,window); mp=toggleNew(); toggleSetPosition(&mp,0,0); toggleSetState(&mp,0); }
Kpacman::Kpacman(QWidget *parent, const char *name, WFlags fl) : KTMainWindow(parent, name,fl) { schemesPopup = new QList<QPopupMenu>; schemesPopup->setAutoDelete(TRUE); menu(); m_view = new QWidget( this, "m_view" ); m_view->setBackgroundColor( black ); m_layout = new QGridLayout( m_view ); m_layout->setMargin( 7 ); view = new KpacmanWidget( this, QString(name)+"widget"); m_layout->addWidget( view, 0, 0 ); setCaption( tr("KPacman") ); view->referee->setFocus(); connect(view->referee, SIGNAL(setScore(int,int)), view->score, SLOT(setScore(int,int))); connect(view->referee, SIGNAL(setPoints(int)), view->score, SLOT(set(int))); connect(view->referee, SIGNAL(setLifes(int)), view->status, SLOT(setLifes(int))); connect(view->referee, SIGNAL(setLevel(int)), view->status, SLOT(setLevel(int))); connect(view->referee, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); APP_CONFIG_BEGIN( cfg ); focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); APP_CONFIG_END( cfg ); toggleFocusOutPause(); toggleFocusInContinue(); toggleHideMouseCursor(); setCentralWidget( m_view ); }
extern int main(void) { pin * pRED = pinNew(0, pinOut, pinActiveHigh); pin * pYELLOW = pinNew(2, pinOut, pinActiveHigh); pin * pGREEN = pinNew(3, pinOut, pinActiveHigh); toggleNew(pRED, 2000, 2000); toggleNew(pYELLOW, 100, 100); toggleNew(pGREEN, 50, 1500); while (true) { oosmos_RunStateMachines(); oosmos_DelayMS(50); } }
void Score::setScore(int level, int player) { lastScore = -1; if (player < 0 || player >= maxPlayer || level == 0) { if (level != 0) emit toggleNew(); QTimer::singleShot(hallOfFameMS, this, SLOT(end())); return; } lastPlayer = player; for (int i = 0; i < 10; i++) if ( playerScore[lastPlayer] > hallOfFame[i].points) { lastScore = i; break; } if (lastScore < 0) { emit toggleNew(); QTimer::singleShot(hallOfFameMS, this, SLOT(end())); return; } for (int i = 9; i > lastScore && i > 0; i--) hallOfFame[i] = hallOfFame[i-1]; hallOfFame[lastScore].points = playerScore[lastPlayer]; hallOfFame[lastScore].levels = level; hallOfFame[lastScore].moment = QDateTime::currentDateTime(); hallOfFame[lastScore].name = playerName[lastPlayer]; cursor.x = 14; cursor.y = 11+lastScore; cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); // startTimer(cursorBlinkMS); setFocus(); }
void Score::keyPressEvent(QKeyEvent *k) { if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) { k->ignore(); return; } int x = cursor.x; int y = cursor.y; uint key = k->key(); if (scrollRepeat && (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)) { k->ignore(); return; } if (key != Key_Return) { if (key == RightKey || key == Key_Right) if (++cursor.x > 16) cursor.x = 14; if (key == LeftKey || key == Key_Left) if (--cursor.x < 14) cursor.x = 16; if (key == UpKey || key == Key_Up) if (cursor.chr.unicode() < bitfont->lastChar()) cursor.chr = cursor.chr.unicode()+1; else cursor.chr = bitfont->firstChar(); if (key == DownKey || key == Key_Down) if (cursor.chr.unicode() > bitfont->firstChar()) cursor.chr = cursor.chr.unicode()-1; else cursor.chr = bitfont->lastChar(); if (cursor.x == x && cursor.y == y && cursor.chr == hallOfFame[lastScore].name.at(cursor.x-14)) { uint ascii = k->ascii(); if (ascii < bitfont->firstChar() || ascii > bitfont->lastChar()) ascii = toupper(ascii); if (ascii >= bitfont->firstChar() && ascii <= bitfont->lastChar()) { cursor.chr = ascii; hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; if (++cursor.x > 16) cursor.x = 14; } } } if (key == Key_Return) { playerName[lastPlayer] = hallOfFame[lastScore].name; write(); read(); lastScore = -1; cursor.x = -1; cursor.y = -1; // killTimers(); emit toggleNew(); end(); } if (x != cursor.x || y != cursor.y) { if (cursor.x != -1 && lastScore >= 0) cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); scrollRepeat = FALSE; repaint(rect(x, y*1.25, cursor.chr), FALSE); } else if (lastScore >= 0) hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; if (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down) scrollRepeat = TRUE; else repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); }