/* * === FUNCTION ====================================================================== * Name: main * Description: * ===================================================================================== */ int main ( int argc, char *argv[] ) { int port1, port2; /* Check for error in input */ if ( argc < 4 || argc > MAX_PLAYERS + 2 ) { printf("Usage: %s N port1 port2 [port3 ... port%d] \n", argv[0], MAX_PLAYERS); printf(" N: Number of turns\n"); printf(" portn: Port for player\n"); exit(1); } /* Seed the random */ srand( (unsigned)time(0) ); /* Read ports */ port1 = atoi( argv[1] ); port2 = atoi( argv[2] ); /* Init Players */ initPlayers( argc - 2, argv ); /* Init Graphics */ initGraphics( argc, argv ); /* Print Message */ printf("Run all the players with their specific ports and press Enter or click Start."); /* Start the main loop. glutMainLoop never returns */ glutMainLoop( ); /* We should never get here */ return EXIT_SUCCESS; }
//init world init game for a certain level World* World::initWorld(Node* backgroundLayer, Node* actionLayer, Node* HUDnode) { this->backgroundNode = backgroundLayer; this->actionNode = actionLayer; this->hudNode = HUDnode; swiss = NULL; score = 0; CCLOG("Created the world"); //initialize the Pools initSpriteCache(); //initialize all the game objects/entities initCommonComps(); initPools(); initPlayers(); //initialize all the entity runners initRunners(); infoPanel = new InformationPanel(); if (!Config::instance()->debug_mode) {//if debug mode is turned off spawningPool = new ZombieSpawningPool(); if (spawningPool) spawningPool->init(); } destroyFlag = false; return this; }
static int initGame() { int ret = 0; ret = initPlayers(1); if(HX_SERVER_OK != ret) { printf("Errors in initialzing players!\n"); return HX_SERVER_COMMON_ERROR; } return ret; }
/// class MatchReplayScene MatchReplayScene::MatchReplayScene(MatchRecording *const &recording, QObject *const &parent) : QGraphicsScene(parent), recording(recording), controller(recording), projection(computeProjection(1000, 700)) { initPitch(); initScoreboard(); initBall(); initPlayers(); connect(&controller, SIGNAL(frameChanged(MatchSnapshot *const &)), this, SLOT(changeFrame(MatchSnapshot *const &))); }
void Game::initialize(std::string whiteName, int whiteLevel, std::string blackName, int blackLevel) { tearDown(); // Game starts with white players turn board = Board(); activeSquare = -1; initPlayers(whiteName, whiteLevel, blackName, blackLevel); playerOnTurn = white; //whitePlayerText.setString("White: " + white->getName()); //blackPlayerText.setString("Black: " + black->getName()); // To format info text //infoText.setString("Game started!\n" + playerOnTurn->getName() + "'s turn."); timeOffset = 0; //clock.restart(); }
bool GameEngine::initialize() { if (!_context.start(_options->getWidth(), _options->getHeight(), "MadBomberMax")) return (false); glEnable(GL_DEPTH_TEST); AssetsManager::instanciateAssetsManager(); if (!_shader.load("./libgdl/shaders/basic.fp", GL_FRAGMENT_SHADER) || !_shader.load("./libgdl/shaders/basic.vp", GL_VERTEX_SHADER) || !_shader.build()) throw BombermanError::ShaderBuildingFailure("Could not build shader correctly\n"); _shader.bind(); _shader.setUniform("view", _camera.getTransformation()); _shader.setUniform("projection", _camera.getProjection()); initMap(); initBoardAndLimits(); initPlayers(); // initIA(_options->getNbIa()); _bonuses.initialize(); _camera.initialize(&_shader); return (true); }
GameState::GameState(Quoridor& app, std::list<Player> players, const int& boardSize) : State(app), m_subState(SUB_STATE::LOADING), m_board(boardSize), m_players(std::move(players)), m_nbPlayers(m_players.size()), m_nbWallsAtStart((boardSize + 1) / (m_nbPlayers / 2)), m_playerActual(1), m_wallCol(0), m_wallRow(0), m_wallDir(Board::WALL_ORIENTATION::VERTICAL), m_moveChoices(), m_error(), m_loadingEnded(false), m_waitingChoiceAction(false), m_waitingChoiceMove(false), m_waitingChoiceWallCol(false), m_waitingChoiceWallRow(false), m_waitingChoiceWallDir(false), m_waitingChoiceWin(false), m_waitingChoiceDraw(false) { initPlayers(); }
int main() { // INIT COMS cd = (Comm_data*) malloc(sizeof(Comm_data)); uart = init_clear_uart(cd); alt_timestamp_start(); srand(alt_timestamp()); CardCtrl *cardCtrl = (CardCtrl*)malloc(sizeof(CardCtrl)); PlayerCtrl* playerCtrl = (PlayerCtrl*)malloc(sizeof(PlayerCtrl)); initCards(cardCtrl); printf("Waiting for players\n"); while(connected_count < 3) { receivedFromAndroid(); } printf("Got all players\n"); initPlayers(playerCtrl, connected_count); int y; for (y = 0; y < connected_count; y++) { if (pid_connected[y] == 1) { tell_user_pid_role(y, playerCtrl->players[y]); Message message = receivedFromAndroid(); if (message.type == ACKNOWLEDGE); } } int i, j; for (i = 0; i < connected_count; i++) { drawCardsForId(i, cardCtrl, 2, playerCtrl); } field = malloc(sizeof(Field)); alt_up_char_buffer_dev *charBuffer = initCharBuffer(); alt_up_pixel_buffer_dma_dev *pixelBuffer = initPixelBuffer(); initField(field, playerCtrl, cardCtrl, charBuffer); *leds = *switches; alt_timestamp_start(); srand(alt_timestamp()); Message message; tell_user_all_opponent_range_role(playerCtrl->turn, getPlayersInfoForId(playerCtrl, playerCtrl->turn)); message = receivedFromAndroid(); if (message.type == ACKNOWLEDGE); tell_user_all_opponent_blue_lives(playerCtrl->turn, getPlayersInfoForId(playerCtrl, playerCtrl->turn)); message = receivedFromAndroid(); if (message.type == ACKNOWLEDGE); tell_user_their_turn(0); while (1){ int listening = 1; while (listening) { Message message = receivedFromAndroid(); switch (message.type) { case DRAW_CARDS: drawCardsForId(message.fromId, cardCtrl, message.count, playerCtrl); tell_user_ok(message.fromId); break; case UPDATE_HAND: updateHandForId(playerCtrl, message.fromId, message.count, message.cards); break; case UPDATE_BLUE: updateBlueCardsForId(playerCtrl, message.fromId, message.count, message.cards); tell_user_ok(message.fromId); break; case UPDATE_LIVES: updateLivesForId(playerCtrl, message.fromId, message.count); break; case GATLING: startGatling(playerCtrl, message.fromId); tell_user_ok(message.fromId); break; case ALIENS: startAliens(playerCtrl, message.fromId); tell_user_ok(message.fromId); break; case BEER: { //TODO //updateLivesForId(playerCtrl, message.fromId, message.count); Message message = receivedFromAndroid(); if (message.type == UPDATE_LIVES) updateLivesForId(playerCtrl, message.fromId, message.count); updateHand(message.fromId, playerCtrl); break; } case GENERAL_STORE: startStore(playerCtrl, message.fromId, cardCtrl); break; case SALOON: startSaloon(playerCtrl, message.fromId); tell_user_ok(message.fromId); break; case ZAP: { startZap(playerCtrl, message.toId, message.fromId, message.self); if (message.self == 0) { tell_user_ok(message.fromId); } break; } case PANIC: startPanic(playerCtrl, message.toId, message.fromId, message.self); if (message.self == 0) { tell_user_ok(message.fromId); } break; case CAT_BALOU: startCatBalou(playerCtrl, message.toId, message.fromId, message.self); if (message.self == 0) { tell_user_ok(message.fromId); } break; case DUEL: startDuel(playerCtrl, message.toId, message.fromId, message.self); if (message.self == 0) { tell_user_ok(message.fromId); } break; case JAIL: //TODO tell_user_jail(message.toId, message.cards); break; case END_TURN: listening = 0; break; default: break; } alt_up_char_buffer_clear(charBuffer); runField(field, isGameEnd, winningPlayer); } endTurn(playerCtrl); tell_user_all_opponent_range_role(playerCtrl->turn, getPlayersInfoForId(playerCtrl, playerCtrl->turn)); message = receivedFromAndroid(); if (message.type == ACKNOWLEDGE); tell_user_all_opponent_blue_lives(playerCtrl->turn, getPlayersInfoForId(playerCtrl, playerCtrl->turn)); message = receivedFromAndroid(); if (message.type == ACKNOWLEDGE); int y; for (y = 0; y < MAX_CARDS; y++ ) { if (playerCtrl->players[playerCtrl->turn].blueCards[y] >= 72 && playerCtrl->players[playerCtrl->turn].blueCards[y] <= 74) { drawCardsForId(playerCtrl->turn, cardCtrl, 1, playerCtrl); break; } } tell_user_their_turn(playerCtrl->turn); alt_up_char_buffer_clear(charBuffer); runField(field, isGameEnd, winningPlayer); } return 0; }
Game::Game(int x, int y) { initPlayers(); field = Field(x,y); }
Game::Game(){ initPlayers(); //Field //field = Field() Automatically... }