Example #1
1
int main()
{
   initscr();
   keypad(stdscr, TRUE);
   noecho();
   start_color();
   init_pair(1, COLOR_GREEN,   COLOR_BLACK);
   init_pair(2, COLOR_MAGENTA, COLOR_BLACK);
   finit(9,9,0,2);
   clear();
   printw(
   "      Etherial Void   \n\n"
   "Is it that all exists only in the\n"
   "etherial landscape of the mind?\n\n"
   "The past is uncertian,\n\n"
   "The present is now the past,\n\n"
   "The future might only be thought of.\n\n"
   "Is then not our mind's eye\n"
   "the root of reality?\n\n"
   "But should that eye be blind,\n"
   "where then would rest the soul?"
   "\n\n"
   "(press any key to continue)\n");
   getch();
   clear();
   printw(
   "   I look,\n"
   "but I see nothing.");
   getch();
   clear();
   getch();
   printw(
   "   Perhaps,\n"
   "there is nothing to see.");
   getch();
   helpmsg="Use the arrow keys or WASD to move the charecter.";
   clear();
   while(loop)
   {  
      switch(z)
      {  
         case 0:
            nroom=1;
            eroom=2;
            sroom=3;
            wroom=4;
            uroom=5;
            light=2;
            wall=
            "Some sort of wall mesage should be displayed here,\n"
            "It should inform the player of the solidity of this wall,\n"
            "and it should warn that attempts to surpass this fact are admonishable.";
            
            msg(9,6,
            "   I <do> see something:\n"
            "There seem to be dimly glowing etchings on the ground which signify,\n"
            "'There is naught to the north.'");

            msg(12,9,
            "   There is <something> here:\n"
            "In the ground there are shallow grooves filled with a\n"
            "faintly luminescent material. I cannot comprehend them.");
            if(sw[0]&&sw[1]&&sw[2]&&sw[3])
            {
               map[0][9][9]='^';
               smsg(9,9,
               "This is a new stairwell.");
            }
            break;
         case 1:
            sroom=0;
            lvr(9,9,0);
            break;
         case 2:
            wroom=0;
            wall=
            "There are some large deep grooves on the wall";
            lvr(9,9,1);
            break;
         case 3:
            nroom=0;
            lvr(9,9,2);
            break;
         case 4:
            eroom=0;
            lvr(9,9,3);
            break;
         case 5:
            eroom=6;
            droom=1;
            break;
         case 6:
            wroom=5;
            break;
         default:
            endwin();
            printf("Error: 42\n");
            loop=0;
            exit(42);
      }
      unmove();
      uncover(0);
      showmap();
      input();
   }
   endwin();
   return 0;
}
void game::start()
{int i=0;
     player player1(IMG_Load("megaman.gif"));
    Uint32 start;
   while(run)
    {start=SDL_GetTicks();
        handle_events();

       if(direction[2])
       {
           player1.setjump();
       }
       if(direction[0])
       {if(player1.getrect()->x>0)
        player1.setxvel(-1);
        else
        {
           camera.x--;
       base::coord.x--;
        }
       if(camera.x<=0)
       {camera.x++;base::coord.x++;}
       }
        else if(direction[1])
       {
           {if(player1.getrect()->x<60)
        player1.setxvel(1);
        else
        { player1.setxvel(0);
           camera.x++;
       base::coord.x++;
        }
       if(camera.x>1280-640)
       camera.x=0;
       }
       }
    else
    player1.setxvel(0);
        SDL_BlitSurface(back,&camera,screen,NULL);
         player1.move();
      if(gun)

          bullets=(new bullet(fire,player1.getrect()->x+player1.getrect()->w-11,player1.getrect()->y+15,10,0));

          bullets->move();
        player1.showplayer();
        showmap();
        bullets->show();
     SDL_Flip(screen);

     if(1000/30>(SDL_GetTicks()-start))
     SDL_Delay(1000/30-(SDL_GetTicks()-start));
    }

}
Example #3
0
File: horse.c Project: Alexoner/dsa
void visit(Point *poi,int n,int i)
{
    int j;//CRITICAL!!!
    printf("the %dth step\n",n+1);
	poi[n+1].x=poi[n].x+a[i];
	poi[n+1].y=poi[n].y+b[i];
	map[poi[n+1].x][poi[n+1].y]=n+2;
    showmap();
	for(j=0;j<8;j++)
    {
        if(right(poi,n+1,j)==1)
        {
            visit(poi,n+1,j);
            map[poi[n+2].x][poi[n+2].y]=0;
        }
        else if(right(poi,n+1,j)==MAX)
        {
            printf("done\n");
            showpath();
            return;
        }
    }
}
Example #4
0
int main(void)
{
printf(	
   "\n   I am now awake,\n"
   "I know this because when my eyes where closed "
   "I saw nothing but black darkness,\n"
   "and now that my eyes are open I see nothing...\n"
   "...but white fog.\n\n"

   "   I get up,\n"
   "I feel sturdy ground beneath my feet,\n"
   "but an infernal abyss inside my mind.\n");
   while(loop==1)
   {
      
      if(z == 0)
      {
         /*-input,cls&roommsg-*/
         
         takeinp();
         int i; for(i=0; i != 60; i++) printf("\n"); // clear screen
         rmsg("type w a s or d to move.\n");
         
         /*-walls&objects-*/
         
         room(0,8,0,8,
         "   I see a great white wall forever rising to infinity...\n"
         "...How bland.");
         
         elev(6,2,4,13,1,
         "   An elegant glass box materializes out of the mist,\n"
         "it has a height twice its length and width,\n"
         ">>I wonder if I should go inside, Yes or No : ",
         "I decide not to enter the box.");
         
         /*switches&effects*/
         
         lvr(0,2,6,"I have found a lever. Do I pull it? ",
         "",
         "I have already pulled this lever.");
         
         /*-map&coordinates-*/
         
         showmap(9,9,2,map0);
         printf("%i,%i,%i\n",x,y,z);
      
      }
      if(z == 1)
      {
         /*-input,cls&roommsg-*/
         
         takeinp();
         int i; for(i=0; i != 60; i++) printf("\n"); // clear screen
         rmsg(
         "   I step into the elevator and the machine begins to hum\n" 
         "as the doors close behind me.\n"
         "I notice the elevator has no buttons inside as it starts to move.\n"
         "The elevator continues for a time.\n\n"

         "   The doors open with a hiss.\n"
         "I step outside and look at the space where I have been deposited,\n"
         "The white mist is still there, but I can see the ceiling now.\n" 
         "There is a three dimensional network of pipes on the aforementioned ceiling.\n");
         
         /*-walls&objects-*/

         char wall[] =
         {"   I see a network of pipes barring my way in that direction,\n"
          "some of the tubes rising to the ceiling are warm "
          "and others are very cold."};
         char pillar[] =
         {"   There is an unstable pillar before me.\n"
          "It reminds me of the foundation to all logic and reason."};
         
         block(2,2,11,14,wall);
         block(6,6,11,14,wall);
         block(3,5,14,14,wall);
         block(1,3,8, 10,"you hit a tube");
         block(5,7,8, 10,"you hit a tube");
         block(0,0,0, 8 ,wall);
         block(8,8,0, 8 ,wall);
         block(0,8,0, 0 ,wall);
         block(4,4,6, 6 ,pillar);
         block(6,6,4, 4 ,pillar);
         block(4,4,2, 2 ,pillar);
         block(2,2,4, 4 ,pillar);
         
         elev(4,12,6,3,0,"I see an elevator, enter? ","I don\'t enter.");

         /*switches&effects*/
         
         if(sw[0])
         {
	        map1[4][4]='E';elev(4,4,9,9,2,
            "I see an elevator, enter? ",
            "I don\'t enter.");
         }
         else 
         {
		    msg(4,4,4,4,
            "   My foot scrapes against a rough spot on the ground,\n"
            "I look down and see a complex geometric design,\n"
            "surrounded by an inscription:\n\n"
         
            "      2,6,0");
         }

         /*-map&coordinates-*/

         showmap(15,9,2,map1);
         printf("%i,%i,%i\n",x,y,z);
      
      }
      if( z== 2)
      {
	      /*-input,cls&roommsg-*/
	      takeinp();
         int i; for(i=0; i != 60; i++) printf("\n"); // clear screen
         rmsg(
         "A voice echoes throught the room;\n\n"

         "\"Welcome to the Infinite Cube,\n"
         "The Cube is a prototype in alternate-reality technology.\n"
		 "You may ask how we know this space is a cube if it is, as has been previously stated, infinite.\n"
		 "Don\'t.\n\n"
         "It consists of several levels,\n"
         "designed to test your mental abilities,\n"
         "which are being enhanced by experiments in the real world.\n"
         "You are perfectly safe...\n\n" 
         "... as far as we know.\"");
         
         /*-walls&objects-*/
         char cube[]=
         {"   You see a large cube.\n"
          "It is inscribed with strange symbols.\n"
          "They seem to indicate the turning of a lever...\n"
          "...this is giving me second thoughts about turning that lever."};
                  
         block(4 ,6 ,8 ,10,cube);
         block(8 ,10,4 ,6 ,cube);
         block(12,14,8 ,10,cube);
         
         char wall[]=
         {""};
         
         block(7 ,11,0 ,0, wall);
         block(5 ,7 ,0 ,5 ,wall);
         block(0 ,5, 5, 7 ,wall);
         block(0 ,0 ,7 ,11,wall);
         block(0 ,5 ,11,13,wall);
         block(5 ,7 ,13,18,wall);
         block(7 ,11,18,18,wall);
         block(11,13,13,18,wall);
         block(13,18,11,13,wall);
         block(18,18,7 ,11,wall);
         block(13,19,5 ,7 ,wall);
         block(11,13,0 ,5 ,wall);

         //...cont. in book
         
         /*switches&effects*/
         lvr(1,9,11,"I see a lever, do I pull it? ",
         "",
         "I already pulled the lever");
         
         if(sw[1])
         {
	        map2[13][9]=' ';
	        msg(8 ,10,12,14,
	        "I see the cube around me,\n"
	        "but I can't touch it.");
		 }
         else
         {block(8 ,10,12,14,cube);}
         
         /*-map&coordinates-*/
         showmap(19,19,4,map2);
         printf("%i,%i,%i\n",x,y,z);
         
	  }
   
   
   }
  return 0 ;
}
Example #5
0
int main()
{  finit( 9, 9, 0, 3);
   int n; /* having a spare int is useful. */
   time_t t;
   printw(
   "   This game is so interesting and meaningfull\n"
   "and the reasons why are explained in this message...\n"
   "...which may or may not be complete\n"
   "\n"
   "(press any 3 keys to continue)\n");
   getch();
   getch();
   getch();
   clear();

   #include "objects.h"

   while(loop)
   {  
      switch(z)
      {  
         case 0:
            uroom[0]=5;
            wroom[0]=1;
 
            wall=
            "Some sort of wall mesage should be displayed here,\n"
            "It should inform the player of the solidity of this wall,\n"
            "and it should warn that attempts to surpass this fact are admonishable.";

            event(11,11,30,"hello");
            event(11,11,31,"hello again");
            event(11,11,32,"hello a third time");

            mesage[0][0].x  =12;
            mesage[0][0].y  =12;
            mesage[0][0].ch='*';
            mesage[0][0].hit="Hello sir, this is a structure mesage";
 
            msg(8,9,
            "THIS SPOT IS IMPORTANT FOR THIS REASON");
            smsg(2,9,
               "   This spot is UBER important :)\n"
               "It clears the screen to show you something!!!! \n");
            smsg(2,9,
               "   And it can do it twice!!!\n");
            smsg(2,9,
               "\n"
               "And thrice as well!!! :)");
            if(sw[0])
            {
               smsg(9,9,
               "This is a new stairwell.");
            }
            break;
         case 1:
            wall=
            "this is a wall in room 1";
            droom[1]=2;
            eroom[1]=0;
            sroom[1]=4;
            break;
         case 2:
            wall=
            "this is a more interesting wall in room 2";
            sroom[2]=3;
            uroom[2]=1;
            break;
         case 3:
            wall=
            "in room 3, the wall is so interesting, it's unsurpassable...";
            nroom[3]=2;
            break;
         case 4:
            wall=
            "...when it's not compared to these walls in room 4\n"
            "(see room 3's walls)";
            
            smsg(6,14,
            "   this is an object of\n"
            "INSURMOUNTABLE POWER...\n"
            "It will somehow help you on your\n"
            "QUEST,\n"
            "(which has neither been defined nor\n"
            "ACCEPTED)...\n"
            "\n"
            "...once the master programmer imbues\n"
            "it with the power to do such.\n"
            "\n"
            "Until then, walk from here back to\n"
            "THE BEGINING,\n"
            "and from there to here 9 times 7.\n"
            "\n");
             
            smsg(6,14,
            "+-----------------------------------+"
            "|                                   |"
            "|                                   |"
            "|            ????                   |"
            "|          ??  ? ???                |"
            "|            ??     ??              |"
            "|             ####    ?   ####      |"
            "|          ###    ##   ? ##  ##     |"
            "|        ##     ?   #  ?     ##     |"
            "|      ##     ?   o   ?     ##      |"
            "|     ##     ?  #   ?     ##        |"
            "|     ##  ## ?   ##    ###          |"
            "|      ####   ?    ####             |"
            "|              ??     ??            |"
            "|                ??? ?  ??          |"
            "|                   ????            |"
            "|                                   |"
            "|                                   |"
            "+-----------------------------------+");

            smsg(6,14,
            "   The Master Programmer hath spoken."
            "He hath declared that the way forth  "
            "shall become clear if you retrace    "
            "your steps to your point of origin.  ");

            lvr(6,14,0);
            if(sw[0]==1)
            {
               map[0][9][9]='^';
               sw[0]==2;
            }
            nroom[4]=1;
            break;
         case 5:
            wall=
            "there is nothing extra-ordinary about these walls";
            droom[5]=0;
            nroom[5]=6;
            smsg(9,8,
            "\n\n\n   Time:\n"
            "all encompasing,\n"
            "inescapable...\n");
            
            smsg(9,1,
            "\n\n\n...incorporeal.\n\n"
            "   In Time\n" /* "Time" which refers to the clock, is a proper noun in this case*/
            "The Trinity will point forward...");

            lvr(9 , 4,1);
            lvr(13, 5,2);
            lvr(14,9 ,3);
            lvr(13,13,4);
            lvr(9 ,14,5);
            lvr(5 ,13,6);
            lvr(4 , 9,7);
            lvr(5 , 5,8);

            if(sw[1]&&sw[3]&&sw[5]&&sw[7]||sw[2]&&sw[4]&&sw[6]&&sw[8])
            {
               sw[1]=0;
               sw[2]=0;
               sw[3]=0;
               sw[4]=0;
               sw[5]=0;
               sw[6]=0;
               sw[7]=0;
               sw[8]=0;
            }
            if(sw[1]&&sw[4]&&sw[6]||sw[2]&&sw[5]&&sw[7]||sw[8]&&sw[5]&&sw[3])
            {
               map[5][0][ 8]=' ';
               map[5][0][ 9]=' ';
               map[5][0][10]=' ';
            }
            else
            {
               map[5][0][ 8]='-';
               map[5][0][ 9]='-';
               map[5][0][10]='-';
            }
            
            if(time(NULL)>t)
            {
            int a,b,c,d,e,f,g,h;
            a=sw[1]; //rotate lvrs
            b=sw[2];
            c=sw[3];
            d=sw[4];
            e=sw[5];
            f=sw[6];
            g=sw[7];
            h=sw[8];
            sw[1]=h;
            sw[2]=a;
            sw[3]=b;
            sw[4]=c;
            sw[5]=d;
            sw[6]=e;
            sw[7]=f;
            sw[8]=g;
            }
            t=time(NULL);
            break;
         case 6:
            sroom[6]=5;
            uroom[6]=7;

            map[5][0][ 8]=' ';
            map[5][0][ 9]=' ';
            map[5][0][10]=' ';

            msg( 9, 9,
            "...all will be of one substance...");

            lvr( 6, 6, 9);
            lvr(12, 6,10);
            lvr( 9, 7,11);
            lvr( 7, 9,12);
            lvr(11, 9,13);
            lvr( 9,11,14);
            lvr( 6,12,15);
            lvr(12,12,16);

            if(sw[ 9]==1)
            {
               flip(13);
               flip(14);
               sw[ 9]=2;
            }
            if(sw[10]==1)
            {
               flip(12);
               flip(14);
               sw[10]=2;
            }
            if(sw[11]==1)
            {
               flip(15);
               flip(16);
               sw[11]=2;
            }
            if(sw[12]==1)
            {
               flip(10);
               flip(16);
               sw[12]=2;
            } 
            if(sw[13]==1)
            {
               flip( 9);
               flip(15);
               sw[13]=2;
            }
            if(sw[14]==1)
            {
               flip( 9);
               flip(10);
               sw[14]=2;
            }
            if(sw[15]==1)
            {
               flip(13);
               flip(11);
               sw[15]=2;
            }
            if(sw[16]==1)
            {
               flip(11);
               flip(12);
               sw[16]=2;
            }
            lvr( 6, 6, 9);
            lvr(12, 6,10);
            lvr( 9, 7,11);
            lvr( 7, 9,12);
            lvr(11, 9,13);
            lvr( 9,11,14);
            lvr( 6,12,15);
            lvr(12,12,16);
            if(sw[9]&&sw[10]&&sw[11]&&sw[12]&&sw[13]&&sw[14]&&sw[15]&&sw[16])
              {map[6][9][9]='^';}
            
            break;
         case 7:
            uroom[7]=8;
            droom[7]=6;
            lvr( 5, 5,17);
            lvr(13, 5,18);
            lvr(13,13,19);
            lvr(5 ,13,20);
            
            for(n=17;n<20;n++)
            {
               if(sw[n]==1)
               {
                  flip(n+4);
                  flip(n+1);
                  flip(n);
               }
            }
            if(sw[20]==1)
            {
               flip(17);
               flip(24);
               flip(20);
            }
            mlvr( 5, 5,17);
            mlvr(13, 5,18);
            mlvr(13,13,19);
            mlvr(5 ,13,20);

            break;
         case 8:
            uroom[8]=9;
            droom[8]=7;

            lvr( 9, 9,30);

            lvr( 5, 5,21);
            lvr(13, 5,22);
            lvr(13,13,23);
            lvr(5 ,13,24);
            
            for(n=22;n<=24;n++)
            {
               if(sw[n]==1)
               {
                  flip(n-1);
                  flip(n+4);
                  flip(n-4);
                  flip(n);
               }
            }
            if(sw[21]==1)
            {
               flip(24);
               flip(25);
               flip(17);
               flip(21);
            }
            if(sw[30]==1)
            {
               int a,b,c,d;
               a=sw[21];
               b=sw[22];
               c=sw[23];
               d=sw[24];
               sw[21]=b;
               sw[22]=c;
               sw[23]=d;
               sw[24]=a;
               flip(30);
            }

            mlvr( 9, 9,30);
            mlvr( 5, 5,21);
            mlvr(13, 5,22);
            mlvr(13,13,23);
            mlvr(5 ,13,24);
            break;
         case 9:
            droom[9]=8;
            uroom[9]=10;
            lvr( 9, 9,29);

            lvr( 5, 5,25);
            lvr(13, 5,26);
            lvr(13,13,27);
            lvr(5 ,13,28);
            
            for(n=25;n<28;n++)
            {
               if(sw[n]==1)
               {
                  flip(n+1);
                  flip(n-4);
                  flip(n);
               }
            }
            if(sw[28]==1)
            {
               flip(25);
               flip(24);
               flip(28);
            }
            if(sw[29]==1)
            {
               int a,b,c,d;
               a=sw[25];
               b=sw[26];
               c=sw[27];
               d=sw[28];
               sw[25]=d;
               sw[26]=a;
               sw[27]=b;
               sw[28]=c;
               flip(29);
            }
            mlvr( 5, 5,25);
            mlvr(13, 5,26);
            mlvr(13,13,27);
            mlvr(5 ,13,28);

            break;
         default:
            endwin();
            printf("ERROR THE PROGGRAMMER HAS YET TO MAKE THIS LEVEL!!!\n");
            loop=0;
            return 1;
      }
      mesages();
      levers();
      BlockMessage();
      uncover(1);
      showmap();
      input();
   }

   endwin();
   return 0;
}
Example #6
0
          void game::start()
          {   float FPS=40;

                               SDL_Rect tmprect_surprises,tmprect_surprises2;
              int moneymove=0;

              Uint32 start;
              loadmap("map2.map");
            while(running)
            {
                start=SDL_GetTicks();
                handelevents();
                //logic
                if(direction[0])
                {
                    player1->setDirection('l');
                    if(player1->getRect()->x>80) //it was x>0
                        player1->setXvel(-1);
                    else{
                    camera.x--;
                    baseclass::coord.x--;
                    player1->setXvel(0);
                    }
                    if(camera.x<0)
                        camera.x=6400-screen_width;
                        //player1->set
                       // std::cout<<"la position de coord - est :"<<coord.x<<"la position de camera est :"<<camera.x<<std::endl;
                }
                     else if(direction[1])
                {

                    player1->setDirection('r');
                    if(player1->getRect()->x <80)
                        player1->setXvel(1);
                    else{
                     player1->setXvel(0);
                    camera.x++;
                    baseclass::coord.x++;
                    }
                    if(camera.x>=6400-screen_width)
                        camera.x=0;
                        // std::cout<<"la position de coord + est :"<<coord.x<<"la position de camera est :"<<camera.x<<std::endl;
                }
                else
                    player1->setXvel(0);
int start2=(baseclass::coord.x-(baseclass::coord.x%baseclass::tile_size))/baseclass::tile_size;
int end2=(baseclass::coord.x+baseclass::coord.w+(baseclass::tile_size-(baseclass::coord.x+baseclass::coord.w)%baseclass::tile_size))/baseclass::tile_size;
if(start2<0)
    start2=0;
if(end2>map1[0].size())
    end2=map1[0].size();
bool    nocollision=0;
for (int i=0;i<map1.size();i++)
    {
      for (int j=start2;j<end2;j++)
      {
         if( map1[i][j]==0)
            continue;
         SDL_Rect dest_rect={j*30-baseclass::coord.x,i*30,30,30};
          for (int g=0;g<bullets.size();g++)
          {
            if(collision(bullets[g]->getRect(),&dest_rect))
               {
                 b1->setFrame(1);
                               // b1->setX(bullets[g]->getRect()->x+20);
                               if(player1->getDirection()=='r')
                               b1->setX(j*30-14);
                               else
                                b1->setX(j*30+24);
                                b1->setY(bullets[g]->getRect()->y);

                delete bullets[g];

                bullets.erase(bullets.begin()+g);
                }
           }

                             for (int j=0;j<Champignons.size();j++)
                          {
                              SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30};

        for (int k=0;k<Champignons.size();k++)
                              {
                                  if(k!=j){


                                SDL_Rect tmprect2 ={Champignons[k]->getRect()->x-baseclass::coord.x,Champignons[k]->getRect()->y,30,30};
                                if (collision(&tmprect,&tmprect2))
                                {
                                   Champignons[j]->setxvel(1);
                                   Champignons[j]->setdirection('r');
                                   Champignons[k]->setxvel(-1);
                                   Champignons[k]->setdirection('l');
                                   std::cout<<"here is collision between two enemies "<<std::endl;
                                }
                              }
                             }



                             }

                               for (int j=0;j<Champignons.size();j++)
                          {
                              SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30};

                             for (int k=0;k<Tortues.size();k++)
                              {


                                SDL_Rect tmprect2 ={Tortues[k]->getRect()->x-baseclass::coord.x,Tortues[k]->getRect()->y,30,30};
                                if ((tmprect.x+30==tmprect2.x)&&(Tortues[k]->getetat()==2)&&(Champignons[j]->getPuissance()==1))
                                {
                                   Champignons[j]->setxvel(-1);
                                   Champignons[j]->setdirection('r');
                                   Tortues[k]->setxvel(1);
                                   Tortues[k]->setdirection('l');
                               }else
                                if ((tmprect.x==tmprect2.x+30)&&(Tortues[k]->getetat()==2)&&(Champignons[j]->getPuissance()==1))
                                {
                                   Champignons[j]->setxvel(1);
                                   Champignons[j]->setdirection('r');
                                   Tortues[k]->setxvel(-1);
                                   Tortues[k]->setdirection('l');
                               }else
                                if ((tmprect.x==tmprect2.x+30)&&(Tortues[k]->getetat()==1)&&(Champignons[j]->getPuissance()==1))
                                {
                                   delete Champignons[j];
                                   Champignons.erase(Champignons.begin()+j);

                               }
                               else
                                if ((tmprect.x+30==tmprect2.x)&&(Tortues[k]->getetat()==1)&&(Champignons[j]->getPuissance()==1))
                                {
                                   delete Champignons[j];
                                   Champignons.erase(Champignons.begin()+j);

                               }

                             }
                          }

                            for (int j=0;j<Tortues.size();j++)
                          {
                              SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30};

                               for (int k=0;k<Tortues.size();k++)
                              {
                                  if(k!=j){


                                SDL_Rect tmprect2 ={Tortues[k]->getRect()->x-baseclass::coord.x,Tortues[k]->getRect()->y,30,30};
                                if ((collision(&tmprect,&tmprect2))&&(Tortues[j]->getetat()!=1)&&(Tortues[k]->getetat()!=1))
                                {
                                   Tortues[j]->setxvel(1);
                                   Tortues[j]->setdirection('r');
                                   Tortues[k]->setxvel(-1);
                                   Tortues[k]->setdirection('l');
                                   std::cout<<"here is collision between two tortues "<<std::endl;
                                }
                                if (collision(&tmprect,&tmprect2)&&Tortues[j]->getetat()==1)
                                {
                                     delete Tortues[k];
                                     Tortues[j]->setxvel(5);
                                    Tortues.erase(Tortues.begin()+k);
                                }
                              }
                             }
                          }







        }
        }
                   for (int i=0;i<bullets.size();i++)
                    {
                      if((bullets[i]->getRect()->x >= screen->w)||(bullets[i]->getRect()->x  <=0))
                        {
                         delete bullets[i];
                         bullets.erase(bullets.begin()+i);
                        }
                         }
                         for (int i=0;i<bullets.size();i++)
                         {
                          for (int j=0;j<Champignons.size();j++)
                          {
                              SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30};
                              if(collision(&tmprect,bullets[i]->getRect()))
                              {
                                b1->setFrame(1);
                                b1->setX(Champignons[j]->getRect()->x);
                                b1->setY(Champignons[j]->getRect()->y);
                                 delete bullets[i];
                                 delete Champignons[j];
                                 bullets.erase(bullets.begin()+i);
                                 Champignons.erase(Champignons.begin()+j);
                              }
                          }
                          for (int j=0;j<Tortues.size();j++)
                          {
                              SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30};
                              if(collision(&tmprect,bullets[i]->getRect()))
                              {
                                b1->setFrame(1);
                                b1->setX(Tortues[j]->getRect()->x);
                                b1->setY(Tortues[j]->getRect()->y);
                                 delete bullets[i];
                                 delete Tortues[j];
                                 bullets.erase(bullets.begin()+i);
                                 Tortues.erase(Tortues.begin()+j);
                              }
                          }




                         }


                         for (int i=0;i<bullets.size();i++)
                         {
                          for (int j=0;j<fleur_toxiques.size();j++)
                          {
                              SDL_Rect tmprect ={fleur_toxiques[j]->getRect()->x-baseclass::coord.x,fleur_toxiques[j]->getRect()->y,30,30};
                              if(collision(&tmprect,bullets[i]->getRect()))
                              {
                                b1->setFrame(1);
                                  b1->setX(fleur_toxiques[j]->getRect()->x);
                                b1->setY(tmprect.y);
                               delete bullets[i];
                                 delete fleur_toxiques[j];
                                 bullets.erase(bullets.begin()+i);
                                 fleur_toxiques.erase(fleur_toxiques.begin()+j);
                              }
                          }
                         }

                               for (int j=0;j<Champignons.size();j++)
                          {
                              int set_life_power=0;
                              SDL_Rect tmprect ={Champignons[j]->getRect()->x-baseclass::coord.x,Champignons[j]->getRect()->y,30,30};
                                 if(collision(&baseclass::coord,Champignons[j]->getRect()))
                                 {
                              if(collision(&tmprect,player1->getRect()))
                              {
                                 std::cout<<"collesion enemy yvel  "<<tmprect.y<< "pleyer y vel "<<player1->getRect()->y<<std::endl;
                               if((player1->getRect()->y< tmprect.y )&&(Champignons[j]->getPuissance()>0))
                               {
                                   Champignons[j]->setpuissance(0);
                                   std::cout<<"collesion enemy yvel  "<<Champignons[j]->getFrame()<<std::endl;
                                  // delete Champignons[j];
                                   // Champignons.erase(Champignons.begin()+j);
                               }
                               else
                                if((player1->getRect()->y==tmprect.y )&&(set_life_power>=0)&&(Champignons[j]->getPuissance()>0))
                                {

                                     player1->setHealth(-1);
                                   //std::cout<<"enemy killl me et mon lhealth est  :"<<player1->getHealth();
                                   delete Champignons[j];//version before i was neot here
                                    Champignons.erase(Champignons.begin()+j); //version before i was neot here
                                }
                              }
                              if((player1->getRect()->x> tmprect.x+60||player1->getRect()->x < tmprect.x-60)&&(Champignons[j]->getPuissance()==0))
                              {
                                  delete Champignons[j];//version before i was neot here
                                    Champignons.erase(Champignons.begin()+j); //version before i was neot here

                              }
                              Champignons[j]->move(map1);
                              }
                               }
                               for (int j=0;j<Tortues.size();j++)
                          {   bool setEtat =false;
                              SDL_Rect tmprect ={Tortues[j]->getRect()->x-baseclass::coord.x,Tortues[j]->getRect()->y,30,30};
                                 if(collision(&baseclass::coord,Tortues[j]->getRect()))
                                 {
                              if(collision(&tmprect,player1->getRect()))
                              {
                                 std::cout<<"collesion enemy yvel  "<<tmprect.y<< "pleyer y vel "<<player1->getRect()->y<<std::endl;
                               if((player1->getRect()->y< tmprect.y )&&(Tortues[j]->getetat()==2))
                               {
                                   Tortues[j]->setetat(1);
                                  // delete Tortues[j];
                                   // Tortues.erase(Tortues.begin()+j);
                               }
                               else  if((player1->getRect()->y== tmprect.y )&&(Tortues[j]->getetat()==2))

                                {
                                     player1->setHealth(-1);
                                   //std::cout<<"enemy killl me et mon lhealth est  :"<<player1->getHealth();
                                   delete Tortues[j];//version before i was neot here
                                    Tortues.erase(Tortues.begin()+j); //version before i was neot here
                                }
                              }
                              Tortues[j]->move(map1);
                              }
                               }








                               for (int i=0;i<moneis.size();i++)
                               {
                                   SDL_Rect tmprect ={moneis[i]->getRect()->x-baseclass::coord.x,moneis[i]->getRect()->y,30,30};


                                 if(collision(&tmprect,player1->getRect()))
                              {
                                   delete moneis[i];//version before i was neot here
                                    moneis.erase(moneis.begin()+i); //version before i was neot here
                                   player1->setmoney(1);
                                   if (player1->getmoney()==100)
                                   {
                                    player1->setmoney(0);
                                    player1->setHealth(1);
                                   }

                              }



                               }

                                for (int i=0;i<surprises.size();i++)
                               {
                                    tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};
                                    if((player1->getRect()->x+15>=tmprect_surprises.x)&&(player1->getRect()->x<=tmprect_surprises.x+20)&&(player1->getRect()->y==tmprect_surprises.y+40))
                                      {
                                           moneymove=1;
                                           tmprect_surprises2={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};

                                          std::cout<<"player get y"<<player1->getRect()->y<<std::endl;

                                   if (player1->getmoney()==100)
                                   {
                                   }
                                     }
                                   }
                                   for (int i=0;i<fleur_ames.size();i++)
                               {
                                 SDL_Rect tmprect ={fleur_ames[i]->getRect()->x-baseclass::coord.x,fleur_ames[i]->getRect()->y,30,30};

                               if(collision(player1->getRect(),&tmprect))
                               {
                                  delete fleur_ames[i];
                                 fleur_ames.erase(fleur_ames.begin()+i);
                                    player1->setpower(1);
                               }
                               }

                                  for (int i=0;i<fleur_toxiques.size();i++)
                               {
                                 SDL_Rect tmprect ={fleur_toxiques[i]->getRect()->x-baseclass::coord.x,fleur_toxiques[i]->getRect()->y,30,30};

                               if(collision(player1->getRect(),&tmprect)&&fleur_toxiques[i]->getmouvement()==true)
                               {
                                    player1->setpower(-1);
                               }
                               }

                                   if (moneymove>0 && moneymove<30)
                                    {
                                    moneymove++;
                                     for (int i=0;i<surprises.size();i++)
                                     {
                                        tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};
                                       if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false)
                                        {




                                            if (i!=2&&moneymove==5)
                                                     {
                                                      monies_surp.push_back(new money(mon2,surprises[i]->getRect()->x,tmprect_surprises.y-60,-1,0)); //because every tile is TILE_SIZE width and height, we can calculate
                                                      }








                                        surprises[i]->setY(-1);


                                        }
                                     }



                                    }
                                    if (moneymove>=30 && moneymove<=59)
                                        {


                                            moneymove++;

                                        for (int i=0;i<surprises.size();i++)
                                     {
                                        tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};
                                       if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false)
                                        {   if (i==2&&moneymove==31)
                                        {
                                             fleur_ames.push_back(new fleur_ame(fleur_am1,surprises[i]->getRect()->x-1,tmprect_surprises.y,10,0)); //because every tile is TILE_SIZE width and height, we can calculate

                                           }

                                        surprises[i]->setY(1);
                                       }
                                     }


                                     }





                                       for (int i=0;i<monies_surp.size();i++)
                                     {

                                      if (monies_surp[i]->getFrame()>1.5)
                                      {
                                            delete monies_surp[i];
                                        monies_surp.erase(monies_surp.begin()+i);
                                        player1->setmoney(1);
                                         if (player1->getmoney()>100)
                                         {
                                             player1->setHealth(1);
                                             player1->setmoney(0);

                                         }

                                      }

                                     }





                                     if (moneymove==59)
                                        {
                                        for (int i=0;i<surprises.size();i++)
                                        {
                                        tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};
                                       if (tmprect_surprises.x==tmprect_surprises2.x&& surprises[i]->getmovement()==false){


                                        surprises[i]->setmovement(true);
                                        surprises[i]->setFrame(3);
                                        player1->setpower(1);
                                        }
                                     }
                                     }

                                       /*for (int i=0;i<surprises.size();i++)
                               {*/
                                    //tmprect_surprises ={surprises[i]->getRect()->x-baseclass::coord.x,surprises[i]->getRect()->y,30,30};

                                     // }
                                     //surprises[i]->setmovement(true);








                    for (int i=0;i<bullets.size();i++)
                       {
                       bullets[i]->setangle(20);
                       bullets[i]->move();

                       }

                player1->move(map1);

                   if(1000/FPS>SDL_GetTicks()-start)
                    {
                    SDL_Delay(1000/FPS-(SDL_GetTicks()-start));
                       }

                time++;
                if(time>15)
                    {
                        time=0;
                        temps2--;
                    }
                //render

                SDL_BlitSurface(background,&camera,screen,NULL);
            b1->show2(screen);
               relatifdetails("Mario Bross World 1 ");
               currenttime();
                showmap();
                player1->showplayer(screen);

//                playe->show2(screen);
//                su->show(screen);
                 for (int i=0;i<bullets.size();i++)
                {
            bullets[i]->show("bullet2.bmp",screen);

               }
                for (int i=0;i<surprises.size();i++)
             {
            surprises[i]->show(screen);
             }
              for (int i=0;i<fleur_toxiques.size();i++)
              {
                  fleur_toxiques[i]->show(screen);
              }
              for (int i=0;i<fleur_ames.size();i++)
             {
            fleur_ames[i]->show(screen);
             }
               for (int i=0;i<moneis.size();i++)
             {
            moneis[i]->show(screen);
             }

              for (int i=0;i<monies_surp.size();i++)
             {
               monies_surp[i]->show2(screen);
             }
                 for (int i=0;i<Champignons.size();i++)
                  {
                    Champignons[i]->show(screen);
                 }
        for (int i=0;i<Tortues.size();i++)
                  {
                    Tortues[i]->show(screen);
                 }


                SDL_Flip(screen);
                if(temps2==0||player1->getHealth()==0 || player1->getRect()->y >=screen->h)//||player1->getRect())
                {
                    running=false;
                    SDL_Delay(3000);
                   showmessage("Game Over");
                }
                SDL_Rect tmprect2={finish.x-coord.x,finish.y,30,30};
                if(player1->getRect()->x+player1->getRect()->w>= tmprect2.x-tmprect2.w*2)
                {
                    showmessage("You win");
                    SDL_Delay(1000);
                    running=false;
                }

                   if(1000/FPS>SDL_GetTicks()-start)
                    {
                    SDL_Delay(1000/FPS-(SDL_GetTicks()-start));
                       }
            }
          }