// Construtor Padrão
	Tela::Tela() {
        audio = true;
        textColor = { 255, 255, 255 };
        set_clips(clipsGems);
        set_clips(clipsGems_dica);
        pontos = new Pilha();
        level = 1;
        changedLevel = true;
        fillMatriz(4);
        user = new Usuario();
    }
Animacion::Animacion(std::string nombre, Posicionable* animado, int prior,int alto, int ancho, vector<st_Animacion*> vectorAnimaciones, ID unId, std::string nombrePers)
					: Imagen(nombre, animado, prior,alto,ancho,unId, nombrePers)
{
	this-> frame = 0;  //Por defecto el frame 0 indica la posicion "quieto"
	this-> animado = animado;
	set_clips(vectorAnimaciones);
}
Exemple #3
0
Otter::Otter(std::string filename, int r, int g, int b):Sprite(4), SPRITE_DOWN(0), SPRITE_UP(1), SPRITE_WALK(2), ROLL(3){ //constructor
    //Initialize sprite dimensions
    height = 32;
    width = 32;

    //Initialize movement variables
    offSetY = -35;
    offSetX = 50;
    velocityX = 0;
    velocityY = 0;
	
    isStarting = true;

    //Initialize animation variables
    frame = 0;
    status = SPRITE_DOWN;

    //Sprite pointer
    sprite = load_image(filename,r,g,b);

    //Initialize States
    set_clips();
    
    isVisible = true;
    isDead = false;
}
Exemple #4
0
//------------------------------
// Main game loop
//------------------------------
int main(int argc, char* argv[])
{
    srand(time(0));
        
    if(sys_init() == false) { return 1; }
    if(sys_loadfiles() == false) { return 1; }
    
    set_clips();
    sys_configload();
    
    while(quit == false)
    {
        startTimer = SDL_GetTicks();
        
        sys_input();
        game_logic();
        draw_everything();
        
        //Update the screen
        if(SDL_Flip(screen) == -1) { return 1; }
            
        endTimer = SDL_GetTicks();
        deltaTimer = endTimer - startTimer;
        if ( deltaTimer < ( 1000 / FPS ))
        {
            SDL_Delay( ( 1000 / FPS ) - deltaTimer );
        }
    }
    
    sys_configupdate();
    sys_cleanup();
    
    return 0;
}
c_Animate::c_Animate( int eID )
{
	set_clips(eID);
	frameNo = 0;
	animType = eID;

	currentFrame = &defaultFrame;
}
Exemple #6
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;
}
Exemple #7
0
Tiles::Tiles(SDL_Rect &tposOffset, SDL_Surface* tScreen, int screen_width, int screen_height){
	image = load_image("res/tilesfix.png");
	if(image == NULL)
		std::cout << '1' << std::endl;
	screen = tScreen;
	posOffset = &tposOffset;
	set_clips();
	this->screen_width = screen_width;
	this->screen_height = screen_height;
}
Exemple #8
0
//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;
}
Exemple #9
0
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;
}
Exemple #10
0
int main (int argc, char* args[] ) {
    bool quit = false;

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

    buttonSheet = load_image("button.png");
    if( buttonSheet == NULL ) {
        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( event.type == SDL_QUIT ) {
                quit = true;
            }
        }

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

        //Show the button
        myButton.show();

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

    clean_up();

    return 0;
}
Exemple #11
0
CFire::CFire() {
	set_clips() ;

	state = FIRE_WALKING ;	//FIRE starts on the lowest platform

	xinit = FIRE_START_X ;
	yinit = FIRE_START_Y;

	x = xinit ;
	y = yinit ;

	width = FIRE_WIDTH ;
	height = FIRE_HEIGHT ;

	xVel = 1;
	yVel = 2;

}
Exemple #12
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;

}
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;
    }

    //Clip the sprite sheet
    set_clips();

    //The frame rate regulator
    Timer fps;

    //The stick figure
    Foo walk;

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

        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the stick figure
            walk.handle_events();

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

        //Move the stick figure
        walk.move();

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

        //Show the stick figure on the screen
        walk.show();

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

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }

    //Clean up
    clean_up();

    return 0;
}
Exemple #14
0
void dino_main()
{
    start= SDL_GetTicks();


    for(int i=0; i<600; i++)
    {
        randx[i]= rand()%600 + 1;
        randy[i]= rand()%420 + 1;

        if (randy[i]>220 && randy[i]<270)
        {
            randx[i]=randx[i-1];
            randy[i]=randx[i-1];

        }
    }


    bool quit = false;
    set_clips();

    //The frame rate regulator
    Timer fps;


    //The stick figure
    Foo walk;


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


        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the stick figure
            walk.handle_events();

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

        //Move the stick figure
        walk.move(randx,randy);

        //Fill the screen white
        //SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0, 0xFF, 0xFF ) );
        apply_surface(0,0,back_grass,screen);
        score_dis = TTF_RenderText_Solid( font, "Score", textColor );

        apply_surface( 460, 450, score_dis, screen );



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

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



        walk.show();
        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {

        }

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }

}
Exemple #15
0
Enemies::Enemies(SDL_Rect &camera){
	posOffset = camera;
	set_clips();
}
Exemple #16
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;
    }

  //Set the clips
  set_clips();

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

  //Apply the background
  int bkgd_loc = 0;
  for(int i=0; i<8; ++i ){
    for(int j=0; j<8; ++j){
      apply_surface( 16*i, 16*j, background, screen, &clip_background[ bkgd_loc ] );
      ++bkgd_loc;
    }
  }
  int neal_loc[2] = { 2, 2};
  apply_surface( neal_loc[0]*16, (neal_loc[1]-1)*16, sprite, screen, &clip_sprite[ 0 ] );

  //While the user hasn't quit
  while( quit == false )
    {

    //If there's an event to handle
    if( SDL_PollEvent( &event) )
      {
	//If a key is pressed
	if( event.type == SDL_KEYDOWN )
	  {
	  //Set the proper message surface
	    switch( event.key.keysym.sym )
	      {
	      case SDLK_UP:
		//Up Arrow Key
		/*Update background
		  apply_surface( neal_loc[0]*16, neal_loc[1]*16-8, background, screen, &clip_background[(neal_loc[0]+1)*8+neal_loc[1]+1]);*/
		//Update the background
		bkgd_loc = 0;
		for(int i=0; i<8; ++i ){
		  for(int j=0; j<8; ++j){
		    apply_surface( 16*i, 16*j, background, screen, &clip_background[ bkgd_loc ] );
		    ++bkgd_loc;
		  }
		}
		//Update location
		neal_loc[1]--;
		//Update sprite surface
		apply_surface( neal_loc[0]*16, (neal_loc[1]-1)*16, sprite, screen, &clip_sprite[ 0 ] );
		break;
	      case SDLK_DOWN:
		//Down Arrow Key
		//Update the background
		bkgd_loc = 0;
		for(int i=0; i<8; ++i ){
		  for(int j=0; j<8; ++j){
		    apply_surface( 16*i, 16*j, background, screen, &clip_background[ bkgd_loc ] );
		    ++bkgd_loc;
		  }
		}
		//Update location
		neal_loc[1]++;
		//Update sprite surface
		apply_surface( neal_loc[0]*16, (neal_loc[1]-1)*16, sprite, screen, &clip_sprite[ 0 ] );
		break;
	      case SDLK_LEFT:
		//Left Arrow Key
		//Update the background
		bkgd_loc = 0;
		for(int i=0; i<8; ++i ){
		  for(int j=0; j<8; ++j){
		    apply_surface( 16*i, 16*j, background, screen, &clip_background[ bkgd_loc ] );
		    ++bkgd_loc;
		  }
		}
		//Update location
		neal_loc[0]--;
		//Update sprite surface
		apply_surface( neal_loc[0]*16, (neal_loc[1]-1)*16, sprite, screen, &clip_sprite[ 0 ] );
		break;
	      case SDLK_RIGHT:
		//Right Arrow Key
		//Update the background
		bkgd_loc = 0;
		for(int i=0; i<8; ++i ){
		  for(int j=0; j<8; ++j){
		    apply_surface( 16*i, 16*j, background, screen, &clip_background[ bkgd_loc ] );
		    ++bkgd_loc;
		  }
		}
		//Update location
		neal_loc[0]++;
		//Update sprite surface
		apply_surface( neal_loc[0]*16, (neal_loc[1]-1)*16, sprite, screen, &clip_sprite[ 0 ] );
		break;
	      }
	  }

	//If the user has X'ed out the window
	else if(event.type == SDL_QUIT )
	  {
	    //Quit the program
	    quit = true;
	  }
      }

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

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

  return 0;
}
Exemple #17
0
int main(int argc, char* args[]) {

    //make sure the program waits for a quit
    bool quit = false;

    if (!init()) {
        std::cerr << "failed to initialize SDL" << std::endl;
        return 1;
    }

    //load files
    if(!load_files()) {
        std::cerr << "failed to load images" << std::endl;
        return 1;
    }

    set_clips();

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

    //display background
    apply_surface(0, 0, background, screen);
    apply_surface(320, 0, background, screen);
    apply_surface(0, 240, background, screen);
    apply_surface(320, 240, background, screen);
    //update screen
    if ( SDL_Flip(screen) == -1) {
        std::cerr << "error flipping screen" << std::endl;
        return 1;
    }

    //Pause
    while(!quit) {
        while( SDL_PollEvent(&event) ) {
            //handle buton events
            myButton.handle_events();

            //if user quits
            if(event.type==SDL_QUIT) {
                //quit program
                quit = true;
            }
        }
        apply_surface(0, 0, background, screen);
        apply_surface(320, 0, background, screen);
        apply_surface(0, 240, background, screen);
        apply_surface(320, 240, background, screen);
        myButton.show();

        //update screen
        if ( SDL_Flip(screen) == -1) {
            std::cerr << "error flipping screen" << std::endl;
            return 1;
        }


    }
    clean_up();

    return 0;
}