Exemplo n.º 1
0
int main( int argc, char** argv )
{
	QApplication app( argc, argv );

	Config* config = new Config( &app );

	// If we can't process the command-line or set up the database
	// there's no point continuing
	if ( !processCommandLine() || !setupDatabase() )
		return 0;

	QDeclarativeView view;

	view.connect( view.engine(), SIGNAL(quit()), SLOT(close()) );
	view.setResizeMode( QDeclarativeView::SizeRootObjectToView );

	// Register custom types for access to certail enums from QML
	qmlRegisterType< SoundEngine >( "net.randalflagg.llamaui", 1, 0, "SoundEngine" );
	qmlRegisterType< KeyboardMap >( "net.randalflagg.llamaui", 1, 0, "KeyboardMap" );
	qmlRegisterType< SystemProcess >( "net.randalflagg.llamaui", 1, 0, "SystemProcess" );

	QDeclarativeContext* rootContext = view.rootContext();

	// Initalise the keyboard key/action mapper
	if ( !initKeyboardMap( rootContext ) )
		return 0;

	rootContext->setContextProperty( "config", config );
	initSoundEngine( rootContext );
	initGameMenu( rootContext );
	initEmulatorMenu( rootContext );
	initSystemMenu( rootContext );
	initGameLauncher( rootContext );

	// Create the interface
	QDir dir( Config::instance()->value( "paths", "qmlDir" ).toString() );
	view.setSource( QUrl::fromLocalFile( dir.absoluteFilePath( "main.qml" ) ) );
	view.showFullScreen();

	// Hide the mouse cursor
	app.setOverrideCursor( QCursor( Qt::BlankCursor ) );

	return app.exec();
}
Exemplo n.º 2
0
MyGame::MyGame(int argc, char* argv[]) : Game(640, 480, -1, "Engine Sandbox", argc, argv){
    // Força o carregamento de imagens, sons, arquivos de mapas e itens de forma relativa.
    setRelativePaths();
    MyGame::getParams(argc, argv);
    initMainMenu();
    initGameMenu();
    
    BackgroundMusic::loadSong("/Users/alexpeixoto/Downloads/AF/menu.ogg");
    BackgroundMusic::setVolume(20);
    BackgroundMusic::play();
    
    //Inicia screenlog
    sl=new ScreenLog("/Developer/times.ttf");;
    
    //Define a janela principal para render de imagem e texto
    Core::Image::setWindow(Game::window);
    Core::TextControl::setWindow(Game::window);
    
    // Define arquivos genericos de itens e sons.
    ItemManager::loadFromFile("/Users/alexpeixoto/Desktop/item.list");

    
    
    // Inicializa um screenLog estático.
    sl->setPosition(Point2i(Game::window->getSize().x-250, 0));
    sl->setSize(Vector2i(250, 100));
    sl->setSpacing(5);
    sl->setScale(.5);
    
    // Inicializa debug
    Debug::LogManager::addLevelDestiny(Debug::LogLevel::WARNING, Debug::Destiny::Console);
    LogManager::addLevelDestiny(Debug::LogLevel::MESSAGE, Debug::Destiny::Screen, sl);
    LogManager::addLevelDestiny(Debug::LogLevel::WARNING, Debug::Destiny::Console, sl);
    
    bs=new Core::BackgroundShape();
    
    bs->setBorderSize(2);
    bs->setBorderColor(10, 100, 10, 255);
    bs->setInsideColor(100, 100, 0, 180);
    bs->setSize(Vector2i(260, 110));
    bs->setPosition(Point2i(Game::window->getSize().x-262, 2));
    
    //!Escreve no TTY, Caso deseje utilizar esta função abra o terminal e digite tty. Coloque o valor retornado no lugar do /dev/ttys000
    //LogManager::addLevelDestiny(Debug::LogLevel::ERROR, Debug::Destiny::Device, "/dev/ttys000", true);
    //LogManager::log(Debug::LogLevel::ERROR, "Teste", "");
    //LogManager::log(Debug::LogLevel::ERROR, "Teste", "");
    //LogManager::removeLevelDestiny(Debug::LogLevel::ERROR, Debug::Destiny::Device);

    thread t([=](){
        map<string, string> params;
        while(1){
            params.clear();
            //Aqui é verificado de onde veio a solicitação de mudança de nivel.
            if(Adventure::LevelManager::changeTo==0 && (loaded==-1 || loaded==0))
                LevelManager::changeLevel<ClosedMap>(params);
            else if(Adventure::LevelManager::changeTo==1 && (loaded==-1 || loaded==0))
                LevelManager::changeLevel<TestMap>(params);
            else if(Adventure::LevelManager::changeTo==2 && (loaded==-1 || loaded==0))
                LevelManager::changeLevel<ObjectMapGame>(params);
            
            else if(Adventure::LevelManager::changeTo==0 && loaded==1){
                params.insert(make_pair("position", "outHouse"));
                LevelManager::changeLevel<BeginMap>(params);
            }
            else if(Adventure::LevelManager::changeTo==0 && loaded==2){
                params.insert(make_pair("position", "outTest"));
                LevelManager::changeLevel<BeginMap>(params);
            }
            else if(Adventure::LevelManager::changeTo==0 && loaded==3){
                params.insert(make_pair("position", "outObject"));
                LevelManager::changeLevel<BeginMap>(params);
            }
            this_thread::sleep_for(chrono::milliseconds(100));
        }
    });
    t.detach();
}