Tippeligaen::Tippeligaen(QWidget *parent) : QMainWindow(parent), ui(new Ui::Tippeligaen) { ui->setupUi(this); QGroupBox *team = createTeamChooserGroupBox(); teamOfTheRound = createTeamOfTheRoundGroupBox(); createTeamPlayersGroupBox(); createTeamInfoGroupBox(); createTeamOfTheRoundChooseTeamGroupBox(); createTeamWikiView(); createTeamOfTheRoundShowTeam(); crateNewTeamOfTheRound(); makeWindowMenues(); createMakeNewPlayerView(); doAtStartUp(); QGridLayout *layout = new QGridLayout; layout->addWidget(team, 0, 0); layout->addWidget(players, 1, 0); layout->addWidget(playerInfoGroupBox, 2 ,0); layout->addWidget(makePlayerGroupBox, 2, 0); layout->addWidget(crateNewTeamOfTheRoundGroupBox, 2, 0); layout->addWidget(teamOfTheRound, 0, 1, 3, 1); layout->addWidget(teamWiki, 0, 1, 3, 1); layout->addWidget(teamOfTheRoundChooseTeamGroupBox, 0, 1); layout->addWidget(createTeamOfTheRoundShowTeamGroupBox, 1, 1); layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(0, 500); layout->setColumnMinimumWidth(1, 500); QWidget *widget = new QWidget; widget->setLayout(layout); setCentralWidget(widget); this->adjustSize(); setWindowTitle(tr("Tippeligaen 2010")); connect(playerTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(updatePlayerInformation())); connect(teamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTeamWiki(int))); connect(deletePlayerButton, SIGNAL(clicked()), this, SLOT(deletePlayer())); connect(createNewPlayer, SIGNAL(clicked()), this, SLOT(actionAddNewPlayerToDataBase())); connect(addToTeamOfTheRoundButton, SIGNAL(clicked()), this, SLOT(addPlayerToTeamOfTheRound())); connect(teamOfTheRoundChooseTeamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTeamOfTheRoundTable())); connect(teamOfTheRoundButton, SIGNAL(clicked()), this, SLOT(teamOfTheRoundButtonClicked())); connectMainMenuSlots(); }
//************************************ // Method: destroyGame- release all dynamic allocations // FullName: Game::destroyGame // Access: protected // Returns: void // Qualifier: //************************************ void Game::destroyGame() { bool hasPlayers=true; while (hasPlayers=deletePlayer()) { //No body - work done in deletePlayer() } }
int main (int argc, char* argv[]) { if (!loadMapFromFile ("maps/level1.map")) { printf ("Can't locate map!"); } initGUI(); initMap(); initPlayer(); SDL_Event e; int quit = 0; int start_time; int urd_time; int wait_time; int target_time = 1000/FPS; while (!quit) { start_time = SDL_GetTicks(); while (SDL_PollEvent (&e)) { if (e.type == SDL_QUIT) { quit = 1; } else { player->left = 0; player->right = 0; } processInput (); } clearScreen(); updatePlayer (player); renderBackground(); renderMap(); renderPlayer (player); draw(); urd_time = (SDL_GetTicks() - start_time); wait_time = target_time - urd_time; SDL_Delay (wait_time); } destroyGUI(); deletePlayer (player); return 0; }
void ledCube8_Game::button6Player2() { deletePlayer(pos[1]); pos[1].Z++; if(pos[1].Z > 8) { pos[1].Z = 8; } else { //player = cube->getShiftCubeUp(1,false,player); } setPlayer(pos[1]); calculate(); send(); }
void ledCube8_Game::button5Player2() { deletePlayer(pos[1]); pos[1].Z--; if(pos[1].Z < 1) { pos[1].Z = 1; } else { //player = cube->getShiftCubeDown(1,false,player); } setPlayer(pos[1]); calculate(); send(); }
void ledCube8_Game::button4Player2() { deletePlayer(pos[1]); pos[1].Y++; if(pos[1].Y > 8) { pos[1].Y = 8; } else { //player = cube->getShiftCubeLeft90(1,false,player); } setPlayer(pos[1]); calculate(); send(); }
void ledCube8_Game::button3Player2() { deletePlayer(pos[1]); pos[1].Y--; if(pos[1].Y < 1) { pos[1].Y = 1; } else { //player = cube->getShiftCubeRight90(1,false,player); } setPlayer(pos[1]); calculate(); send(); }
void ledCube8_Game::button2Player1() { deletePlayer(pos[0]); pos[0].X++; if(pos[0].X > 8) { pos[0].X = 8; } else { //player = cube->getShiftCubeLeft(1,false,player); } setPlayer(pos[0]); calculate(); send(); }
//===========================BUTTONS======================================== //===========================Player1======================================== void ledCube8_Game::button1Player1() { deletePlayer(pos[0]); pos[0].X--; if(pos[0].X < 1) { pos[0].X = 1; } else { //player = cube->getShiftCubeRight(1,false,player); } setPlayer(pos[0]); calculate(); send(); }
bool CMethod::sendPlane(vector<SCARD>& player,vector<SENDCARDS>& send,int ID,int x,int y) { int Customunsigned; if (ID==PLAYER_C) { Customunsigned =1; }else if(ID==PLAYER_A) Customunsigned =0; int tempIndex; SENDCARDS tempSend; if (!m_plane.empty()) { for (int i=0;i<m_plane.size();i++) { if (m_plane[i].m_ISprimary==true&&((m_plane[i].max>m_sendArray.max&& (m_plane[i].max-m_plane[i].min==m_card.three-1))||m_noSendNum==2)) { for (int j=m_plane[i].min,index=0;j<=m_plane[i].max;j++,index++) { for (int k=0;k<=2;k++) { tempIndex= returnIndex(player,j); tempSend.coord_x=x+index*60+k*20-100*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_plane[i].max; } } m_sendArray.type=PLANECARDS; m_sendArray.cardNum=(m_plane[i].max-m_plane[i].min+1)*3; deletePlayer(player,send,ID); return true; } } } return false; }
void player::playerDelete() { deletePlayer(); }
bool CMethod::DeleteComputerCard(vector<SCARD>& player,CARDTYPE type,vector<SENDCARDS>& send,int ID,int x,int y)//删除电脑的牌 { int Customunsigned; if (ID==PLAYER_C) { Customunsigned =1; }else if(ID==PLAYER_A) Customunsigned =0; int tempIndex; SENDCARDS tempSend; switch(type) { case SINGLECARD://单张 if (!m_single.empty())//单张数组不等于空 { for (int i=0;i<m_single.size();i++) { if (m_single[i].m_ISprimary==true&&m_single[i].max>m_sendArray.max) { tempIndex= returnIndex(player,m_single[i].max); tempSend.coord_x=x; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_single[i].max; m_sendArray.cardNum=1; m_sendArray.type=SINGLECARD; deletePlayer(player,send,ID); return true; } } } break; case BOTHCARDS://对子 if (!m_double.empty())//单张数组不等于空 { for (int i=0;i<m_double.size();i++) { if (m_double[i].m_ISprimary==true&&m_double[i].max>m_sendArray.max) { for (int j=m_double[i].min;j<=m_double[i].max;j++) { for (int k=0;k<=1;k++) { tempIndex= returnIndex(player,j); tempSend.coord_x=x+k*20-40*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_double[i].max; } } m_sendArray.cardNum=2; m_sendArray.type=BOTHCARDS; deletePlayer(player,send,ID); return true; } } } break; case THREECARDS: if (!m_three.empty())//单张数组不等于空 { for (int i=0;i<m_three.size();i++) { if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max) { for (int j=m_three[i].min;j<=m_three[i].max;j++) { for (int k=0;k<=2;k++) { tempIndex= returnIndex(player,j); tempSend.coord_x=x+k*20-30*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_three[i].max; } } m_sendArray.cardNum=3; m_sendArray.type =THREECARDS; deletePlayer(player,send,ID); return true; } } } break; case THREECARDSOFONE: if (!m_three.empty())//单张数组不等于空 { for (int i=0;i<m_three.size();i++) { if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max) { for (int k=0;k<=2;k++) { tempIndex= returnIndex(player,m_three[i].max); tempSend.coord_x=x+k*20-60*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_three[i].max; } if (!m_single.empty()) { for (int i=0;i<m_single.size();i++) { if (m_single[i].m_ISprimary) { tempIndex= returnIndex(player,m_single[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_sendArray.cardNum=4; m_sendArray.type=THREECARDSOFONE; deletePlayer(player,send,ID); return true; } } } } }for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();) { if (iter->ID==ID) { iter=send.erase(iter); }else iter ++; } return false; } break; case THREECARDSOFTWO: if (!m_three.empty())//单张数组不等于空 { for (int i=0;i<m_three.size();i++) { if (m_three[i].m_ISprimary==true&&m_three[i].max>m_sendArray.max) { for (int k=0;k<=2;k++) { tempIndex= returnIndex(player,m_three[i].max); tempSend.coord_x=x+k*20-60*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_three[i].max; } if (!m_double.empty())//单张数组不等于空 { for (int i=0;i<m_double.size();i++) { if (m_double[i].m_ISprimary==true) { for (int k=0;k<=1;k++) { tempIndex= returnIndex(player,m_double[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_double[i].max; } m_sendArray.type=THREECARDSOFTWO; m_sendArray.cardNum=5; deletePlayer(player,send,ID); return true; } } } } } for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();) { if (iter->ID==ID) { iter=send.erase(iter); }else iter ++; } return false; } break; case LINKCARDS: if (!m_link.empty()) { for (int i=0;i<m_link.size();i++) { if (m_link[i].m_ISprimary==true&&((m_link[i].max>m_sendArray.max&&(m_link[i].max-m_link[i].min==m_send.size()-1))||m_noSendNum==2)) { for (int j=m_link[i].min,index=0;j<=m_link[i].max;j++,index++) { tempIndex= returnIndex(player,j); tempSend.coord_x=x+index*20-(m_link[i].max-m_link[i].min)*20*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_link[i].max; } m_sendArray.cardNum=m_link[i].max-m_link[i].min+1; m_sendArray.type=LINKCARDS; deletePlayer(player,send,ID); return true; } } } break; case LINKBOTHCARDS: if (!m_doubleLink.empty()) { for (int i=0;i<m_doubleLink.size();i++) { if (((m_doubleLink[i].m_ISprimary==true) &&(m_doubleLink[i].max>m_sendArray.max &&(m_doubleLink[i].max-m_doubleLink[i].min==m_send.size()/2-1))||m_noSendNum==2)) { //MessageBox(0,0,0,0); for (int j=m_doubleLink[i].min,index=0;j<=m_doubleLink[i].max;j+=1,index+=1) { for (int k=0;k<=1;k++) { tempIndex= returnIndex(player,j); tempSend.coord_x=x+index*40+k*20-100*Customunsigned; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); m_maxCard = m_double[i].max; } } m_sendArray.cardNum=(m_doubleLink[i].max-m_doubleLink[i].min+1)*2; m_sendArray.type=LINKBOTHCARDS; deletePlayer(player,send,ID); return true; } } } break; case PLANECARDS: return sendPlane(player,send,ID,x,y); break; case PLANECARDSOFONE: if (m_handNum[0].s_single.size()>=2&&sendPlane(player,send,ID,x-60,y)) { for (int i=0;i<2;i++) { tempIndex= returnIndex(player,m_handNum[0].s_single[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } m_sendArray.cardNum=8; m_sendArray.type=PLANECARDSOFONE; deletePlayer(player,send,ID); return true; } if (m_handNum[0].s_double.size()>=1&&sendPlane(player,send,ID,x-60,y)) { for (int i=0;i<=1;i++) { tempIndex= returnIndex(player,m_handNum[0].s_double[0].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } m_sendArray.cardNum=8; m_sendArray.type=PLANECARDSOFONE; deletePlayer(player,send,ID); return true; if (m_handNum[0].s_three.size()>=1&&sendPlane(player,send,ID,x-60,y)) { for (int i=0;i<=1;i++) { tempIndex= returnIndex(player,m_handNum[0].s_three[0].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } m_sendArray.cardNum=8; m_sendArray.type=PLANECARDSOFONE; deletePlayer(player,send,ID); return true; } } break; case PLANECARDSOFTWO: if (m_handNum[0].s_double.size()>=2&&sendPlane(player,send,ID,x-90,y)) { for (int i=0;i<m_card.second;i++) { for (int j=0;j<=1;j++) { tempIndex= returnIndex(player,m_handNum[0].s_double[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } } m_sendArray.cardNum=10; m_sendArray.type=PLANECARDSOFTWO; deletePlayer(player,send,ID); return true; } /*for (vector<SENDCARDS>::iterator iter=send.begin();iter!=send.end();) { if (iter->ID==ID) { iter=send.erase(iter); }else iter++; }*/ break; case BOMBCARDSOFONE: if (!m_bomb.empty()) { for (int j=0;j<4;j++) { tempIndex= returnIndex(player,m_bomb[0].max); tempSend.coord_x=x+20*j-Customunsigned*90; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } if (m_handNum[0].s_single.size()>=2) { for (int i=0;i<2;i++) { tempIndex= returnIndex(player,m_handNum[0].s_single[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } m_sendArray.cardNum=5; m_sendArray.type=BOMBCARDSOFONE; deletePlayer(player,send,ID); return true; } if (m_handNum[0].s_double.size()>=1) { for (int i=0;i<=1;i++) { tempIndex= returnIndex(player,m_handNum[0].s_double[0].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } m_sendArray.cardNum=5; m_sendArray.type=BOMBCARDSOFONE; deletePlayer(player,send,ID); return true; } } break; case BOMBCARDSOFTWO: if (!m_bomb.empty()) { for (int j=0;j<4;j++) { tempIndex= returnIndex(player,m_bomb[0].max); tempSend.coord_x=x+20*j-Customunsigned*135; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } if (m_handNum[0].s_double.size()>=2) { for (int i=0;i<=1;i++) { for (int j=0;j<=1;j++) { tempIndex= returnIndex(player,m_handNum[0].s_double[i].max); tempSend.coord_x=send[send.size()-1].coord_x+20; tempSend.coord_y=y; tempSend.ID=ID; tempSend.cx=player[tempIndex].cx; tempSend.cy=player[tempIndex].cy; send.push_back(tempSend); } } m_sendArray.cardNum=6; m_sendArray.type=BOMBCARDSOFTWO; deletePlayer(player,send,ID); return true; } } break; } return false; }
/** *\fn int main(int argc, char *argv[]) * Main *\param[in,out] argc argc *\param[in,out] argv argv */ int main(int argc, char *argv[]) { SDL_Surface *screen = NULL; int go = 1; int ret,ret1, ret2 = 0, ret3, ret4; char level_name[MAX_SIZE_FILE_NAME]; char player_name[MAX_SIZE_FILE_NAME]; int nb_lvl; /*sound*/ Sound *sound_system; sound_system = createSound(); /*keyboard config*/ SDLKey kc[NB_KEY-1]; /*input*/ Input in; SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK); Player *current_player; current_player = (Player *)malloc(sizeof(Player)); /*screen initialization*/ screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); initInput(&in); /*configurations loading */ loadSoundOptions("configuration/sound.conf",sound_system); SDL_WM_SetCaption("Super Martin", NULL); //window name SDL_ShowCursor(SDL_DISABLE); //delete the mouse while (go) //main loop { if(titleMenu(screen,&go,sound_system, &in)) { while( (ret3 = menuPlayers(screen, player_name, &go, sound_system, &in)) != -1 && go) { switch(ret3) { case -1: break; case 2 : ret2 = newPlayer(screen, player_name, sound_system, &go); if(ret2 == 1) { current_player->levelMax = 1; current_player->nbCoins = 0; current_player->nbLifes = 3; current_player->nbProjectile = 5; savePlayer("save/.save", player_name, current_player); loadInputOptions("default",kc,&in); saveInputOptions(player_name, kc, &in); } else break; case 1 : loadPlayer("save/.save", player_name, current_player); loadInputOptions(player_name,kc,&in); while(go && (ret1 = mainMenu(screen,&go,sound_system, player_name, &in)) != -1) { switch(ret1) { case -1: break; case 0: while( (ret4 = menuLevel(screen,level_name,sound_system, player_name, current_player, &go, &nb_lvl, &in)) != -1 && go) { while(play(screen,level_name,sound_system,&go,kc, &in, current_player, player_name, ret4+1, nb_lvl) && go); } break; case 1 : save(screen, "save/.save", player_name, current_player, &go); loadPlayer("save/.save", player_name, current_player); break; case 2 : while((ret = optionMenu(screen,&go,sound_system,kc, &in)) != -1 && go) { switch(ret) { case -1: break; case 0: soundOptions(screen,&go,sound_system, &in); break; case 1: keyBoardOptions(screen,&go,kc,&in,player_name); break; default:; } } break; case 3 : deletePlayer(screen, "save/players", player_name); go = 0; break; default: ; } } go = 1; break; default : ; } } } SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,255,255,255)); //clear screen SDL_Flip(screen); } freeSound(sound_system); free((void*)current_player); freeInput(&in); SDL_Quit(); return EXIT_SUCCESS; }
void TeamHistoryManager::idle(U32 timeDelta) { for(S32 i = 0; i < mTimers.size(); i++) if(mTimers[i].update(timeDelta)) deletePlayer(i); }