/*********************************************************************** Main ***********************************************************************/ void main(void) { DisableInterrupts; initializations(); EnableInterrupts; //enables external xirq after vSync IRQ vSyncFlag = 0; while((vSyncFlag != 1) & (hCnt == 0)) {} asm andcc #$BF ////////////////////////////////////////////////////////////// //; START OF CODE FOR Spring 2012 MINI-PROJECT ////////////////////////////////////////////////////////////// // Load/Display Spalsh Screen displaySplash(); for(;;) { // write code here (Insert Code down here because we need an infinite loop.) // Display Menu Screen displayMenu(selection); // Check for Menu Selection checkMenuInputs(joy0vert); // Use case statement to branch to appropriate selection. // Don't branch unless the user has triggered the 'select' button. if (select == 1) { select = 0; switch (selection) { // Sub Function // Menu: case 1: // Select Character selectCharacter(); break; case 2: // Select Field selectField(); break; case 3: // Start Match startMatch(); break; // the default case is '-1' if nothing has been selected default: break; } } // We don't need the watchdog timer, but I don't think it can hurt to feed it anyway. // The watchdog was disabled in the initialization code. _FEED_COP(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ }
/** * Method handling the response to an invitation * @param JSON::Dict : content of the invitation * @param int : id of the user who sent the invitation */ void GameManager::sendInvitationResponseToPlayer(const JSON::Dict &response, int peer_id){ string username; if (ISSTR(response.get("username"))) username = STR(response.get("username")).value(); string answer; if (ISSTR(response.get("answer"))) answer = STR(response.get("answer")).value(); map<int, User*>::iterator findSender = _users.find(peer_id); for (map<int, User*>::iterator it=_users.begin(); it!=_users.end(); it++){ if (it->second->getUsername() == username){ JSON::Dict toSend; toSend.set("type", MSG::FRIENDLY_GAME_INVITATION_RESPONSE); JSON::Dict data; data.set("username", findSender->second->getUsername()); data.set("answer", answer); toSend.set("data", data); Message status(it->first, toSend.clone()); _outbox.push(status); if (answer == MSG::FRIENDLY_GAME_INVITATION_ACCEPT){ startMatch(peer_id, it->first, false); } } } }
void Pong::run(float timediff) { //--Spieler input verarbeiten und Spielerskelett Zeichnen for(std::vector<Player*>::iterator it = app->players.begin(); it != app->players.end(); it++) { Player* pl = *it; if(pl != 0) { pl->processInput(timediff); pl->draw(Player::SKELETON | Player::BAR); } } if(app->players[app->PLAYER_LEFT] != 0) { if(app->players[app->PLAYER_LEFT]->getExit()) { app->switchTo(app->GS_MENU); } } if(app->players[app->PLAYER_RIGHT] != 0) { if(app->players[app->PLAYER_RIGHT]->getExit()) { app->switchTo(app->GS_MENU); } } //--Ball einfügen if(spawnBall) { timeToSpawnBall -= timediff; if(timeToSpawnBall <= 0.0f) { doSpawnBall(); } } //--Spieler Verarbeiten if(app->playersActive == 2) { drawScores(app->players[app->PLAYER_LEFT]->getScore(), app->players[app->PLAYER_RIGHT]->getScore()); if(!inMatch) { clearBalls(); spawnBall = false; timeToMatch -= timediff; if(timeToMatch <= 0.0f) { startMatch(); } } if(Application::enableEasterEggs) { doEsterEgg(app->PLAYER_LEFT, app->players[app->PLAYER_LEFT]->getEsterEgg()); doEsterEgg(app->PLAYER_RIGHT, app->players[app->PLAYER_RIGHT]->getEsterEgg()); } } else { spawnBall = true; } if(calcForces(timediff)) //--bei Kollision sound ausgeben (nur wenn Spieler drin sind) { app->soundPlayer->effect("collision"); } }
DictApplet::DictApplet(const QString& configFile, Type type, int actions, QWidget *parent, const char *name) : KPanelApplet(configFile, type, actions, parent, name), waiting(0) { // first the widgets for a horizontal panel baseWidget = new QWidget(this); QGridLayout *baseLay = new QGridLayout(baseWidget,2,6,0,1); textLabel = new QLabel(i18n("Dictionary:"), baseWidget); textLabel->setBackgroundOrigin(AncestorOrigin); QFont f(textLabel->font()); f.setPixelSize(12); textLabel->setFont(f); baseLay->addWidget(textLabel,0,1); QToolTip::add(textLabel,i18n("Look up a word or phrase with Kdict")); iconLabel = new QLabel(baseWidget); iconLabel->setBackgroundOrigin(AncestorOrigin); QPixmap pm = KGlobal::iconLoader()->loadIcon("kdict", KIcon::Panel, KIcon::SizeSmall, KIcon::DefaultState, 0L, true); iconLabel->setPixmap(pm); baseLay->addWidget(iconLabel,1,0); iconLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); iconLabel->setFixedWidth(pm.width()+4); QToolTip::add(iconLabel,i18n("Look up a word or phrase with Kdict")); f.setPixelSize(10); clipboardBtn = new QPushButton(i18n("C"),baseWidget); clipboardBtn->setBackgroundOrigin(AncestorOrigin); clipboardBtn->setFont(f); clipboardBtn->setFixedSize(16,16); connect(clipboardBtn, SIGNAL(clicked()), SLOT(queryClipboard())); baseLay->addWidget(clipboardBtn,0,3); QToolTip::add(clipboardBtn,i18n("Define selected text")); defineBtn = new QPushButton(i18n("D"),baseWidget); defineBtn->setBackgroundOrigin(AncestorOrigin); defineBtn->setFont(f); defineBtn->setFixedSize(16,16); defineBtn->setEnabled(false); connect(defineBtn, SIGNAL(clicked()), SLOT(startDefine())); baseLay->addWidget(defineBtn,0,4); QToolTip::add(defineBtn,i18n("Define word/phrase")); matchBtn = new QPushButton(i18n("M"),baseWidget); matchBtn->setBackgroundOrigin(AncestorOrigin); matchBtn->setFont(f); matchBtn->setFixedSize(16,16); matchBtn->setEnabled(false); connect(matchBtn, SIGNAL(clicked()), SLOT(startMatch())); baseLay->addWidget(matchBtn,0,5); QToolTip::add(matchBtn,i18n("Find matching definitions")); completionObject = new KCompletion(); internalCombo = new KHistoryCombo(baseWidget); internalCombo->setBackgroundOrigin(AncestorOrigin); internalCombo->setCompletionObject(completionObject); internalCombo->setFocus(); internalCombo->clearEdit(); internalCombo->lineEdit()->installEventFilter( this ); connect(internalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&))); connect(internalCombo, SIGNAL(textChanged(const QString&)), SLOT(comboTextChanged(const QString&))); QToolTip::add(internalCombo,i18n("Look up a word or phrase with Kdict")); baseLay->addMultiCellWidget(internalCombo,1,1,1,5); baseLay->setColStretch(2,1); // widgets for a vertical panel verticalBtn = new QPushButton(this); connect(verticalBtn, SIGNAL(pressed()), SLOT(showExternalCombo())); QToolTip::add(verticalBtn,i18n("Look up a word or phrase with Kdict")); popupBox = new PopupBox(); popupBox->setFixedSize(160, 22); connect(popupBox, SIGNAL(hidden()), SLOT(externalComboHidden())); externalCombo = new KHistoryCombo(popupBox); externalCombo->setCompletionObject(completionObject); connect(externalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&))); externalCombo->setFixedSize(160, externalCombo->sizeHint().height()); connect(internalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(updateCompletionMode(KGlobalSettings::Completion))); connect(externalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(updateCompletionMode(KGlobalSettings::Completion))); // restore history and completion list KConfig *c = config(); c->setGroup("General"); QStringList list = c->readListEntry("Completion list"); completionObject->setItems(list); int mode = c->readNumEntry("Completion mode", KGlobalSettings::completionMode()); internalCombo->setCompletionMode((KGlobalSettings::Completion)mode); externalCombo->setCompletionMode((KGlobalSettings::Completion)mode); list = c->readListEntry("History list"); internalCombo->setHistoryItems(list); externalCombo->setHistoryItems(list); }