Ejemplo n.º 1
0
int main(int argc, char *argv[]){
    struct BSTree *tree = newBSTree();
    startScreen();
    buildTree(tree);
    playGame(tree);
    return 0;
}
Ejemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
    settings = Settings::getInstance();

    // make sure only ME gets keys
    grabKeyboard();

    startScreen();

    // initialize finder and capture, check if they start
    if (!finder.init(source.size) || !capture.init(source.size)) {
        QMessageBox::warning(this, tr("Can't initialize finder"), finder.error, QMessageBox::Ok);
    }

    whatWeSee = source.frame;
    ui->CVWindow->setImage(&whatWeSee);

    // set start flags
    viewMode = NORMAL;
    recMode = INPUT_;

    // call hearbeat to initialize image
    heartBeat();

}
Ejemplo n.º 3
0
void World::keyEvent(SDL_Event& e, bool& quit)
{
	switch (e.key.keysym.sym)
	{
	case SDLK_a:
		if (state == Constants::START_SCREEN)
		{
			state = Constants::ADVENTURE;
			break;
		}
		break;
	case SDLK_m:
		state = Constants::ADVENTURE;
		break;
	case SDLK_n:
		state = Constants::FIGHT;
		break;
	default:
		break;
	}

	if (state == Constants::START_SCREEN)
		startScreen();
	if (state == Constants::FIGHT)
		fight.events(e, quit);
	if (state == Constants::ADVENTURE)
		adventure.events(e, quit);
}
Ejemplo n.º 4
0
int main ( int argc, char** argv )
{
    camera.x = 0;
    camera.y = 0;
    camera.h = screenW;
    camera.w = screenH;
    // initialize SDL video
    if (SDL_Init(SDL_INIT_VIDEO) < 0 )
    {
        //printf( "Unable to init SDL: %s\n", SDL_GetError() );
        std::cout<<"Unable to init SDL: " <<SDL_GetError() <<std::endl;
        return 1;
    }

    /*
    if(!screen)
    {
        std::cout<<"Unable to set screen: " <<SDL_GetError() <<std::endl;
        return 1;
    }
    */

    std::string windowTitle = "soco-*";
    SDL_WM_SetCaption(windowTitle.c_str(), windowTitle.c_str());

    /***** MUSIC *****/

    // initialize BASS

    if(!BASS_Init(-1,44100,0,NULL,NULL))
    {
        BASS_Init(0,44100,0,NULL,NULL);
    }

    /***** GAME *****/
    // specify game loop
    initSpriteManager();
    initTextureManager();
    initSoundManager();

    bool done = false;
    while(!done)
    {
        int menuValue = startScreen();
        switch(menuValue)
        {
            case 0:
            case 1:
                done = gameLoop();
                break;
            case 2:
            case 3:
            default:
                return 0;
                break;
        }
    }
    return 0;
}
Ejemplo n.º 5
0
void MainWindow::step() {
    if ((source.sourceMode == MOVIE) && (!ui->positionSlider->isSliderDown())) {
        setSliderPosition(source.getPos());
    }
    // if we can't grab, reset to test screen
    if (!source.grab()) {
        startScreen();
        return;
    }

    switch (viewMode) {
        case FINDER:
            finder.step(source.frame);
            whatWeSee = finder.combined;
            break;
        case CAPTURE:
            if (!capture.step(source.frame)) {
                if (source.sourceMode == MOVIE) {
                    pauze();
                } else {
                    startScreen();
                    sourceView();
                };
            };
            whatWeSee = capture.combined;
            break;
        default:
            whatWeSee = source.frame;
            break;
    };

    if (recording) {
        if (recMode == OUTPUT) {
            recorder.putFrame(whatWeSee);
        } else {
            recorder.putFrame(source.frame);
        };
    };

    ui->CVWindow->update();
};
Ejemplo n.º 6
0
int main(int argc, char* argv[]) {
    cout << "Starting Lost Penguins!\n";
    //Clean exit on Windows close...
    atexit(SDL_Quit);

    cout << "Loading configuration file...\n";
    //Maybe: add some more location checks...
    if (readConfig("/usr/local/etc/lost_penguins.conf")) cout << "Loaded /usr/local/etc/lost_penguins.conf...\n";
    else cout << "Configuration files not found! Set default parameters...\n";

    parseInput(argc,argv);

    if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO)==0) {
        cout << "Initialized SDL...\n";
    } else {
        cout << "Couldn't initialize SDL!\n";
        exit(-1);
    }
    SDL_ShowCursor(SDL_DISABLE);
    //Change directory to datadir

    cout << "ImageCache...\n";
    imgcache=new ImageCache();
    cout << "SoundCache...\n";
    sndcache=new SoundCache();
    cout << "GraphicsEngine...\n";
    gfxeng=new GraphicsEngine();
    cout << "SoundEngine...\n";
    sfxeng=new SoundsEngine();
    cout << "Fonts...\n";
    font=new Font(imgcache->loadImage(1,"font_arial_white_16_01.png").surface);
    font2=new Font(imgcache->loadImage(1,"font_arial_red_16_01.png").surface);
    cout << "InputHandler...\n";
    input=new InputHandler();
    cout << "Initializing Scenario...\n";
    scenario=new Scenario();

    startScreen();

    while (true) {
        input->update();
        scenario->physic->update();
        gfxeng->draw();
        SDL_Delay(1);
    }

    quitGame(-2);
}
Ejemplo n.º 7
0
//*************************************************************************************************
//	Main program to initialize hardware and execute Tasks.
//*************************************************************************************************
void main(void)  {
	// Create the tasks, the definitions are passed to the scheduler
	xTaskCreate(OLEDTask, "OLEDTask", 256, NULL, 2, NULL);
	xTaskCreate(LEDTask, "LEDTask", 32, NULL, 1, NULL);
	xTaskCreate(FIBTask, "FIBTask",  64, NULL, 1, NULL);
	//  Initialize system
	systemInit();

	// Display the initial image
	startScreen();

	// Start the FreeRTOS Scheduler
	vTaskStartScheduler();

	// The infinite loop is necessary for the FreeRTOS Scheduler
    while(true);
}
Ejemplo n.º 8
0
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    int collided = 0;
    unsigned char answer;

    Bdisp_AllClr_DDVRAM();

    Init_SerialPort();
    Start_SerialPort();

    if(connect() == 0) {
        isHost = 1;
    }

    while(1) {
        startScreen();

        memset(videoBuffer, 0, 1024);
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawBox(48, 27, 79, 37, videoBuffer, BLACK);
        CoolText(51, 29, FONT_FIVE, "Ready?", videoBuffer);
        DrawAll(videoBuffer);

        Sleep(1000);

        SerialTransmit(READY);
        while(SerialReceive() != READY) {
            ;
        }

        reset();

        while(1) {
            answer = SerialReceive();

            if(answer == CRASH) {
                score++;
                wonLast = ME;
                break;
            }
            if(answer == EXIT) {
                Reset_Calc();
            }
            if(answer == COORDS) {
                receivedX = SerialReceive();
                receivedY = SerialReceive();

                setBit(videoBuffer, 128, receivedX, receivedY, 1);
            }

            checkKeys();
            move();

            collided = getBit(videoBuffer, 128, playerX, playerY);
            if(collided) {
                otherScore++;
                wonLast = OTHER;
                SerialTransmit(CRASH);
                break;
            }

            setBit(videoBuffer, 128, playerX, playerY, 1);

            SerialTransmit(COORDS);
            SerialTransmit(playerX);
            SerialTransmit(playerY);

            DrawAll(videoBuffer);

            Sleep(delays[speed]);
        }
    }

    return 1;
}
Ejemplo n.º 9
0
void editLevelScreen()
{
    int currentType = TILE_RED;
    showType(currentType);

    Tile *tiles[TOTAL_TILES];

    if(loadTiles(tiles) == false)
    {
        cleanUp();
        exit(0);
    }

    while(true)
    {
        fps.start();

        while(SDL_PollEvent(&event))
        {
            //When the user clicks
            if( event.type == SDL_MOUSEBUTTONDOWN )
            {
                //Put the tile
                putTile( tiles, currentType );
            }

            if (event.type == SDL_KEYDOWN)
            {
                switch(event.key.keysym.sym)
                {
                    case SDLK_1:
                    case SDLK_q:
                    {
                        //Scroll forward through tiles
                        currentType--;

                        if( currentType < TILE_RED )
                            currentType = TILE_TOPLEFT;

                        //Show the current tile type
                        showType( currentType );
                        break;
                    }
                    case SDLK_2:
                    case SDLK_w:
                    {
                        //Scroll backward through tiles
                        currentType++;

                        if( currentType > TILE_TOPLEFT )
                            currentType = TILE_RED;

                        //Show the current tile type
                        showType( currentType );
                        break;
                    }

                    case SDLK_s:
                    {
                        // save the tiles and display a "saved" message
                        saveTiles(tiles);
                        SDL_Color savedMessageColor = {255, 255, 255};
                        SDL_Surface* savedMessage = NULL;
                        savedMessage = load_font("eva.ttf", "SAVED", savedMessageColor, 24);
                        apply_surface(1, 1, savedMessage, screen);
                        SDL_Delay(500);
                        SDL_FreeSurface(savedMessage);
                        break;
                    }
                    case SDLK_BACKSPACE:
                    {
                        deleteTiles(tiles);
                        startScreen();
                        break;
                    }
                    default:;
                }
            }

            myWindow.handle_window();
            handleMusic();

            if( event.type == SDL_QUIT )
            {
                //Quit the program
                deleteTiles(tiles);
                cleanUp();
                exit(0);
            }
        }

        if (myWindow.error())
        {
            cleanUp();
            exit(0);
        }

        setEditorCamera();

        for (int t = 0; t < TOTAL_TILES; t++)
            tiles[t]->show();

        if (SDL_Flip(screen) == -1)
        {
            cleanUp();
            exit(0);
        }

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }
}
Ejemplo n.º 10
0
void theGame()
{
    SDL_WM_SetCaption("WASD: Move, BACKSPACE: Start Screen, ENTER: Fullscreen", NULL);
    Sprite mew("testChar2.png", 32, 156, 0); //load mew and set R 32, G 156, B 0 to be transparent.  Set width to 33 and height to 69

    Tile *tiles[TOTAL_TILES];
    Enemy *enemies[TOTAL_ENEMIES];

    enemies[0] = new Enemy(225, 0, ENEMY_ROBOT);
    enemies[0]->setVelX(50);

    enemies[1] = new Enemy(225, 0, ENEMY_ROBOT);
    enemies[1]->setVelX(100);

    enemies[2] = new Enemy(225, 0, ENEMY_ANDROID);
    enemies[2]->setVelX(-75);

    bool playing = true;

    if(setTiles(tiles) == false)
    {
        cleanUp();
        exit(0);
    }

    //game loop
    delta.start();
    while(playing)
    {
        fps.start();
        while(SDL_PollEvent(&event))
        {
            mew.handle_input();
            myWindow.handle_window();
            handleMusic();

            if(event.key.keysym.sym == SDLK_BACKSPACE)
            {
                deleteTiles(tiles);
                deleteEnemies(enemies);
                startScreen();
            }
            if(event.type == SDL_QUIT)
                playing = false;
        }
        if (myWindow.error())
        {
            cleanUp();
            exit(0);
        }

        mew.move(delta.get_ticks(), tiles, enemies);

        for (int e = 0; e < TOTAL_ENEMIES; e++)
        {
            enemies[e]->walk(delta.get_ticks(), tiles);
        }

        delta.start(); //restart delta after movement
        mew.setCamera();

        for( int t = 0; t < TOTAL_TILES; t++ )
            tiles[t]->show();
        mew.show();
        for (int e = 0; e < TOTAL_ENEMIES; e++)
            enemies[e]->show();

        if(SDL_Flip(screen) == -1)
        {
            cleanUp();
            exit(0);
        }

        if(fps.get_ticks() < (1000 / FRAMES_PER_SECOND))
            SDL_Delay(1000 / FRAMES_PER_SECOND - fps.get_ticks());

    }

    deleteTiles(tiles);
    deleteEnemies(enemies);
    exit(0);
}