int main(void) { setEnvironment(); setOutput(); setScoreboard(); while(1) { setRaceMode(); PLAYER ppp[numOfPlayers]; setPlayer(&ppp, 0, STARTING_POSITION_X, 18, '1', 65, 66, 67, 68); setPlayer(&ppp, 1, STARTING_POSITION_X, 20, '2', 119, 115, 100, 97); players = &ppp; redrawScreen(); splashScreen(); countdown(); setStartTime(&ppp); char c; while (!weHaveAWinner(&ppp)) { c = getc(stdin); checkMove(c, &ppp); } printWins(); checkeredFlag(); waitForEnter(); } return EXIT_SUCCESS; }
/* * a hálózat állapotát adja meg */ void GameControl::onNetworkEvent(bool success) { if (AstrOWar::GameModelSingleton.isYourNext()) setPlayer(0); else setPlayer(1); }
void test_set_player(){ point_type pt = newPoint(0,0); //test player 1 option setPlayer(&pt, PLAYER_ONE); assert_int_equal(PLAYER_ONE, getPlayer(&pt)); //test player 2 option setPlayer(&pt, PLAYER_TWO); assert_int_equal(PLAYER_TWO, getPlayer(&pt)); }
// overloaded createScene to pass in player cocos2d::Scene* DormScene::createScene(PlayerModel inplayer) { // 'scene' is an autorelease object auto scene = Scene::create(); // 'layer' is an autorelease object auto layer = DormScene::create(inplayer); layer->setName("dorm"); // add layer as a child to scene scene->addChild(layer); pm = inplayer; pm.setStats(inplayer.getStats()); layer->setHUDScene(scene); layer->setPlayer(inplayer); // create the HUD HUDLayer::createHUD(scene); HUDLayer::setPlayer(inplayer); HUDLayer::updateHUD(pm); // load the character Movement::loadSpriteFrames(scene); // return the scene return scene; }
void Client::login(const QString& login, const QString& mdp) { QSqlQuery query; query.prepare("SELECT id FROM user WHERE pseudo = :login AND mdp = :mdp"); query.bindValue(":login", login); query.bindValue(":mdp", mdp); if(!query.exec()) { qDebug() << "impossible d'executer la requete de login" << query.lastError().text(); send(Message::LoginFailure("Erreur serveur")); return; } if(query.size() != 1) { send(Message::LoginFailure("Informations de login incorrectes")); return; } setPseudo(login); query.first(); setId(query.value(0).toULongLong()); setPlayer(DataAccessor::getPlayer(id())); send(Message::LoginSuccess(id())); }
//--------------------------------------------------------------------------- bool ofVideoPlayer::loadMovie(string name){ //#ifndef TARGET_ANDROID if( player == NULL ){ setPlayer( ofPtr<OF_VID_PLAYER_TYPE>(new OF_VID_PLAYER_TYPE) ); player->setPixelFormat(internalPixelFormat); } //#endif bool bOk = player->loadMovie(name); width = player->getWidth(); height = player->getHeight(); if( bOk){ moviePath = name; if(bUseTexture ){ if(width!=0 && height!=0) { tex.allocate(width, height, ofGetGLInternalFormatFromPixelFormat(internalPixelFormat)); if(ofGetGLProgrammableRenderer() && internalPixelFormat == OF_PIXELS_MONO){ tex.setRGToRGBASwizzles(true); } } } } return bOk; }
void GameObject::serialize( GameSerializer &s ) { int x = m.x, y = m.y, z = m.z, pl = m.pl; s + m.hp + pl + x + y + z; // m.hp = getClass().data.maxHp; if( s.version()<5 ){ x*=4; y*=4; z*=4; } if( s.isReader() ){ setPosition( x, y, z ); setPlayer( pl ); } view.serialize(s); }
void Level::killCreature(Creature* creature) { removeElement(creatures, creature); getSquare(creature->getPosition())->removeCreature(); model->removeCreature(creature); if (creature->isPlayer()) setPlayer(nullptr); }
void Scenario::setNew(){ reset(); // ensure the seed is populated before anything else is set seed.populate(history); // set the environment to new seed values environment = new Environment(*getSurface(), *getMedium()); // TODO: move mesh into setSurface method for Sprites spriteSeed = SpriteSeed(seed, environment->getSurfaceMesh()); // set light to new seed values light = getLight(); // set surface first, then set the player to new seed values player.setSurface(environment->getSurfaceMesh()); setPlayer(seed); sprites.clear(); setSprites(); // sound.loadMusic(); // sound.playMusic(); }
//--------------------------------------------------------------------------- bool ofVideoPlayer::loadMovie(string name){ if( !player ){ setPlayer( shared_ptr<OF_VID_PLAYER_TYPE>(new OF_VID_PLAYER_TYPE) ); player->setPixelFormat(internalPixelFormat); } bool bOk = player->loadMovie(name); width = player->getWidth(); height = player->getHeight(); if( bOk){ moviePath = name; if(bUseTexture){ if(player->getTexture()==NULL){ if(width!=0 && height!=0) { tex.resize(max(player->getPixels().getNumPlanes(),1)); for(int i=0;i<player->getPixels().getNumPlanes();i++){ ofPixels plane = player->getPixels().getPlane(i); tex[i].allocate(plane); if(ofGetGLProgrammableRenderer() && plane.getPixelFormat() == OF_PIXELS_GRAY){ tex[i].setRGToRGBASwizzles(true); } } } }else{ playerTex = player->getTexture(); } } } return bOk; }
int MusicPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updateTime((*reinterpret_cast< qint64(*)>(_a[1]))); break; case 1: playOrpause(); break; case 2: openFile(); break; case 3: setMod(); break; case 4: previousSong(); break; case 5: nextSong(); break; case 6: whatiLike(); break; case 7: showLrc(); break; case 8: setPlayer(); break; case 9: showPlayList(); break; case 10: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break; case 11: tableWidgetClicked((*reinterpret_cast< int(*)>(_a[1]))); break; case 12: aboutToFinish(); break; case 13: clearSources(); break; case 14: saveAndQuit(); break; case 15: trayIconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; default: ; } _id -= 16; } return _id; }
//executes move if it is valid. Returns false and does not update Alex_Ayerdi otherwise //Makes computer make its move and returns the computer's move in row, and col bool Alex_Ayerdi::play_square(int &row, int &col){ int blackplayer = 1; int whiteplayer = -1; if (row == 0 && col == 0) { setPlayer(blackplayer); } else { if (player == blackplayer) play_square(row, col, whiteplayer); if (player == whiteplayer) play_square(row, col, blackplayer); } //generate your own move if(full_board()) { row = -1; col = -1; return false; } else { cout << toString() << "..." << endl; vector<int> cell; this->reset_tries(); if (!has_valid_move(player)) { cout << "Alex_Ayerdi must pass." << endl; row = -1; col = -1; return false; } else { int alphaStart = -INFINITY; int betaStart = INFINITY; //generate move make_minimax_alphabeta_cpu_move(this, player, cell, alphaStart, betaStart); //play move if (!play_square(cell[0], cell[1], player)) { row = -1; col = -1; return false; } //pass to opposing player row = cell[0]; col = cell[1]; } cout << toString(); } return true; }
Window::Window(QWidget *parent):QWidget(parent) { //init window styles setWindowTitle(tr("media-player")); UI(); setPlayer(); connection(); }
Character::Character() { name = ""; charType = ""; inPlay = true; setBattlePoints(0); setPlayer(""); }
//游戏初始化 void gameInit() { initgraph(LENGTH, WIDTH); setcolor(FGCLR); setbkcolor(BKCLR); setfillstyle(FGCLR, SOLID_FILL); BeginBatchDraw(); setfont(25, 0, "华文行楷"); setbkmode(TRANSPARENT); cleardevice(); loadimage(&bkImg, BKIMG, LENGTH, WIDTH); putimage(0, 0, &bkImg); srand((unsigned)time(NULL));//初始化种子 setPlayer(1, "player1", 0, createPt(160, 0), createBlk(), true, createPt(10, 10)); setPlayer(2, "player2", 0, createPt(400, 0), createBlk(), true, createPt(10, 240)); drawStageLine(); }
void GameControl::onBattleStart() { mPhase = GP_BATTLE; mShipNumbers = mInitShipNumbers; if (mListener) mListener->onBattleStart(); setPlayer(mPlayer); }
//--------------------------------------------------------------------------- void ofVideoPlayer::loadAsync(string name){ if( !player ){ setPlayer( shared_ptr<OF_VID_PLAYER_TYPE>(new OF_VID_PLAYER_TYPE) ); player->setPixelFormat(internalPixelFormat); } player->loadAsync(name); moviePath = name; }
//-------------------------------------------------------------------- void ofSoundPlayer_::loadSound(string fileName, bool stream){ if( player == NULL ){ setPlayer( new OF_SOUND_PLAYER_TYPE ); } if( player != NULL ){ player->loadSound(fileName, stream); } }
void refreshTileMap(Game* g) { memset(g->doors, 0, g->doorArraySize * sizeof(door)); memset(g->enemies, 0, g->enemyArraySize * sizeof(enemy)); memset(g->gameKeys, 0, g->keyArraySize * sizeof(key)); memset(g->shots, 0, g->shotArraySize * sizeof(shot)); memset(&g->player1, 0, sizeof(player)); memset(&g->stairs, 0, sizeof(stair)); Tile* t; for (int i = 0; i < TILEMAPSIDE; i++) { for (int j = 0; j < TILEMAPSIDE; j++) { t = &g->tileMaps[0].tiles[i][j]; switch (t->tileID) { case Tile::FLOOR: t->filled = FALSE; t->texID = g->floorTex; break; case Tile::WALL: t->filled = TRUE; t->texID = g->wallTex; break; case Tile::ENEMY_FLOOR: t->filled = false; t->texID = g->floorTex; //enemy spawn addEnemy(g, TILESIDE*(j + 0.5), TILESIDE*(i + 0.5), g->enemyTex); break; case Tile::PLAYER_FLOOR: t->filled = false; t->texID = g->floorTex; //player spawn setPlayer(g, TILESIDE*(j + 0.5) , TILESIDE*(i + 0.5), g->playerTex); break; case Tile::STAIR: t->filled = false; t->texID = g->floorTex; setStair(g, TILESIDE*(j + 0.5), TILESIDE*(i + 0.5), g->stairTex); break; case Tile::DOOR: t->filled = false; t->texID = g->floorTex; addDoor(g, TILESIDE*(j + 0.5), TILESIDE*(i + 0.5), g->doorTex); break; } } } printf(""); }
int main(int argc, char **argv) { srand(time(0)); Player *white = setPlayer("UPPER CASE (White)"); Player *black = setPlayer("lower case (Black)"); HumanPlayer *p = new HumanPlayer(0); RandomPlayer *r = new RandomPlayer(0); Game *g = new Game(white, black); white->setGame(g); black->setGame(g); g->setUp(); bool whiteWins = g->play(); cout << (whiteWins? "Upper" : "Lower") << " case wins." << endl; Board *b = g->getBoard(); cout << *b; delete g; return 0; }
/******************************************************************************* * 関数定義 ******************************************************************************/ int main(int argc, char *argv[]) { struct World world; int result; initWorld(&world); // 世界の初期化(パーツ・コマンドリスト生成など) setPlayer(&world); // プレイヤの受付とモンスターの生成 do(judgment(&world, &result) != GAMEOVER) { // 終了判定 setCommand(&world); // 各プレイヤからコマンドを受け付ける runAttack(&world); // コマンドの実行 }
bool ofxTLVideoTrack::load(string moviePath){ ofPtr<ofVideoPlayer> newPlayer = ofPtr<ofVideoPlayer>(new ofVideoPlayer()); if(newPlayer->loadMovie(moviePath)){ setPlayer( newPlayer ); return true; } else { ofLogError("ofxTLVideoTrack::loadMovie -- movie load failed: " + moviePath); } return false; }
// --- // clear() -- clears out the model // --- void OtwModel::clear() { setPlayer(0); state = INACTIVE; ageCount = 0; checked = false; typeMapper = 0; rcount = 0; hotActive = false; playerID = 0; federateName = 0; }
// on "init" you need to initialize your instance bool Level01::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } m_visibleSize = Director::getInstance()->getVisibleSize(); m_floorPoint = m_visibleSize.height / 4.6; Point origin = Director::getInstance()->getVisibleOrigin(); auto wall = DrawNode::create(); wall->drawSolidRect(Vec2(0, 0), Vec2(m_visibleSize.width, m_visibleSize.height), Color4F::GRAY); this->addChild(wall); setPlayer(); setBG(); animCache(); auto shade = DrawNode::create(); shade->drawSolidRect(Vec2(0, 0), Vec2(m_visibleSize.width, m_visibleSize.height), Color4F(0, 0, 0, 180)); this->addChild(shade); idle(); eventHandler(); m_enterButton = ui::Button::create("img/button.png"); m_enterButton->setScale(0.6); m_enterButton->setTitleColor(Color3B::WHITE); m_enterButton->setTitleFontName("fonts/ant-maru.ttf"); m_enterButton->setTitleFontSize(45); m_enterButton->setTitleText("入る"); m_enterButton->setVisible(false); m_enterButton->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height / 10)); this->addChild(m_enterButton); m_sadmanMsg = ui::Button::create("img/button.png"); m_sadmanMsg->setScale(1); m_sadmanMsg->setTitleColor(Color3B::WHITE); m_sadmanMsg->setTitleFontName("fonts/ant-maru.ttf"); m_sadmanMsg->setTitleFontSize(26); m_sadmanMsg->setTitleText("トナリノヘアガアカルクテ"); m_sadmanMsg->setVisible(false); m_sadmanMsg->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height / 10)); m_sadmanMsg->setEnabled(false); this->addChild(m_sadmanMsg); this->scheduleUpdate(); return true; }
static void regCallback(SubLevel* subLevel_p, const sf::Vector2f& position, const boost::property_tree::ptree& pt) { //create entities auto player = std::shared_ptr<Player>(new Player(sf::FloatRect(position.x, position.y, 0, 0), pt.get<int>("properties.lightlevel", 3),!pt.get<bool>("properties.startdisabled", false) ) ); auto camera = std::shared_ptr<Camera>(new Camera(player)); auto display = std::shared_ptr<InventoryDisplay>(new InventoryDisplay( std::static_pointer_cast<Player>(player) )); auto level_p = subLevel_p->getLevel(); level_p->setPlayer(player); level_p->setCamera(camera); level_p->setInventoryDisplay(display); }
void Game::start(){ // clean scene scene->clear(); // set background of game game->setBackgroundBrush(QBrush(QImage("E:\\game\\sprites\\back.png"))); // set player setPlayer(); }
Geoscape::Geoscape(Career* career) { _career = career; _endOfActivity = false; _requestedActivity = NULL; _passedTime = 0.0f; _blinkingTime = 0.0f; // create geoscape window _geoscape = Gameplay::iGui->createWindow( "Geoscape" ); assert( _geoscape ); _geoscape->getPanel()->setRenderCallback( panelRenderCallback, this ); _moveMap = false; _lastPosIsValid = false; _lastX = _lastY = 0; _currX = _currY = 0; _geoscapeMode = NULL; // create locations if( _career->isHomeDefined() ) { Location* homeLocation = new Location( this, 0 ); _locations.push_back( homeLocation ); if( _career->getHomePlacementFlag() ) { homeLocation->setPlayer( true ); _career->setHomePlacementFlag( false ); } } for( unsigned int i=1; i<database::LocationInfo::getNumRecords(); i++ ) { _locations.push_back( new Location( this, i ) ); } // make market offers for( unsigned int i=0; i<125; i++ ) { Gear marketOffer = generateGear( getCore()->getRandToolkit()->getUniform( 0, 1 ) > 0.75f ); if( marketOffer.isTradeable() ) addGearToMarket( marketOffer ); } // MULTIVERSION ISSUE � // if player is in inaccessible location if( _career->isHomeDefined() ) { Location* location = getPlayerLocation(); if( location && !database::LocationInfo::getRecord( location->getDatabaseId() )->accessible ) { // move player to the dropzone location->setPlayer( false ); getLocation( unsigned int( 0 ) )->setPlayer( true ); }
cGame::cGame(cBiota *pbiota) { delete _pbiota; //Get rid of the cBiota* that the default constructor gave you. _pbiota = NULL; _pbiota = pbiota; _pbiota->setGame(this); //Deleting the _pbiota killed off your _pplayer, so you need to get a new one. if (_pbiota->GetSize()>0) // use the first member of pbiota if there is one. _pplayer = _pbiota->GetAt(0); else //otherwise make a dummy. { cCritter* pdummyplayer = new cCritter(); setPlayer(pdummyplayer); } }
//--------------------------------------------------------------------------- bool ofVideoPlayerAdapt::loadMovie(string name){ if( player == NULL ){ } setPlayer( ofPtr<OF_VID_PLAYER_TYPE>(new OF_VID_PLAYER_TYPE) ); player->setPixelFormat(internalPixelFormat); bool bOk = player->loadMovie(name); width = player->getWidth(); height = player->getHeight(); if( bOk && bUseTexture ) if(width!=0 && height!=0) tex.allocate(width, height, GL_RGB); return bOk; }
void Nib::deleteData() { setPlayer(nullptr); setNetIO(nullptr); setTypeMapper(nullptr); // Clear attached missiles for (unsigned int i = 0; i < MAX_AMSL; i++) { if (apartMsl[i] != nullptr) { apartMsl[i]->unref(); apartMsl[i] = nullptr; apartMslCnt[i] = 0; apartMslAttached[i] = false; } } apartNumMissiles = 0; }