//--------------------------------------------------------------------------- void __fastcall TQuizForm::ReviewedAnswer() { if (FCurrentQuestion > questions.size()) { ShowScore(this, questions.size(), FCorrectAnswers); Close(); } else { ShowQuestion(FCurrentQuestion); } }
void CGameDlg::OnClickedBtnRearrange() { if(!mute) m_nSound.ButtonClick(); if(m_bPause == true || Score < 10) return; Score -= 10; ShowScore(); m_GameC.ResetMap(); UpdateMap(); }
int GameInitial(){ InitializeCriticalSection(&cs); Screen.bar(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,BLACK); InitBox(); ShowBox(); ShowScore(); SDL_EnableKeyRepeat(400,KEYBREAK); ChangeTimes = 1; return 0; }
void RefreshAll( void ) { DrawBackdrop( ); ShowGrayMonitor( 0 ); ShowGrayMonitor( 1 ); RefreshNext( 0 ); RefreshNext( 1 ); RefreshPlayerWindow( 0 ); RefreshPlayerWindow( 1 ); DrawFrozenOpponent( ); DrawStage( ); ShowScore( 0 ); ShowScore( 1 ); }
void Game::Draw(){ if(IsRunning){ map->Draw(); snake->Draw(); ShowScore(); } else if (IsGameOver){ ShowGameOver(); } else ShowSplashScreen(); }
void CGameDlg::OnBnClickedBtnStart() { if(!mute) m_nSound.ButtonClick(); m_nSound.InGameBGM(); m_GameProgress.SetRange(0,SetTime); m_GameProgress.SetStep(-1); m_GameProgress.SetPos(300); SetTimer(PLAY_TIMER_ID, 1000,NULL); ShowScore(); DrawGameTime(); GetDlgItem(IDC_BTN_START)->EnableWindow(m_bPlaying); m_bPlaying = true; m_bPause = false; m_GameC.StartGame(); UpdateMap(); }
void CGameDlg::OnBnClickedBtnPrompt() { if(!mute) m_nSound.ButtonClick(); if(m_bPlaying == false || m_bPause == true || Score < 5) return; Score -= 5; ShowScore(); Vertex avsPath[MAX_SAVED_VERTEX_NUM]; int n_vex; bool bSuc = m_GameC.Help(avsPath,n_vex); if(bSuc) { DrawTipFrame(avsPath[0].row,avsPath[0].col); DrawTipFrame(avsPath[n_vex-1].row,avsPath[n_vex-1].col); DrawTipLine(avsPath,n_vex); } UpdateMap(); Sleep(200); InvalidateRect(m_rtGameRect,FALSE); }
BOOL CGameDlg::OnInitDialog() { //mainBGM(); CDialogEx::OnInitDialog(); InitBackground(); InitElement(); InitMask(); InitComboMask(); InitComboInit(); Pause(); UpdateWindow(); Score = 0; ShowScore(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon return TRUE;// return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void Scene::setbg_3(){ QString load; if(difficulty==4) load=":/pics/pics/bg_oni.png"; else if(difficulty==3) load=":/pics/pics/bg_hard.png"; else if(difficulty==2) load=":/pics/pics/bg_normal.png"; else load=":/pics/pics/bg_easy.png"; QImage bg; bg.load(load); bg = bg.scaled(770,400); this->setBackgroundBrush(bg); text1->setText(title[s]); text1->setPos(488,9); addItem(text1); Map.setSongPlay(title[s]); track = new QMediaPlayer(this); track->setMedia(QUrl::fromLocalFile(QDir::toNativeSeparators(Map.trackPath))); VOL=(Map.map["SONGVOL"]-Map.map["SEVOL"])>0?(Map.map["SONGVOL"]-Map.map["SEVOL"]+50):70; track->setVolume(VOL); BPM=Map.map["BPM"]; Map.getMap(title[s],Map.star[difficulty-1]); Map.convert(setRandom); if(setRandom==true){ QPixmap ran; ran.load(":/pics/pics/optionicon_random.png"); randomTag = new QGraphicsPixmapItem; randomTag->setPos(199,83); randomTag->setPixmap(ran); addItem(randomTag); } if(setAuto==true){ QPixmap au; au.load(":/pics/pics/optionicon_auto.png"); autoTag = new QGraphicsPixmapItem; autoTag->setPos(394,72); autoTag->setPixmap(au); addItem(autoTag); } if(set30secMode==true){ QPixmap ctd; ctd.load(":/pics/pics/optionicon_demo.png"); countdownTag = new QGraphicsPixmapItem; countdownTag->setPos(294,72); countdownTag->setPixmap(ctd); addItem(countdownTag); countdown = new QTimer(this); QObject::connect(countdown , SIGNAL(timeout()) , this , SLOT(secondsLeft())); } songMap=Map.songMap; foreach (QString i, songMap) { qDebug()<<i<<endl; } RD = new QTimer(this); LD = new QTimer(this); RK = new QTimer(this); LK = new QTimer(this); rdp = new QGraphicsPixmapItem;ldp = new QGraphicsPixmapItem; rkp = new QGraphicsPixmapItem;lkp = new QGraphicsPixmapItem; QPixmap res; res.load(":/pics/pics/rd.png"); rdp->setPixmap(res);rdp->setPos(147,123); res.load(":/pics/pics/ld.png"); ldp->setPixmap(res);ldp->setPos(106,123); res.load(":/pics/pics/rk.png"); rkp->setPixmap(res);rkp->setPos(147,124); res.load(":/pics/pics/lk.png"); lkp->setPixmap(res);lkp->setPos(105,124); for(int i=0;i<4;i++){ add[i]=false; } QObject::connect(this , SIGNAL(PlayRdong()) , this , SLOT(playRdong())); QObject::connect(this , SIGNAL(PlayLdong()) , this , SLOT(playLdong())); QObject::connect(this , SIGNAL(PlayRka()) , this , SLOT(playRka())); QObject::connect(this , SIGNAL(PlayLka()) , this , SLOT(playLka())); QObject::connect(RD , SIGNAL(timeout()) , this , SLOT(playRdong())); QObject::connect(LD , SIGNAL(timeout()) , this , SLOT(playLdong())); QObject::connect(RK , SIGNAL(timeout()) , this , SLOT(playRka())); QObject::connect(LK , SIGNAL(timeout()) , this , SLOT(playLka())); AniTimer1 = new QTimer(this); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(moveJudgement())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(FlySoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(MidSoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(WalkSoul())); QObject::connect(this , SIGNAL(Great()) , this , SLOT(GenGreat())); QObject::connect(this , SIGNAL(Good()) , this , SLOT(GenGood())); QObject::connect(this , SIGNAL(Miss()) , this , SLOT(GenMiss())); QObject::connect(this , SIGNAL(Combo()) , this , SLOT(ShowCombo())); QObject::connect(this , SIGNAL(Score()) , this , SLOT(ShowScore())); QObject::connect(this , SIGNAL(Jump()) , this , SLOT(donJump())); QObject::connect(this , SIGNAL(SoulF()) , this , SLOT(GenFlySoul())); QObject::connect(this , SIGNAL(SoulM()) , this , SLOT(GenMidSoul())); QObject::connect(this , SIGNAL(SoulW()) , this , SLOT(GenWalkSoul())); ex1.load(":/pics/pics/explosion_s4.png"); AniTimer2 = new QTimer(this); QObject::connect(AniTimer2 , SIGNAL(timeout()) , this , SLOT(RemoveExplode())); QObject::connect(this , SIGNAL(Explode()) , this , SLOT(GenExplode())); AniTimer3 = new QTimer(this); QObject::connect(AniTimer3 , SIGNAL(timeout()) , this , SLOT(Jumper())); jumper = new QGraphicsPixmapItem; jumper->setPos(0,0); addItem(jumper); AniTimer4 = new QTimer(this); QObject::connect(AniTimer4 , SIGNAL(timeout()) , this , SLOT(Dance())); loadDancerPic(); createDanceItem(); great=0;good=0;miss=0; combo=0;maxcombo=0;soul=0,score=0; secLeft=30;jumpPicNum=1; msec=60000/BPM/4+2; test=60000/BPM/16; waitfor=109*test/2+Map.map["OFFSET"]*1000; for(int i=0;i<10;i++){ numberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ ctdnumberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ scorenumberPic[i].load(":/pics/pics/scorenumber_"+QString::number(i)+".png"); } for(int i=50;i<1000;i+=100){ QSound *so; QString c; c=QString::number(i); so = new QSound(":/sound/sound/voice_"+c+"combo.wav"); comTrack.push_back(so); if(i==50)i+=50; } for(int i=0;i<3;i++){ jumpPic[i].load(":/pics/pics/playerchar_normal"+QString::number(i+1)+".png"); jumpPic[i] = jumpPic[i].scaled(jumpPic[i].width()*1.48,jumpPic[i].height()*1.48); } //Etimer = new QElapsedTimer; //Etimer->start(); timer = new QTimer(this); QObject::connect(timer , SIGNAL(timeout()) , this , SLOT(stopWait())); timer1 = new QTimer(this); timer2 = new QTimer(this); timer3 = new QTimer(this); cout<<"msec: "<<msec<<endl; cout<<"waitfor: "<<waitfor<<endl; QObject::connect(timer2 , SIGNAL(timeout()) , this , SLOT(Generate())); if(setAuto==false) QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Move())); else QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Auto())); QObject::connect(timer3 , SIGNAL(timeout()) , this , SLOT(startWave())); if(waitfor<0){ track->play(); timer->start(-waitfor); waitfor=0; } else timer->start(0); }
void CGameDlg::OnLButtonUp(UINT nFlags, CPoint point) { if(point.y<m_ptGameTop.y || point.x<m_ptGameTop.x || !m_bPlaying || m_bPause) { CDialogEx::OnLButtonUp(nFlags, point); } else{ if(!m_GameC.IsWin()) { int nRow = (point.y-m_ptGameTop.y)/m_sizeElem.cy; int nCol = (point.x-m_ptGameTop.x)/m_sizeElem.cx; if( m_GameC.GetElement(nRow,nCol)!=BLANK && nRow < SetRow && nCol < SetCol) { if(m_bFirstPoint) //the First Point { m_bFirstPoint = false; DrawTipFrame(nRow,nCol); m_GameC.SetFirstPoint(nRow,nCol); if(!mute) m_nSound.Select(); } else //the Second Point { m_bFirstPoint = true; DrawTipFrame(nRow,nCol); m_GameC.SetSecPoint(nRow,nCol); Vertex avPath[MAX_SAVED_VERTEX_NUM]; if(!mute) m_nSound.Select(); if(m_GameC.Link(avPath,vex)) { DrawTipLine(avPath,vex); if(!mute) m_nSound.Erase(); Score+=10; ShowScore(); if(!m_combo) { m_combo_check1 = m_GameProgress.GetPos(); m_combo = true; } else if(m_combo) { m_combo_check2 = m_GameProgress.GetPos(); m_combo = false; } int firsttime,lasttime; (m_combo_check1 > m_combo_check2)? (firsttime = m_combo_check1, lasttime = m_combo_check2) : (firsttime = m_combo_check2, lasttime = m_combo_check1); if(firsttime - lasttime < 3) { Output_combo = true; TotalCombo += 1; ComboScore += 5; Score +=ComboScore; ShowScore(); } else { ComboScore = 0; } } UpdateMap(); if(Output_combo) { Combo(); Output_combo = false; } Sleep(200); InvalidateRect(m_rtGameRect,FALSE); } } } else { if(!mute){ m_nSound.Stop(); m_nSound.Win(); } m_bPlaying = false; int Lefttime = m_GameProgress.GetPos() ; TimeBonus = (double)Score*((double)Lefttime/300); CGameResult result; result.TotalScore = Score+TimeBonus; result.TotalCombo = TotalCombo; result.TimeBonus = TimeBonus; result.DoModal(); } } }
int ThreadFunc(void * unused){ int old_time,cur_time,x,y; old_time = cur_time = SDL_GetTicks(); while( !gameOver ){ while( alive ){ while( !Operation.isEmpty() && alive){ EnterCriticalSection(&cs); Operation.DeleteQ(command); curblk.ClearCube(); switch( command ){ case MOVEDOWN: curblk.MoveDown(); break; case MOVELEFT: curblk.MoveLeft(); break; case MOVERIGHT:curblk.MoveRight(); break; case ROTATE : curblk.Rotate(); break; } if( command == TURNNEXT ){ //有的特殊命令最好特殊处理 curblk.TurnNext(); break; } curblk.DrawCube(); Screen.flip(); LeaveCriticalSection(&cs); } cur_time = SDL_GetTicks(); SDL_Delay(1); if( !AIMode ){ if( cur_time - old_time < 500 ) continue; old_time = cur_time; Operation.AddQ(MOVEDOWN); }else{ if( cur_time - old_time < 50 ) continue; old_time = cur_time; x = curblk.x; y = curblk.y; if( BestRotate>0 ){ Operation.AddQ(ROTATE); BestRotate -= 1; continue; } if( BestPath[x][y+1] ){ Operation.AddQ(MOVEDOWN); BestPath[x][y+1] = 0; y += 1; continue; }else if( BestPath[x+1][y] ){ Operation.AddQ(MOVERIGHT); BestPath[x+1][y] = 0; x += 1; continue; }else if( BestPath[x-1][y] ){ Operation.AddQ(MOVELEFT); BestPath[x-1][y] = 0; x -= 1; continue; } alive = 0; } } while(DelLine()); Operation.ClearQ(); ShowCube(); ShowScore(); if( AIMode ) Search(); alive = 1; } return 0; }
void Game::Loop(){ srand (time(NULL)); player = new Player(renderer,WIDTH/2 ,HEIGHT/2,1,PLAYER,&information); gameObjects.push_back(player); for(int i=1;i<=5;i++) { int AsteroidX = rand() % 600 + 150; int AsteroidY = rand() % 300 + 150; if(player->CheckIfCanSpawnAsteroid(AsteroidX,AsteroidY)) { asteroid = new Asteroids(renderer,AsteroidX,AsteroidY,&information); gameObjects.push_back(asteroid); } else i--; } while(!quit && mainEvent.type != SDL_QUIT) { timer = SDL_GetTicks(); CheckIfGameIsEnded(); while(SDL_PollEvent(&mainEvent)) { if(mainEvent.type == SDL_KEYDOWN) { if(mainEvent.key.keysym.sym == SDLK_q) { //ADDING NEW ASTEROIDS //asteroid = new Asteroids(renderer,rand() % 600 + 150 ,rand() % 300 + 150,&information); //gameObjects.push_back(asteroid); } if(mainEvent.key.keysym.sym == SDLK_SPACE) { //ADDING NEW ASTEROIDS bullet = new Bullet(renderer,player->points[1].x,player->points[1].y,5,BULLET,player->GetAngle(),&information); gameObjects.push_back(bullet); } } } SpawnAsteroids(); /////////////////COLLISION DETECTION //////////// CollisionDetection(); /////////////////////////////////////////////////////// //UPDATE GAMEOBJECTS for(int i = 0; i < gameObjects.size(); i++){ gameObjects[i]->Update(); } //////////////////////////////////////////////////////// //DELETE DEAD OBJECTS DeleteUnusedOrDeadObjects(); ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //DRAW Background RenderBackground(); ////////////////////////////////////////////////////// //DRAW things ///////RENDER for(int i = 0; i < gameObjects.size(); i++){ gameObjects[i]->Render(); } ShowScore(information); //////////////////////////////////////////////////////// ///////////////FPS////////////// SDL_RenderPresent(renderer); if(1000/FPS > SDL_GetTicks() - timer) SDL_Delay(1000/FPS - (SDL_GetTicks() - timer)); //////////////////////////////////////////////////////// } }
void wxBlokus::OnGameEnd() { ShowScore(); }
void wxBlokus::OnCountScore(wxCommandEvent &event) { ShowScore(); }