bool CPlayGameVorticon::init() { CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Assure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. g_pTimer->ResetSecondsTimer(); g_pInput->flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, m_NumPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode has reached verifyFinales(); // When Level starts it's never dark! g_pGfxEngine->Palette.setdark(false); if(m_level_command == GOTO_FINALE) createFinale(); else if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
bool CPlayGameVorticon::init() { CMapLoader MapLoader( &m_Map, &m_Player ); MapLoader.m_checkpointset = m_checkpointset; MapLoader.mp_objvect = &m_Object; m_Map.m_Difficulty = m_Difficulty; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; m_SavedGame.setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map m_Map.drawAll(); // Now Scroll to the position of the player and center him m_Map.gotoPos( 32, 64 ); // Assure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. g_pTimer->ResetSecondsTimer(); g_pInput->flushAll(); // Initialize the AI mp_ObjectAI = new CObjectAI(&m_Map, m_Object, m_Player, m_NumPlayers, m_Episode, m_Level, m_Difficulty, m_Map.m_Dark); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode has reached verifyFinales(); // When Level starts it's never dark! g_pGfxEngine->Palette.setdark(false); if(m_level_command == GOTO_FINALE) createFinale(); else if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); m_MessageBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
void ServerWidget::openFile(int row) { QTableWidgetItem *item = filesTable->item(row, 0); QString filename(currentDir.absoluteFilePath(item->text())); qDebug() << "ServerWidget::openFile() : " << filename; QMetaObject::invokeMethod(server, "setupGame", Qt::DirectConnection, Q_ARG(QString, filename)); // server->setupGame(filename); QStringList roles; QMetaObject::invokeMethod(server, "getRoles", Qt::DirectConnection, Q_RETURN_ARG(QStringList, roles)); // QStringList roles = server->getRoles(); debug("Nb roles : ", QString::number(roles.size())); nbRoles = roles.size(); setupPlayers(roles); }
bool CPlayGameVorticon::init() { const GsRect<Uint16> gameRect = gVideoDriver.getVidConfig().m_GameRect; gVideoDriver.setNativeResolution(gameRect); // Create the special merge effect (Fadeout) CColorMerge *pColorMergeFX = new CColorMerge(8); gEffectController.setupEffect(pColorMergeFX); CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; const int numPlayers = g_pBehaviorEngine->mPlayers; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); mMap->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Ensure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. gTimer.ResetSecondsTimer(); gInput.flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, numPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode is reached verifyFinales(); // When Level starts it's never dark! gGraphics.Palette.setdark(false); const std::string finaleStr = gArgs.getValue("finale"); if(finaleStr == "on") { createFinale(); gArgs.removeTag("finale"); } if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
int main(void) { int linesInPropertyFile = 0; struct property **arrayForProperties = 0; struct player **arrayForPlayers = 0; int totalLinesInPropFile = 0; int amntPlayers = 0; int *cornerPositions = malloc(sizeof(int) * SIDES); //Open /dev/urandom for rollDice FILE *propertyFile = fopen("/home/jordan/Documents/Programming/Monopoly Project/properties","rb"); if(propertyFile == NULL) { puts("ERROR: error in opening file(s)"); return 1; } linesInPropertyFile = amountOfLines(propertyFile,&totalLinesInPropFile); /*//DEBUG printf("%d is contained within \"linesInPropertyFile\"\n",linesInPropertyFile);*/ if(createArrayOfPtrs(linesInPropertyFile,(void ***)&arrayForProperties)) { puts("ERROR: error from createArrayOfPointers() :: non-zero returned"); return 1; } /*//DEBUG printf("Outside Pointer: %p\n",arrayForProperties);*/ if(makeArryOfPropertyPtrs(linesInPropertyFile,arrayForProperties)) { puts("ERROR: error from createArrayOfPointersForProperties() :: non-zero returned"); return 1; } if(FillArryPropertyData(arrayForProperties,linesInPropertyFile,propertyFile)) { puts("ERROR: error from FillArryPropertyData() :: non-zero returned"); } if(setupTmpPropertyNames(arrayForProperties,linesInPropertyFile)) { puts("ERROR: error from setupTmpPropertyNames() :: non-zero returned"); } if(setupPlayers(&arrayForPlayers,&amntPlayers)) { puts("ERROR: error from setupPlayers() :: non-zero returned"); } setFourCorners(linesInPropertyFile,cornerPositions); addCorners(linesInPropertyFile,cornerPositions,&arrayForProperties); //Set up GrahicalLoop thread. pthread_t glThread; volatile int isRunning = 1; void* data[4]; data[0] = (void*)arrayForProperties; data[1] = (void*)arrayForPlayers; data[2] = (void*)&linesInPropertyFile; data[3] = (void*)&isRunning; pthread_create(&glThread,NULL,graphicalMain,(void *)data); if(gameLoop(arrayForProperties,arrayForPlayers,linesInPropertyFile,amntPlayers,cornerPositions,&isRunning)) { puts("ERROR: error from gameLoop() :: non-zero returned"); } //DEBUG /*printf("array: %p\n",arrayForProperties); printf("*array: %p\n",*arrayForProperties); printf("Lines W/O comments: %d Total lines comments: %d\n\n",linesInPropertyFile,totalLinesInPropFile); int i = 0; for(i = 0;i < 4;i++) { printf("CORNER POSITION #%d: %d\n",i,cornerPositions[i]); } for(i = 0;i < linesInPropertyFile;i++) { printf("NAME: %s\n",(arrayForProperties[i])->name); printf("MONEY: %d\n",(arrayForProperties[i])->value); } puts(""); for(i = 0;i < amntPlayers;i++) { printf("NAME: %s\n",(arrayForPlayers[i])->id); printf("MONEY: %d\n",(arrayForPlayers[i])->money); }*/ //free allocated memory int i = 0; for(i = 0;i < linesInPropertyFile + SIDES;i++) { if((arrayForProperties[i])->type != 1) { free((arrayForProperties[i])->name); } free(arrayForProperties[i]); } free(arrayForProperties); for(i = 0;i < amntPlayers;i++) { free((arrayForPlayers[i])->id); free(arrayForPlayers[i]); } free(arrayForPlayers); //Close FILE stream for /dev/urandom fclose(propertyFile); return 0; }
/////////////////////////// // Game State Management // /////////////////////////// bool CPlayGameVorticon::loadGameState() { CSaveGameController &savedGame = *(gpSaveGameController); // This fills the datablock from CSavedGame object if(savedGame.load()) { // Create the special merge effect (Fadeout) CColorMerge *pColorMergeFX = new CColorMerge(8); // Prepare for loading the new level map and the players. cleanup(); // get the episode, level and difficulty char newLevel; savedGame.decodeData(m_Episode); savedGame.decodeData(newLevel); bool loadmusic = ( m_Level != newLevel || m_Level == 80 ); m_Level = newLevel; savedGame.decodeData(g_pBehaviorEngine->mDifficulty); bool dark, checkpointset; int checkx, checky; savedGame.decodeData(checkpointset); savedGame.decodeData(checkx); savedGame.decodeData(checky); savedGame.decodeData(dark); // Load number of Players savedGame.decodeData(m_NumPlayers); if(!m_Player.empty()) m_Player.clear(); m_Player.assign(m_NumPlayers, CPlayer(m_Episode, m_Level, mp_level_completed, *mMap.get() ) ); for( size_t i=0 ; i < m_Player.size() ; i++ ) { m_Player.at(i).m_index = i; m_Player.at(i).setDatatoZero(); } CVorticonMapLoaderWithPlayer Maploader(mMap, m_Player, mSpriteObjectContainer); m_checkpointset = checkpointset; Maploader.m_checkpointset = m_checkpointset; if(!Maploader.load(m_Episode, m_Level, m_Gamepath, loadmusic, false)) return false; m_checkpoint_x = checkx; m_checkpoint_y = checky; m_level_command = START_LEVEL; std::vector<CPlayer> :: iterator player; for( player=m_Player.begin() ; player != m_Player.end() ; player++ ) { int x, y; player->setupforLevelPlay(); savedGame.decodeData(x); savedGame.decodeData(y); player->moveToForce(VectorD2<int>(x,y)); savedGame.decodeData(player->blockedd); savedGame.decodeData(player->blockedu); savedGame.decodeData(player->blockedl); savedGame.decodeData(player->blockedr); savedGame.decodeData(player->inventory); player->pdie = 0; } // load the number of objects on screen Uint32 size; savedGame.decodeData(size); for( Uint32 i=0 ; i<size ; i++ ) { unsigned int x,y; if(i >= mSpriteObjectContainer.size()) { std::unique_ptr<CVorticonSpriteObject> object( new CVorticonSpriteObject( mMap.get(), 0, 0, OBJ_NONE) ); object->exists = false; mSpriteObjectContainer.push_back(move(object)); } CVorticonSpriteObject &object = *(mSpriteObjectContainer.at(i)); savedGame.decodeData(object.m_type); savedGame.decodeData(x); savedGame.decodeData(y); object.moveToForce(VectorD2<int>(x,y)); savedGame.decodeData(object.dead); savedGame.decodeData(object.onscreen); savedGame.decodeData(object.hasbeenonscreen); savedGame.decodeData(object.exists); savedGame.decodeData(object.blockedd); savedGame.decodeData(object.blockedu); savedGame.decodeData(object.blockedl); savedGame.decodeData(object.blockedr); savedGame.decodeData(object.mHealthPoints); savedGame.decodeData(object.canbezapped); savedGame.decodeData(object.cansupportplayer); savedGame.decodeData(object.inhibitfall); savedGame.decodeData(object.honorPriority); savedGame.decodeData(object.sprite); object.performCollisions(); if(object.m_type == OBJ_DOOR or object.m_type == OBJ_RAY or object.m_type == OBJ_SNDWAVE or object.m_type == OBJ_FIREBALL or object.m_type == OBJ_ICECHUNK or object.m_type == OBJ_ICEBIT or object.m_type == OBJ_GOTPOINTS or object.m_type == OBJ_ANKHSHIELD) // Some objects are really not needed. So don't load them object.exists = false; } // TODO: An algorithm for comparing the number of players saved and we actually have need to be in sync // Load the map_data as it was left last savedGame.decodeData(mMap->m_width); savedGame.decodeData(mMap->m_height); savedGame.readDataBlock( reinterpret_cast<byte*>(mMap->getForegroundData()) ); // Load completed levels savedGame.readDataBlock( (byte*)(mp_level_completed) ); m_Player[0].setMapData(mMap.get()); m_Player[0].setupCameraObject(); m_Player[0].mpCamera->attachObject(&m_Player[0]); while(m_Player[0].mpCamera->m_moving) { m_Player[0].mpCamera->process(); m_Player[0].mpCamera->processEvents(); } mMap->drawAll(); // Create the special merge effect (Fadeout) g_pGfxEngine->setupEffect(pColorMergeFX); mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, m_NumPlayers, m_Episode, m_Level, mMap->m_Dark) ); setupPlayers(); mMap->m_Dark = dark; g_pGfxEngine->Palette.setdark(mMap->m_Dark); return true; } return false; }