Help With If Statement

hi guys my first post here, basically im making a point and click game with SDL, and what i want the code to is, when i click on an image(barrel) the image will be replaced by another image(broken barrel) and also a key would appear.

if(barrelNormal.drawMe==true){
SDL_BlitSurface(barrelNormal.img1,NULL,screen,&barrelNormal.location);
}
else if(currentEvent.type == SDL_MOUSEBUTTONDOWN){ if(currentEvent.button.button == SDL_BUTTON_LEFT){
int mousex = currentEvent.motion.x;
int mousey = currentEvent.motion.y;

if( mousex > barrelNormal.location.x && mousex < barrelNormal.img1-> w + barrelNormal.location.x){
if( mousey > barrelNormal.location.y && mousey < barrelNormal.img1-> h + barrelNormal.location.y){

barrelNormal.drawMe== false;
SDL_BlitSurface(barrelBroken.img1,NULL,screen,&barrelBroken.location);
SDL_BlitSurface(key.img1,NULL,screen,&key.location);
}
It would be not bad if you would also say what is the problem with if statements.
sorry, there are no problems, its just the image doesnt go away, it just blits the other two images when the button is clicked and once let go they go awa.
I'm just a newbie as well, but it looks to me like not all of your block statements are properly enclosed. Notice how, using the code formatting feature and indents, you only have one closing bracket starting after your if-else statement. If I were the compiler, I'd be confused.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if(barrelNormal.drawMe==true){
SDL_BlitSurface(barrelNormal.img1,NULL,screen,&barrelNormal.location);
}	
else if(currentEvent.type == SDL_MOUSEBUTTONDOWN){
   if(currentEvent.button.button == SDL_BUTTON_LEFT){
      int mousex = currentEvent.motion.x;
      int mousey = currentEvent.motion.y;

      if( mousex > barrelNormal.location.x && mousex < barrelNormal.img1-> w + barrelNormal.location.x) { 
           if( mousey > barrelNormal.location.y && mousey < barrelNormal.img1-> h + barrelNormal.location.y){ 

                 barrelNormal.drawMe== false;
                 SDL_BlitSurface(barrelBroken.img1,NULL,screen,&barrelBroken.location);
                 SDL_BlitSurface(key.img1,NULL,screen,&key.location);
             }
Topic archived. No new replies allowed.