How hide picture

Hello!

how {as} hide the surface {area} (ufo.bmp) with read in function:

//code…

apply_surface(100,100,ufo,screen);

//how hide the surface ufo?

Quoting krzysztof posluszny :

Hello!

how {as} hide the surface {area} (ufo.bmp) with read in function:

//code…

apply_surface(100,100,ufo,screen);

//how hide the surface ufo?

i’m pretty good a writing crypic questions to this list but this is
even beyond
me

you might like to explain what it is you are trying to do a little more

Wow, yeah, that’s, uh…

ANyway, to GUESS< I think they’re drawing a UFO on the screen,
and they want to erase it. Probably it’s trailing along the
screen as they move it or something.

Redraw what was under the UFO, by first capturing it into a new
surface (blitting that part of “screen” into the new surface).

Or, simply redraw whatever you have on the screen (a background image,
a solid color, whatever) in the location.

Look up: dirty rectangles while you’re at it. :)On Thu, Apr 24, 2008 at 05:23:57PM +0100, neil at cloudsprinter.com wrote:

Quoting krzysztof posluszny :

Hello!

how {as} hide the surface {area} (ufo.bmp) with read in function:

//code…

apply_surface(100,100,ufo,screen);

//how hide the surface ufo?

i’m pretty good a writing crypic questions to this list but this is
even beyond
me

you might like to explain what it is you are trying to do a little more


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/

Before drawing everything on the screen:

SDL_FillRect( screen, NULL, SDL_MapRGB( screen->format, 0, 0, 0 ) );
//0 0 0 = R, G, B; 255 0 0 = Red Screen; 0 255 0 = Green Screen

Good luck.> From: wojownik266 at wp.pl

To: sdl at lists.libsdl.org
Date: Thu, 24 Apr 2008 18:09:26 +0200
Subject: [SDL] HOW HIDE PICTURE

Hello!

how {as} hide the surface {area} (ufo.bmp) with read in function:

//code…

apply_surface(100,100,ufo,screen);

//how hide the surface ufo?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Express yourself wherever you are. Mobilize!
http://www.gowindowslive.com/Mobile/Landing/Messenger/Default.aspx?Locale=en-US?ocid=TAG_APRIL

I would like so that the small picture “ufo” appear for a moment and
disappeared.

Please for the advice as this to make. Below program code:

#include <SDL/SDL.h>
#include <SDL/SDL_Image.h>
#include
#include
//Atrybuty ekranu
const int SCREEN_WIDTH = 340;
const int SCREEN_HEIGHT = 280;
const int SCREEN_BPP = 32;
bool quit=false;
SDL_Event event;
SDL_Surface *screen = NULL;
SDL_Surface *ufo = NULL;

bool init()
{
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return false;
}

//Set up the screen
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, 

SDL_SWSURFACE );

//If there was in error in setting up the screen
if( screen == NULL )
{
    return false;
}

//Set the window caption
SDL_WM_SetCaption( "GAME", NULL );

//If everything initialized fine
return true;

}

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface*
destination, SDL_Rect* clip = NULL )
{
//Holds offsets
SDL_Rect offset;
x=rand()/5;
y=rand()/5;
//Get offsets
offset.x = x;
offset.y = y;

//Blit
SDL_BlitSurface( source, clip, destination, &offset );

}
//The timer
class Timer
{
private:
//The clock time when the timer started
int startTicks;

//The ticks stored when the timer was paused
int pausedTicks;

//The timer status
bool paused;
bool started;

public:
//Initializes variables
Timer();

//The various clock actions
void start();
void stop();
void pause();
void unpause();

//Get the number of ticks since the timer started
//or gets the number of ticks when the timer was paused
int get_ticks();

//Checks the status of the timer
bool is_started();
bool is_paused();

};
Timer::Timer()
{
//Initialize the variables
startTicks = 0;
pausedTicks = 0;
paused = false;
started = false;
}

void Timer::start()
{
//Start the timer
started = true;

//Unpause the timer
paused = false;

//Get the current clock time
startTicks = SDL_GetTicks();

}

void Timer::stop()
{
//Stop the timer
started = false;

//Unpause the timer
paused = false;

}

void Timer::pause()
{
//If the timer is running and isn’t already paused
if( ( started == true ) && ( paused == false ) )
{
//Pause the timer
paused = true;

    //Calculate the paused ticks
    pausedTicks = SDL_GetTicks() - startTicks;
}

}

void Timer::unpause()
{
//If the timer is paused
if( paused == true )
{
//Unpause the timer
paused = false;

    //Reset the starting ticks
    startTicks = SDL_GetTicks() - pausedTicks;

    //Reset the paused ticks
    pausedTicks = 0;
}

}

int Timer::get_ticks()
{
//If the timer is running
if( started == true )
{
//If the timer is paused
if( paused == true )
{
//Return the number of ticks when the the timer was paused
return pausedTicks;
}
else
{
//Return the current time minus the start time
return SDL_GetTicks() - startTicks;
}
}

//If the timer isn't running
return 0;

}

bool Timer::is_started()
{
return started;
}

bool Timer::is_paused()
{
return paused;
}
int main(int argc,char *argv[])
{
if((init())==0)
{
SDL_GetError();
return 1;
}

    //Set up the screen
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, 

SDL_SWSURFACE );

//If there was in error in setting up the screen
if( screen == NULL )
{
    return false;
}
ufo=SDL_LoadBMP("czaszka.bmp");

//While the user hasn't quit
while( quit == false )
{
    //Start the frame timer
    Timer fps;
    fps.get_ticks();
    fps.start();
    apply_surface(rand(),rand(),ufo,screen);

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

        }
    }

SDL_Flip(screen);

}

}

To apologize for my English

Quoting krzysztof posluszny :

I would like so that the small picture “ufo” appear for a moment and
disappeared.

you need to put something ‘back over’ the ufo to dissapear it

if you put a backround image and plot that each loop then the ufo after
that the
background will wipe out the old ufo position

or you can take a ‘snap’ of the screen area you are going to put the ufo, then
put the screen back after-

psudo code

ufo.x = random ( xsize )
ufo.y = random ( ysize )

temp-background-surface= rectangle ( ufo.x , ufo.y , ufo.width ,
ufo.height )

plot ufo

plot temp-background-surface

end psudo code

if system resources are not an issue you can just redraw a set
background image

otherwise use somthing similar to above psudo code

hope you can cope with my english!