int main(void) { srand(time(NULL)); GuessGamAnswer answer; answer.randomGenerate(); showRules(); // allow 10 guesses at maximum for (int i = 0; i < 10; ++i) { std::string input; do { input = getInput(); } while (!isInputLegal(input)); int match1 = 0, match2 = 0; answer.evaluateGuess(input, match1, match2); if (match1 < 4) showGuessResults(match1, match2); else showWin(); } showLose(answer); }
void myFinanceMainWindow::onAssetHistoryClicked() { qDebug() << STR("资产历史变化 clicked"); myAssetHistory assetHistory; QEventLoop eventLoop; connect(&assetHistory, SIGNAL(ready4Display()), &eventLoop, SLOT(quit())); assetHistory.prepareCalcAssetValue(QDateTime(QDate::currentDate()), QDateTime(QDate(2016, 7, 19))); eventLoop.exec(); myHistortyShow showWin(assetHistory.getHistoryValue(), this); showWin.exec(); }
void Optics2::drawLine(Ref *pSender) { if (lightOn) { node->clear(); lightOn=false; } else { lightOn=true; int objX = cannonX; int objY = cannonY; auto dir = cannon->firstDirection(); node = CCDrawNode::create(); addChild(node,10); while (dir!= GameObject::END && dir!=GameObject::WIN) { switch (dir) { case GameObject::UP : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX][objY--]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::DOWN : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX][objY++]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::LEFT : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX++][objY]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; case GameObject::RIGHT : node->drawSegment(grid[objX][objY]->getPosition(), grid[objX--][objY]->getPosition(), 5.0,ccc4f(180,180,180,100)); dir = grid[objX][objY]->nextDirection(dir); break; }//switch }//while if (dir==GameObject::WIN) showWin(); } }
void ball() { if(dir==1) if(y<=5)dir=2; else if(x>5&&y>5) { x--,y--; } else if(x==5&&y>=yy-50&&y<=yy+60) dir=rand()%2+3;//odbij paletka else { showWin(); newGame(); } //odbicie od gornej krawedzi if(dir==2) if(x>5&&y<225) { x--,y++; } else dir=1; if(dir==3) if(y<=5)dir=4; else if(y>5&&x<385) { x++,y--; } else if(x>=385&&y>=yyy-50&&y<=yyy+60) dir=rand()%2+1; else { showWin(); newGame(); } if(dir==4) if(y<225&&x<385) { x++,y++; } else dir=3; }
//如果是简单的单击处理,只需要在Began中处理就可以了,无需到ccTouchEnded中 bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { //如果输入盘打开了,并且点中了输入盘的某个数字,则填入选择的数字,并隐藏输入盘 if(g_pad->isVisible() && g_pad->containsTouchLocation(pTouch)) { int number = g_pad->getNumber(pTouch); _inputGrid->setValue(number); g_pad->setVisible(false); if(checkWin()) { //此处关闭单点触摸,只能点击按钮进行下一步 CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this); showWin(); } return true; } //如果是初始的数字,不允许修改 if(!canInput(pTouch)) { g_pad->setVisible(false); return true; } CCPoint pos = pTouch->getLocation(); pos.x = getBound(pos.x,g_pad->rect().getMaxX(),0,_background->getContentSize().width); pos.y = getBound(pos.y,g_pad->rect().getMaxY(),0,_background->getContentSize().height); //CCLOG("final pos x:%0.1f,y:%0.1f",pos.x,pos.y); runFx(pos); g_pad->setPosition(pos); g_pad->setScale(0.1f); g_pad->setVisible(true); SimpleAudioEngine::sharedEngine()->playEffect(CLICK_FILE); CCActionInterval* actionTo = CCScaleTo::create(0.05f, 1.2f); CCActionInterval* actionBack = CCScaleTo::create(0.05f,1.0f); //添加一些动作,可以仅仅是单个动作,也可以是多个动作组合 //g_pad->runAction(actionTo); g_pad->runAction( CCSequence::create(actionTo, actionBack, NULL)); _inputGrid = getGrid(pTouch); return true; }
/***************************************************************** * 函数名称:showGame * 描述说明:显示连连看游戏 * 输入参数:p_gameUi:游戏体指针 * 输出参数:无 *****************************************************************/ void showGame(gameUi_t *p_gameUi) { showWin(&p_gameUi->m_ui); showMat(&p_gameUi->m_mat); showTime(restTime); }
void MainWindow::getAlias(QString name) { showWin(gSavedWins[name]); }
void MainWindow::onWitemActivate(QModelIndex index) { if(proxy->rowCount() == 0) return; showWin(witems[getSelWinNum()].handle); }