bool Weapon_Template::loadTemplate(std::string filename)
{
  std::ifstream file;
  file.open(filename.c_str());
  if(file.fail())
  {
    printf("Error loading weapon templates \n");
    return false;
  }
  int num = 0;
  
  std::string weapon_graphic;
  std::string projectile_graphic;
  while(file >> weapon_graphic >> projectile_graphic >> templates[num].x_pos >> templates[num].y_pos >> templates[num].angle 
    >> templates[num].firing_rate >> templates[num].projectile_speed >> templates[num].projectile_radius >> templates[num].damage >> templates[num].firing_pattern)
  {
    if(load_files(templates[num].weapon_graphic, weapon_graphic) == false)
    {
      return 1;
    }
    if(load_files(templates[num].projectile_graphic, projectile_graphic) == false)
    {
      return 1;
    }
    num ++;
  }
}
示例#2
0
int main( int argc, char* args[] )
{
    //wait for quit
    bool quit = false;
    //init
    if( init() == false )
        return 1;
    
    //load
    if( load_files() == false )
        return 1;
    
    //apply
    apply_surface( 0, 0, image, screen );
    
    //update
    if( SDL_Flip( screen ) == -1 )
        return 1;
    
    while( quit == false )
    {
           //while event
           while( SDL_PollEvent( &event ) )
           {
                if( event.type == SDL_QUIT )
                    quit = true;
           }
    }
    clean_up();
    
    return 0;
}
示例#3
0
文件: main.cpp 项目: yaochie/Tetras
int main(int argc, char *args[])
{
    srand(time(NULL));

    //Initialization
	if (!init())
		return 1;
	if (!load_files())
		return 1;

    //Sets initial state
    stateID = STATE_INTRO;
    currentState = new Intro();

    //Game loop
    while (stateID != STATE_EXIT)
    {
        currentState->handle_events();
        currentState->logic();
        change_state();
        currentState->render();

        if (SDL_Flip(screen) == -1)
            return 1;
    }

    clean_up();

    //logger.close();

	return 0;
}
示例#4
0
Game::Game(){
	width = 640;
	height = 480;
	bpp = 32;
	fpsCap = 60;

	if(init() == false){ //sets up screen
		return; //fail!
	}

	Player p;
	player = p;

	spawn_enemies();

	if(load_files() == false){ //load player/background sprite
		return; //FAIL!
	}

	wallBounds.x = width/2;
	wallBounds.y = 25;
	wallBounds.w = 15;
	wallBounds.h = height - 50;


	Renderer r;
	renderer = r;

	Timer t;
	timer = t;
}
bool StartScreen::main(){
	bool quit = false;

	if(load_files() == false)
		return 1;

	while(!quit){
		while(SDL_PollEvent(&event)){
			if(event.type == SDL_QUIT)
				quit = true;
			if(event.type == SDL_KEYDOWN){
				if(event.key.keysym.sym == SDLK_RETURN){
					quit = true;
				}
			}
		}

		
		apply_surface((SCREEN_WIDTH - messages[0]->w)/2, SCREEN_HEIGHT/3, messages[0], screen);
		apply_surface((SCREEN_WIDTH - messages[1]->w)/2, 2*SCREEN_HEIGHT/3, messages[1], screen);

		if(SDL_Flip(screen) == -1)
			return 1;

	}
	cleanup();
	return 0;
}
示例#6
0
//Initializes the system
int init()
{
	//Initializes the SDL and exit if there was an error
	if (SDL_Init (SDL_INIT_EVERYTHING) == -1)
		{ return 1; }

	//Initializes the SDL_ttf and exit if there was an error
	if (TTF_Init())
		{ return 3; }

	//Initializes the SDL_mixer and exit if there was an error
	if (Mix_OpenAudio(LC_SOUND_SAMPLERATE, LC_SOUND_FORMAT, LC_SOUND_CHANNELS, LC_SOUND_CHUNKSIZE) == -1)
		{ return 4; }

	//Create the window
	screen = SDL_SetVideoMode (LC_SCREEN_WIDTH, LC_SCREEN_HEIGHT, LC_SCREEN_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF);

	//Load the necessary files and check for errors
	if (!load_files())
		{ return 5; }

	//Changes the window title
	SDL_WM_SetCaption ("Line Collapser", NULL);

	//If there was an error with the window creation, exits the program
	if (screen == NULL)
		{ return 6; }

	//Start the random number generation function
	mt_init();

	//If everything went fine
	return 0;

}//init()
示例#7
0
int main(int argc, char* args[]) {
    //make sure the program waits for a quit;
    bool quit = false;
    //initialize;
    if(init()==false) {
        return 1;
    }
    //load the files
    if(load_files()==false) {
        return 1;
    }
    //apply the surface to the screen
    apply_surface(0,0,image,screen);
    //update the screen
    if(SDL_Flip(screen)==-1) {
        return 1;
    }
    //while the user hasn't quit
    while(quit==false) {
        while(SDL_PollEvent(&event)) {
            //if the user has Xed out the window
            if(event.type == SDL_QUIT) {
                //quit the program
                quit = true;
            }
        }
    }
    //free the surface and quit SDL
    clean_up();
    return 0;
}
bool MGame::main(){
	bool quit = false;
	
	if(load_files() == false){
		return 1;
	}

	while(!quit){
		while(SDL_PollEvent(&event)){
			if(event.type == SDL_QUIT){
				quit = true;
			}
		}

		SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 255,255,255));

		apply_surface(100,100,stuff, gScreen);
		apply_surface(0,0,gScreen, screen);

		if(SDL_Flip(screen) == -1){
			return 1;
		}
	}

	return !quit;
}
示例#9
0
int main(int argc, char* args[])
{
   bool quit = false;

   if (init() == false)
   {
      return 1;
   }
   
   if (load_files() == false)
   {
      return 1;
   }
   
   apply_surface(0, 0, background, screen);
   apply_surface(240, 190, foo, screen);

   if (SDL_Flip(screen) == -1)
   {
      return 1;
   }
   while(quit == false)
   {
      while (SDL_PollEvent(&event))
      {
         if (event.type == SDL_QUIT)
         {
            quit = true;
         }
      }
   }      
   clean_up();
   return 0;
}
示例#10
0
void MainWindow::on_file_open() {
	bool bExit = false;

    m_dialogFile.set_title(gettext("Open DICOM Image files"));
	m_dialogFile.set_select_multiple(true);
    m_dialogFile.remove_filter(m_filter_dicomdir);
    m_dialogFile.add_filter(m_filter_dicom);
    m_dialogFile.add_filter(m_filter_any);
    m_dialogFile.set_filter(m_filter_dicom);
	m_dialogFile.show();

	int rc = 0;

	while(!bExit) {
		rc = m_dialogFile.run();
		bExit = (rc == Gtk::RESPONSE_CANCEL) || (rc == Gtk::RESPONSE_OK);
	}

	m_raise_opened = m_dialog_check->get_active();

	m_dialogFile.hide();

	if(rc == Gtk::RESPONSE_CANCEL) {
		return;
	}

	load_files(m_dialogFile.get_filenames());
}
示例#11
0
int main(int argc, char* args[])
{
  bool quit = false;
  bool cap = true;
  int frame = 0;
  Timer fps;
  Square mySquare;

  if(init() == false)
  {
    return 1;
  }

  //Load the files
  if(load_files() == false)
  {
    return 1;
  }

  wall.x = 300;
  wall.y = 40;
  wall.w = 40;
  wall.h = 400;

  //While user hasn't quit
  while(quit == false)
  {
    fps.start();

    while(SDL_PollEvent(&event))
    {
      mySquare.handle_input();

      if(event.type == SDL_QUIT)
      {
        quit = true;
      }
    }
      mySquare.move();
      SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
      SDL_FillRect(screen, &wall, SDL_MapRGB(screen->format, 0x77, 0x77, 0x77));
      mySquare.show();

      if(SDL_Flip(screen) == -1)
      {
        return 1;
      }

      frame++;

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

  clean_up();
  return 0;
}
示例#12
0
int main(int argc, char* argv[])
{
	bool quit = false;
	SDL_Surface *message = NULL;
	if (argc != 3)
	{
		std::cout << "Usage : keypress_sdl <fontname> <image name>\n";
		return 1;
	}

	if (init() == false) return 1;
	if (load_files(argv[1],argv[2]) == false) return 1;
	
	//Render the text messages
	
	upMessage = TTF_RenderText_Solid(font,"Up was pressed",textcolor);
	downMessage = TTF_RenderText_Solid(font,"Down was pressed",textcolor);
	leftMessage = TTF_RenderText_Solid(font,"Left was pressed",textcolor);
	rightMessage = TTF_RenderText_Solid(font,"Right was pressed",textcolor);
	
	apply_surface(0,0,background,screen);
	
	
	
	if (SDL_Flip(screen) == -1) return 1;
	
	while (quit == false)
	{
		while (SDL_PollEvent(&event))
		{
			if(event.type == SDL_QUIT)
			{
				quit = true;
			}
			if (event.type == SDL_KEYDOWN)
			{
				switch (event.key.keysym.sym)
				{
					case SDLK_UP	:message = upMessage; 	 break;
					case SDLK_DOWN	:message = downMessage;  break;
					case SDLK_LEFT	:message = leftMessage;  break;
					case SDLK_RIGHT :message = rightMessage; break;
					default : ;
				}
			}
			if (message != NULL)
			{
				apply_surface(0,0,background,screen);
				apply_surface((SCREEN_WIDTH - message->w)/2,(SCREEN_HEIGHT-message->h)/2,message,screen);
				message = NULL;
			}
			if (SDL_Flip(screen) == -1) return 1;

		}
	}
	
	clean_up();
	return 0;
}
cDangerousGame::cDangerousGame( const int screen_width, const int screen_height ){

	finished = false;
	started = false;
	startButton = BUTTON_NOT_PRESSED;

	message = NULL;
	screen = NULL;
	background = NULL;
	opponents = NULL;
	player = NULL;
	font = NULL;
	timeMessage = NULL;
	playerMessage = NULL;

	textColor = { 255, 255, 255 };

	bool init = game_init( (int) screen_width, (int) screen_height );
	if( !init ) { printf("initialitation failed\n"); }
	bool loading = load_files();
	if( !loading ) { printf("loading files failed\n"); }

	playerDetails = new cPlayer();

        clip[ 0 ].x = 0;
        clip[ 0 ].y = 0;
        clip[ 0 ].w = 40;
        clip[ 0 ].h = 40;

        clip[ 1 ].x = 40;
        clip[ 1 ].y = 0;
        clip[ 1 ].w = 40;
        clip[ 1 ].h = 40;

        clip[ 2 ].x = 0;
        clip[ 2 ].y = 40;
        clip[ 2 ].w = 40;
        clip[ 2 ].h = 40;

        clip[ 3 ].x = 40;
        clip[ 3 ].y = 40;
        clip[ 3 ].w = 40;
        clip[ 3 ].h = 40;

	srand(time(NULL) + getpid());
	ball1 = new cBall( wRand(), hRand(), 10, 10, screen_h, screen_w );
	ball2 = new cBall( wRand(), hRand(), 10, -10, screen_h, screen_w );
	ball3 = new cBall( wRand(), hRand(), -10, 10, screen_h, screen_w );
	ball4 = new cBall( wRand(), hRand(), -10, -10, screen_h, screen_w );

	timeGameStarted = 0;//SDL_GetTicks();
	timeForOneRound = 120;
	lastBlittTime = -1;

	playerPoints = 0;

	createPlayerPointMessage();
}
示例#14
0
int main( int argc, char* argx[] )
{
  //Quit flag
  bool quit = false;

  //Initialize
  if( init() == false )
    {
      return 1;
    }

  //Load the files
  if( load_files() == false )
    {
      return 1;
    }

  //Clip the sprite sheet
  set_clips();

  //Make the button
  Button myButton( 170, 120, 320, 240 );

  //While the user hasn't quit
  while( quit == false )
    {
      //If there's events to handle
      if( SDL_PollEvent( &event ) )
        {
          //Handle button events
          myButton.handle_events();

          //If the user hax Xed out the window
          if( event.type == SDL_QUIT )
            {
              //Quit the program
              quit = true;
            }
        }

      //Fill the screen white
      SDL_FillRect( screen, &screen-> clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

      //Shaw the button
      myButton.show();

      //Update the screen
      if( SDL_Flip( screen ) == -1 )
        {
          return 1;
        }
    }

  //Clean up
  clean_up();

  return 0;
}
示例#15
0
int main( int argc, char *args[] ) {
    bool quit = false;
    ScreenManager *screenManager = new ScreenManager();
    SoundManager *soundManager = new SoundManager();


    if ( init() == false ) {
        return 1;
    }

    if ( load_files() == false ) {
        return 1;
    }

    while ( quit == false ) {
        while ( SDL_PollEvent( &event ) ) {

            if ( event.type == SDL_KEYDOWN ) {
                switch ( event.key.keysym.sym ) {
                    case SDLK_RETURN:
                        handle_return_key();
                        break;
                    default:
                        ;
                }
            }

            if ( event.type == SDL_QUIT ) {
                quit = true;
            }
        }


        startScreen = screenManager->load_image( "../ScreenManager/Images/test.png" );

        if ( soundManager->play_music( "../beat.wav" ) ) {
            return 1;
        }

        screenManager->apply_surface( 0, 0, startScreen, screen);


        if ( gameStart ) {
            //apply the gameScreen surface
        } else {
            //apply the startScreen surface
        }

        //Update the screen
        if ( SDL_Flip( screen ) == -1 ) {
            return 1;
        }
    }

    clean_up();
    return 0;
}
示例#16
0
int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Render the text
    message = TTF_RenderText_Solid( font, "The quick brown fox jumps over the lazy dog", textColor );

    //If there was an error in rendering the text
    if( message == NULL )
    {
        return 1;
    }

    //Apply the images to the screen
    apply_surface( 0, 0, background, screen );
    apply_surface( 0, 150, message, screen );

    //Update the screen
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }

    //While the user hasn't quit
    while( quit == false )
    {
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }
    }

    //Free surfaces and font then quit SDL_ttf and SDL
    clean_up();

    return 0;
}
示例#17
0
int main( int argc, char* args[] ){
   
    StopWatch fps(0.2);
    SDL_Event event;
    SDL_Rect camera = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
    //Initialize
    if( init() == false ) {
        std::cerr<<"Init fail"<<std::endl;
        return 1;
    }
    
    //Load the files
    if( load_files() == false ){
        std::cerr<<"Load file fail"<<std::endl;
        return 1;
    }
    
    //Continuous key press
//    if(SDL_EnableKeyRepeat(200,200)<0) return 1;
    
        
    MenuScreen * menu_screen = new MenuScreen();
    ScreenController * screen_controller = new ScreenController(menu_screen);
   
    
    //While the user hasn't quit
    fps.start();
    while( QUIT == false ){
        
        while( SDL_PollEvent( &event )){
            if( event.type == SDL_QUIT )QUIT = true;
            
        }
        
        if (fps.is_timeup()) {
            screen_controller->handle_input(event);
            screen_controller->animate();
            fps.start();
        }
        
        screen_controller->show(camera, menuSheet, screen);

        //Update the screen
        if( SDL_Flip( screen ) == -1 ){
            return 1;
        }

    }
    
    //Clean up
    delete screen_controller;
    clean_up();
    
    return 0;
}
示例#18
0
文件: main.c 项目: WangKaimin/netwalk
int main( int argc, char* args[] )
{
    //确保程序一直等待quit
    bool quit = false;

    // 初始化
    if(init() == false)
        return 1;

    // 加载文件
    if( load_files() == false)
        return 1;



    apply_surface( 0, 0, image, screen );

    // 更新窗口
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }


    //当用户还不想退出时
    while( quit == false )
    {
        //当有事件发生时,我们需要处理它们
        while( SDL_PollEvent( &event))
        {
            //如果用户点击了窗口右上角的关闭按钮
            if( event.type == SDL_QUIT )
            {
                //退出程序
                quit = true;
            }
            else if(event.type == SDL_MOUSEBUTTONUP)
            {
                //退出程序
                quit = true;
            }
        }
    }

    clean_up();



    // 退出SDL
    // SDL_Quit();

    return 0;
}
示例#19
0
int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

	mytext = TTF_RenderText_Solid( font, "Hello", textcolor );

    //Apply the surfaces to the screen
    apply_surface( 0, 0, background, screen );
    apply_surface( 240, 190, mytext, screen );

    //Update the screen
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }

    //While the user hasn't quit
    while( quit == false )
    {
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
			else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_q)
			{
				quit = true;
			}
        }
    }

    //Free the surfaces and quit SDL
    clean_up();

    return 0;
}
示例#20
0
文件: animation.cpp 项目: Foest/sdl
//Functions
int main(int argc, char* args[])
{
  bool quit = false;

  if(init() == false)
  {
    return 1;
  }

  //Load the files
  if(load_files() == false)
  {
    return 1;
  }

  set_clips();
  Timer fps;
  Foo walk;

  //While user hasn't quit
  while(quit == false)
  {
    fps.start();

    while(SDL_PollEvent(&event))
    {
      walk.handle_events();

      if(event.type == SDL_QUIT)
      {
        quit = true;
      }
    }
      walk.move();

      SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
      walk.show();

      if(SDL_Flip(screen) == -1)
      {
        return 1;
      }

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

  clean_up();
  return 0;
}
示例#21
0
文件: Stage.cpp 项目: Tirmenat/solara
Stage::Stage()
{	
  //units.push_back(new Hero(x,y,0,0,0,0,0));
  screen = NULL;
  background = NULL;
  title = NULL;
  init();
  load_files();
  set_clips();
  xoffset = 100;
  yoffset = 100;
  maxBullets = 5; //max number of bullets on screen is 5
  currBullets = 0;
}
int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Show the background
    show_surface( 0, 0, background );

    //Create and run the threads
    threadA = SDL_CreateThread( blitter_a, NULL );
    threadB = SDL_CreateThread( blitter_b, NULL );

    //Wait for the threads to finish
    SDL_WaitThread( threadA, NULL );
    SDL_WaitThread( threadB, NULL );

    //While the user hasn't quit
    while( quit == false )
    {
        //If there's an event to handle
        if( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }
    }

    //Clean up
    clean_up();

    return 0;
}
示例#23
0
int main() {
	bool quit = false;
    Timer fps;
    SDL_Surface *screen = NULL;
	SDL_Event event;
    Water water(&screen);

	//TTF_Font *font = NULL;
	//SDL_Color textColor = {0, 0, 0};
	
    if( init(&screen) == false ) return 1;
    if( load_files() == false ) return 2;
	
	//water.randomInit();
	
    while( quit == false ) {
		fps.start();
		
		while( SDL_PollEvent( &event ) ) {
            if( event.type == SDL_QUIT ) {
                quit = true;
            }
            if (event.type == SDL_MOUSEBUTTONDOWN)
				if (event.button.button == SDL_BUTTON_LEFT) {
					if (event.button.y < SCREEN_HEIGHT / 2)
						water.giveInput(event.button.x, 10);
					else
						water.giveInput(event.button.x, -10);
				}
        }
		
		water.compute();
		water.move();
		
        SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ));
		
		water.show();
		
        if( SDL_Flip( screen ) == -1 ) return 3;
        
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }
    clean_up();

    return 0;
}
示例#24
0
文件: SAO.cpp 项目: jodilo/monopoly
int main( int argc, char* args[] )
{
    //Make sure the program waits for a quit
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Apply the surface to the screen
    apply_surface( 0, 0, image, screen );

    //Update the screen
    if( SDL_Flip( screen ) == -1 )
    {
        return 1;
    }

    //While the user hasn't quit
    while( quit == false )
    {
        //While there's an event to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }
    }

    //Free the surface and quit SDL
    clean_up();

    return 0;
}
示例#25
0
int main( int argc, char* args[] ) 
{ 
	bool quit = false;
	Character* myChar = new Character(200, 0, 0, 20, 20);
	Timer delta;
	
	if (init() == false)
	{
		return 1;
	}

	if (load_files() == false)
	{
		return 1;
	}

	delta.start();

	while (quit == false)
	{
		while(SDL_PollEvent(&event))
		{
			myChar->handle_input();

			if (event.type == SDL_QUIT)
			{
				quit = true;
			}
		}

		myChar->move(delta.get_ticks());
		delta.start();
		SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
		myChar->show();

		if(SDL_Flip(screen) == -1)
		{
			return 1;
		}
	}
	
	//Quit SDL 
	clean_up();

	return 0; 
}
示例#26
0
int main()
{
    static bool quit = false;
    Role role("saozi");
    //Timer fps;
    //Background bg;

    init_sdl_lib();
    load_files();
    role.set_screen(person, screen);
    role.set_clips();
    role.set_event(&event);

    SDL_FillRect(screen, &screen->clip_rect, 
            SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));

    SDL_Flip(screen);

    while (quit != true) {
        role.start();
        while (SDL_PollEvent(&event)) {
        //if (SDL_PollEvent(role.role_get_event())) {
            role.handle_event();

            if (event.type == SDL_QUIT) {
                quit = true;
            }
        }

        role.move();
        SDL_FillRect(screen, &screen->clip_rect, 
                SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));

        role.show();

        SDL_Flip(screen);
            //bg.show(); 
        if (role.get_ticks() < 1000 / 20) {
            SDL_Delay((1000/20) - role.get_ticks());
        }
    }

    clean_up();
    return 0;
}
示例#27
0
int main (int argc, char* args[])
{
	bool quit = false;

	if(init() == false)
	{
		return 1;
	}

	if(load_files() == false)
	{
		return 1;
	}

	set_clips();

	Button myButton( 170, 120, 320,240);

	//the loop
	while(quit == false)
	{
		if (SDL_PollEvent(&event))
		{
			myButton.handle_events();

			if(event.type == SDL_QUIT)
			{
				quit = true;
			}
		}

		SDL_FillRect ( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );
		myButton.show();
		if(SDL_Flip(screen) == -1)
		{
				return 1;
	
		}
	}
	
	clean_up();
	return 0;

}
示例#28
0
dicom_parser::dicom_parser(QStringList file_list,QWidget *parent) :
        QDialog(parent),
        ui(new Ui::dicom_parser)
{
    ui->setupUi(this);
    cur_path = QFileInfo(file_list[0]).absolutePath();
    std::sort(file_list.begin(),file_list.end(),compare_qstring());
    load_files(file_list);

    if (!dwi_files.empty())
    {
        ui->SrcName->setText(get_src_name(file_list[0]));
        image::io::dicom header;
        if (header.load_from_file(file_list[0].toLocal8Bit().begin()))
        {
            slice_orientation.resize(9);
            header.get_image_orientation(slice_orientation.begin());
        }
    }
}
int main( int argc, char* args[] ){
   //The program will wait for a quit
   bool quit = false;

   //Initializing
   if( init() == false ){
      return 1; 
   }

   //Loading my files
   if( load_files() == false ){
      return 1;
   }

   //Applying the surface to the screen
   apply_surface( 0, 0, image, screen );

   //Update the screen
   if( SDL_Flip( screen ) == -1 ){
      return 1;
   }

   //Now is time to show the image on the screen
   //while the user hasn't quit
   while( quit == false ){
      //while there's an event to handle
      while( SDL_PollEvent( &event ) ){
         //If the user has exited out the window by clicking on the X button and we need to threat this ;)
         if( event.type == SDL_QUIT ){
            //Go out
            quit = true;
         }
      }
   }

   //Free the surface and go out
   clean_up();

   return 0;
}
示例#30
0
int main(int argc, char *argv[])
{
    int i = 0;

    char *filenames[argc - 1];
    Fileinfo *f_infos[argc - 1];

    for(i = 1; i < argc; i++)
    {
        filenames[i - 1] = argv[i];
    }

    //TODO: Expand absolute paths with tilde in it like '~/something.txt'
    //TODO: Expand relative paths '../something.txt'
    load_files(argc - 1, filenames, f_infos);
    for_each_fileinfo(argc - 1, f_infos, op_read_all);
    for_each_fileinfo(argc - 1, f_infos, op_cat);
    for_each_fileinfo(argc - 1, f_infos, op_close_all);


    return 0;
}