LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch ( message ) { case WM_CREATE: { RECT wantRect = { 0, 0, GameManager::RESOLUTION_X, GameManager::RESOLUTION_Y }; AdjustWindowRect(&wantRect, WS_CAPTION | WS_SYSMENU, false); MoveWindow(hWnd, 0, 0, wantRect.right - wantRect.left, wantRect.bottom - wantRect.top, true); } break; case WM_DESTROY: g_GameManager.Destroy(); PostQuitMessage(0); break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MOUSEMOVE: case WM_MOUSEWHEEL: g_GameManager.GameInputProc(hWnd, message, wParam, lParam); break; break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
int main(int argc, char **argv) { GameManager * GM; std::vector<std::string>lib; if (argc > 6 || argc < 4) { std::cout << "usage: ./nibbler height width library [library [library] ]" << std::endl; return -1; } try { srand(time(NULL)); Vector2 size = Vector2(atoi(argv[1]), atoi(argv[2])); if (size._x < 20 || size._x > 50 || size._y < 20 || size._y > 50) { std::cout << "size is not correct, es soll zwischen 20 und 50 sein" << std::endl; return -1; } for (int i = 3; i < argc ; i++) lib.push_back(argv[i]); GM = new GameManager(1, size, lib); GM->Update(); delete GM; } catch (std::exception & e) { std::cout << "Nibbler : " << e.what() << std::endl; } return (0); }
int main () { GameManager* game = new GameManager(); IntroState* introState = new IntroState(); PlayState* playState = new PlayState(); PauseState* pauseState = new PauseState(); UNUSED_VARIABLE(introState); UNUSED_VARIABLE(playState); UNUSED_VARIABLE(pauseState); try { // Inicializa el juego y transición al primer estado. game->start(IntroState::getSingletonPtr()); } catch (Ogre::Exception& e) { std::cerr << "Excepción detectada: " << e.getFullDescription(); } delete game; return 0; }
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { ChangeWindowMode(TRUE); DxLib_Init(); SetDrawScreen(DX_SCREEN_BACK); int handle = LoadGraph("image/backGround.png"); GameManager *gameMgr; gameMgr = new GameManager(); /*初期化処理*/ gameMgr->initialize(); while (!ProcessMessage() && !ScreenFlip() && !ClearDrawScreen()) { /*キーボードアップデート*/ KeyboardInput::Instance()->update(); if (KeyboardInput::Instance()->get(KEY_INPUT_ESCAPE) == 1){ break; } DrawGraph(0, 0, handle, FALSE); /*メイン処理*/ gameMgr->execute(); } /*終了処理*/ gameMgr->finalize(); delete gameMgr; DxLib_End(); return 0; }
int main(int argc, char *argv[]) #endif { srand((unsigned int)time(NULL)); if (AllocConsole()) { freopen("CONIN$", "rb", stdin); freopen("CONOUT$", "wb", stdout); freopen("CONOUT$", "wb", stderr); std::ios::sync_with_stdio(); } GameManager game; try { game.init(); game.changeState(TitleState::getInstance()); game.go(); } catch( Ogre::Exception& e ) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); #else std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl; #endif } return 0; }
/** * Adds an Object to the area. * @param object The Object's pointer. * @see removeObject() */ void Area::addObject(Object* object) { //object->setArea(this); DEBUG_M("Entering function..."); GameManager* gm = getGameManager(); if(object->getGameManager() != gm) { DEBUG_A("Different GameMangers..."); object->setGameManager(gm); if(gm) { DEBUG_A("Registering object with gamemanager..."); gm->registerObject(object); } } RigidBody* rb = dynamic_cast<RigidBody*>(object); if(rb) { rb->addBody(getPhysics()); } Light* pl = dynamic_cast<Light*>(object); if(pl) { lights_.push_back(pl); } addChild(object); }
uShort timer_gameManagerProcess(timer* t, uLong ms) { GameManager* g = (GameManager*)t->userData; ASSERT(g); g->Process(ms); return TIMER_CONTINUE; }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ) { #ifdef _DEBUG ChangeWindowMode( TRUE ); //ウィンドウ起動 #endif //フルスクリーンにするか /*int YN = MessageBox(NULL,"フルスクリーンで起動しますか?","ウィンドウサイズの設定",MB_YESNO); if(YN != IDYES )ChangeWindowMode(TRUE);*/ //多重起動をできないようにする SetDoubleStartValidFlag(FALSE); SetGraphMode( 800 , 600 , 16 ) ; if( DxLib_Init() == -1 ){ return -1 ; } // DXライブラリ初期化処理 while( ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == FALSE) { //ゲームマネージャー GameManager* GameMain = new GameManager(); //メイン GameMain->Menu(); GameMain->Run(); delete GameMain; } DxLib_End(); // DXライブラリ使用の終了処理 return 0; // ソフトの終了 }
int main( int argc, char** argv ) { Actor** actors = (Actor**) malloc(10 * sizeof(Actor*)); actors[0] = new simplehero(ACTOR_HERO); actors[1] = new SmartHero(ACTOR_HERO); actors[2] = new SmartEnemy(ACTOR_ENEMY); actors[3] = new SmartPowerup(ACTOR_POWERUP); int num_actors = 4; GameManager* manager = new GameManager(argc, argv, actors, num_actors); manager->addActor(new Actor(ACTOR_HERO)); manager->play(); delete manager; manager = 0; for ( int i = 0; i < num_actors; i++ ) { delete actors[i]; } free(actors); actors = 0; return 0; }
void RotateObjects::apply() { GameManager* gameManager = selection->getGameManager(); list<unsigned int>::iterator sprite = spritesToRotate.begin(); list<Vec2>::iterator posIt = startingSpritePositions.begin(); list<float>::iterator rotIt = startingSpriteRotations.begin(); for (; sprite != spritesToRotate.end(); ++sprite, ++posIt, ++rotIt) { if (absoluteRotation) { ((SpriteObject*)gameManager->getObject(*sprite))->setRotation(angle); } else { Vec2 newPosition = vectorRot2D((*posIt), rotationCenter, angle); ((SpriteObject*)gameManager->getObject(*sprite))->setPosition(newPosition.x, newPosition.y); ((SpriteObject*)gameManager->getObject(*sprite))->setRotation((*rotIt) + angle); } } SharedTriangleData* sharedTriangleData = selection->getSharedTriangleData(); unordered_map<unsigned int, unsigned int>::iterator vertex = verticesToRotate.begin(); posIt = startingVertexPositions.begin(); for (; vertex != verticesToRotate.end(); ++vertex, ++posIt) { Vec2 newPosition = vectorRot2D((*posIt), rotationCenter, angle); sharedTriangleData->setSharedVertexPosition(vertex->first, newPosition.x, newPosition.y); } selection->updateSelection(); selection->updateProperties(); }
bool SuccessScene::init() { if(!Scene::init()) return false; Size size = Director::getInstance()->getWinSize(); GameManager* instance = GameManager::getInstance(); instance->clear(); Sprite* sprite = Sprite::create("Plain.png"); sprite->setPosition(Point(size.width / 2, size.height / 2)); this->addChild(sprite, -1); Sprite* nextNormal = Sprite::createWithSpriteFrameName("btnNext.png"); Sprite* nextOver = Sprite::createWithSpriteFrameName("btnNextOver.png"); MenuItemSprite* nextItem = MenuItemSprite::create(nextNormal, nextOver, CC_CALLBACK_1(SuccessScene::menuNextCallback, this)); Sprite* backNormal = Sprite::createWithSpriteFrameName("btnBack.png"); Sprite* backOver = Sprite::createWithSpriteFrameName("btnBackOver.png"); MenuItemSprite* backItem = MenuItemSprite::create(backNormal, backOver, CC_CALLBACK_1(SuccessScene::menuCloseCallback, this)); Menu* menu = Menu::create(backItem, nextItem, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(size.width / 2, size.height / 2)); this->addChild(menu); return true; }
void ComponentMiniMap::update() { //Reparte los updates por varios frames para que no se los tenga que comer todos un frame y //se note una bajada de rendimiento cada vez que le toque actualizar a todos los sprites //Solo entraria durante los primeros updates //Va retrasando el reloj cada frame mientras siga quedando delay if(delay > 0) { delay--; clock.restart(); return; } if(clock.getElapsedTime() >= 1000/REFRESH_RATE) { GameManager* gameManager = GameManager::getInstance(); //Es mas sencillo trabajar con posiciones en el grid que en coordenadas asi para ajustar en el minimapa Vector2d positionOnGrid = gameManager->getMapManager()->getFrame(parent->position); positionOnGrid = Vector2d(positionOnGrid.y, positionOnGrid.x); //CAmbiar para que salga el objeto en el centro de la posicion que le pasas int x = gameManager->getGraphicsEngine()->getWindowSize().x-180+(parent->position.x/scale); int y = gameManager->getGraphicsEngine()->getWindowSize().y-175+(-parent->position.y/scale); minimapSprite->setPosition(Vector2d(x,y)); clock.restart(); } }
bool NetworkEngine::startServer() { GameManager* gameManager = GameManager::getInstance(); if(!gameManager->isServer()) { std::cout << "ERROR: Se esta intentando lanzar el server desde un cliente\n"; return false; } if(started) { std::cout << "ERROR: El server ya estaba lanzado\n"; return false; } //start(); peer = RakNet::RakPeerInterface::GetInstance(); socketDescriptor = new RakNet::SocketDescriptor(0,0); socketDescriptor->socketFamily=AF_INET; replicaManager = new ReplicaManager(); messageHandler = new RakNet::PacketLogger(); networkIdManager = new RakNet::NetworkIDManager(); socketDescriptor->port = SERVER_PORT; RakNet::StartupResult startupResult = peer->Startup(MAX_PLAYERS, socketDescriptor, 1); if(startupResult != RakNet::RAKNET_STARTED) { std::cout << "ERROR: No se ha podido lanzar el server (StartupResult)\n"; return false; } peer->AttachPlugin(replicaManager); replicaManager->SetNetworkIDManager(networkIdManager); peer->SetMaximumIncomingConnections(MAX_PLAYERS); //peer->AttachPlugin(messageHandler); messageHandler->SetPrintAcks(false); replicaManager->SetAutoSerializeInterval(SERVER_MILLISECONDS_BETWEEN_UPDATES); //peer->SetTimeoutTime(5000, RakNet::UNASSIGNED_SYSTEM_ADDRESS); std::cout << "Starting server in port " << SERVER_PORT << "\n"; std::cout << "Server started with GUID: " << peer->GetMyGUID().ToString() << "\n"; started = true; //replicaManager->SetAutoManageConnections(false,false); //replicaManager->Reference(GameManager::getInstance()->getGameObjectManager()->createEnemy()); return true; }
int main () { srand(time(NULL)); GameManager* game = new GameManager(); IntroState* introState = new IntroState(); PlayState* playState = new PlayState(); MenuState* menuState = new MenuState(); ControlsState* controlsState = new ControlsState(); PauseState* pauseState = new PauseState(); RecordsState * recordState = new RecordsState(); sounds * s = sounds::getInstance(); records * r = records::getInstance(); UNUSED_VARIABLE(introState); UNUSED_VARIABLE(playState); UNUSED_VARIABLE(pauseState); UNUSED_VARIABLE(menuState); UNUSED_VARIABLE(controlsState); s->load_xml((char*)"sounds.xml"); r->loadFile((char*)"pacman_records.txt"); try { // Inicializa el juego y transición al primer estado. game->start(IntroState::getSingletonPtr()); } catch (Ogre::Exception& e) { std::cerr << "Excepción detectada: " << e.getFullDescription(); } delete game; return 0; }
StaticEntity::StaticEntity(float x, float y, std::string resource_id):Entity( x, y ) { GameManager* manager = GameManager::getInstance(); clan::Canvas& gc = manager->getCanvas(); _currentSprite = clan::Sprite::resource(gc, resource_id, manager->getResourceManager()); }
Player::Player(float x, float y, float speedX, float speedY, unsigned int number, std::string sprite, PlayerModel* model, unsigned int lives ) : DynamicEntity( x, y, speedX, speedY ), _playerNumber( number ), _lives( lives ), _score( 0 ) ,_model( model ), _spriteResourceKey( sprite ), _weapon( new Weapon("Standard laser", "sprites/shot", GameManager::getInstance()->getPlayerOptions()->shotDelay ) ), _controller( GamepadController::getNewGamepad( 0 ) ), _invincible( false ), _invincibilityTimerBase(1500), _invincibilityTimer( 0 ), _alphaFlash( 0.5f ) { setCurrentWeapon( _weapon ); _weapon->setShotSpeed( GameManager::getInstance()->getPlayerOptions()->shotSpeedX, GameManager::getInstance()->getPlayerOptions()->shotSpeedY ); if (_controller == NULL) { _controller = new KeyboardController(); } GameManager* manager = GameManager::getInstance(); clan::Canvas& gc = manager->getCanvas(); _currentSprite = clan::Sprite::resource( gc, sprite, manager->getResourceManager() ); std::string descriptor = sprite.substr( sprite.find_last_of( "/" ) + 1 ); for (int i = 0; i < _currentSprite.get_frame_count(); i++) { std::string collisionResource = clan::string_format( "outlines/player/%1_00%2", descriptor, i ); _currentOutlines.push_back( clan::CollisionOutline::load( collisionResource.c_str(), manager->getResourceDocument() ) ); } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow) { ChangeWindowMode(TRUE); SetGraphMode(WINDOW_X, WINDOW_Y, 32); if (DxLib_Init() == -1)return -1; SetDrawScreen(DX_SCREEN_BACK); //�錾 GameManager *gm = new GameManager(WINDOW_X, WINDOW_Y); while (ProcessMessage() != -1) { int startTime = GetNowCount(); ScreenFlip(); ClearDrawScreen(); //���� gm->All(); if (CheckHitKey(KEY_INPUT_ESCAPE) == 1)break; int endTime = GetNowCount(); WaitTimer((1000 / 60) - (endTime - startTime)); } delete gm; DxLib_End(); return 0; }
int main ( int argc, char* argv[] ) { GameManager* gman = new GameManager(); if(argc > 2) { std::string str1 = std::string(argv[2]); str1 += ".map"; gman->setMap(str1); } gman->init(); int x = gman->run(); delete gman; if(!x){ // all is well ;) printf("Exited cleanly\n"); return 0; } else{ printf("There was an error\n"); return 1; } }
int main(int argc, char** argv) { GameManager* game = &GameManager::getGameManager(); game->runGameLoop(); return 0; }
int main(int argc, char *argv[]) #endif { // Fill Here --------------------------------------------------- GameManager game; try { game.init(); game.changeState(TitleState::getInstance()); game.go(); } // -------------------------------------------------------------- catch (Ogre::Exception& e) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); #else std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl; #endif } return 0; }
// Abre los sockets, pero no se conecta a nada // Antes se llamaba StartServerBrowser bool NetworkEngine::startClient() { GameManager* gameManager = GameManager::getInstance(); if(gameManager->isServer()) { std::cout << "ERROR: Se esta intentando lanzar un cliente desde el server\n"; return false; } if(started) { std::cout << "ERROR: El cliente ya estaba lanzado\n"; return false; } start(); socketDescriptor->port = 0; RakNet::StartupResult startupResult = peer->Startup(1, socketDescriptor, 1); if(startupResult != RakNet::RAKNET_STARTED) { std::cout << "ERROR: No se ha podido lanzar el client (StartupResult)\n"; return false; } started = true; return true; }
int main(int ac, char **av) { try { QApplication app(ac, av); const ConfObject *obj = ConfLoader::getInstance()->getConfObjectFor("./config"); ListenServerSingleton::getInstance()->init(obj->getStringValueOf("ip_server").c_str()); ListenServerSingleton::getInstance()->start(); QFile fileStyle("./rtypeStyle.css"); if (fileStyle.open(QIODevice::ReadOnly)) { app.setStyleSheet(fileStyle.readAll()); fileStyle.close(); } GameManager gameManager; gameManager.show(); return app.exec(); } catch (Exception *e) { LOGERR << "Program terminated with " << e->what() << std::endl; } catch (Exception e) { LOGERR << "Program terminated with " << e.what() << std::endl; } return (0); }
bool Polygon::init(PolygonInfo& polygonInfo) { if (Sprite::init()) { _type = Polygon_; setTag(polygonInfo.tag); this->isConvex = polygonInfo.isConvex; setPosition(polygonInfo.position.x*DefiniteSize.width, polygonInfo.position.y*DefiniteSize.height); GameManager* gameManager = GameManager::getInstance(); b2BodyDef bodyDef; bodyDef.type = b2_staticBody; bodyDef.position = cc_to_b2Vec(getPositionX() + (VisibleSize.width/2 - DefiniteSize.width/2), getPositionY()); bodyDef.userData = this; _body = gameManager->getBox2dWorld()->CreateBody(&bodyDef); b2FixtureDef fixtureDef; fixtureDef.filter.groupIndex = -1; fixtureDef.filter.categoryBits = 0; fixtureDef.filter.maskBits = 0; b2PolygonShape shape; int vertexCount = polygonInfo.vertexes.size(); CCASSERT(vertexCount>=3&&vertexCount<=b2_maxPolygonVertices, "vertex count is too little or too much!"); b2Vec2 points[b2_maxPolygonVertices]; if (isConvex) { for (int i = 0; i<vertexCount; i++) { points[i] = cc_to_b2Vec(polygonInfo.vertexes[i].x, polygonInfo.vertexes[i].y); } shape.Set(points,vertexCount); fixtureDef.shape = &shape; _body->CreateFixture(&fixtureDef); }else{ // std::vector<b2Vec2> vertexes; for (Vec2 vertex : polygonInfo.vertexes) { b2Vec2 point = cc_to_b2Vec(vertex.x, vertex.y); vertexes.push_back(point); } //切割 b2Separator* separator = new b2Separator(); if (separator->Validate(vertexes)==0) { separator->Separate(_body, &fixtureDef, &vertexes, PTM_RATIO); }else if (separator->Validate(vertexes)==1){ CCASSERT(0==1, "there are overlapping lines!"); }else if (separator->Validate(vertexes)==2){ CCASSERT(0==2, "the points are not in clockwise order"); }else if (separator->Validate(vertexes)==3){ CCASSERT(0==3, "there are overlapping lines and the points are not in clockwise order"); } CC_SAFE_DELETE(separator); } return true; } return false; }
int main(int argc, char * argv[]){ GameManager game; if(!game.openCam()){ return 0; } game.play(); return 0; }
void SetBonesParent::revert() { GameManager* gameManager = selection->getGameManager(); list<BoneObject*>::iterator parentIt = startingParents.begin(); for (auto& it : bonesToSetParent) { ((BoneObject*)gameManager->getObject(it.first))->setParent(*parentIt); ++parentIt; } }
int main(int argc, char **argv) { GameManager *gameManager = &GameManager::sharedGameManager(); gameManager->runGameLoop(); GameManager::destroy(); return 0; }
// // Main // int main() { GameManager gameManager; gameManager.Run(); return 0; }
int main() { using std::vector; using std::string; using std::make_pair; using std::chrono::milliseconds; using sf::Event; using sf::ContextSettings; using sf::RenderWindow; using sf::VideoMode; using sf::View; using namespace util; using namespace ray; GameManager gm; Constants::loadConstants(*(gm.getLuaContext())); RenderWindow& window = *gm.getRenderWindow(); // Create the main window entities::setLuaState(gm.getLuaContext()); entities::initBaseTypes(gm); entities::initManagerTypeBindings(gm); entities::initComponentLuaBindings(gm); ai::initAIBindings(gm); vector<Event> events; bool focused = true; while (window.isOpen()) { // Process events Event event; while (window.pollEvent(event)) { events.push_back(event); // Close window : exit switch (event.type) { case Event::Closed: window.close(); break; case Event::LostFocus: focused = false; break; case Event::GainedFocus: focused = true; break; case Event::KeyPressed: break; default: ; // nop } } gm.getStateMachine()->update(events); events.clear(); } }
int _tmain(int argc, _TCHAR* argv[]) { GameManager gManager = GameManager(); gManager.init(); gManager.gameLoop(); return 0; }
void Orc::Shoot(float dt) { GameManager* gManager = GameManager::getInstance(); float hDir = RandomHelper::random_real(-MAX_SHOT_DEVIATION, MAX_SHOT_DEVIATION); float vDir = -ProjectileManager::ENEMY_PROJECTILE_SPEED/2 + RandomHelper::random_real(-MAX_SHOT_DEVIATION, MAX_SHOT_DEVIATION); Vec2 dir = Vec2(hDir, vDir); gManager->getProjectileManager()->fireProjectile(TOwner::ENEMY, this, dir, "red_dot.png"); gManager->getSoundManager()->playFX(TSound::ORC_LASER); }