Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
939 connectés 

  FORUM HardWare.fr
  Programmation

   [ C ] Cherche idée de petit jeu à faire (newbie inside)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[ C ] Cherche idée de petit jeu à faire (newbie inside)

n°100538
Eniac
Da Mourfis' King
Posté le 14-02-2002 à 20:27:49  profilanswer
 

Salut,
 
Je cherche des idées de jeux assez simples à concevoir en C.  Je ne suis pas très avancé, j'ai juste vu les boucles, conditions, printf, scanf, random, tableaux, pointeurs.
J'en suis pas encore aux gets, puts, etc... donc ne me sortez pas un truc trop compliqué :)
 
C'est dans le genre MasterMind, combat naval, puissance 4...
 
Il faut absolument se servir des pointeurs.
 
Merci A+


---------------
If you really want something, all the Universe conspires in helping you to achieve it.
mood
Publicité
Posté le 14-02-2002 à 20:27:49  profilanswer
 

n°100566
Michrone
MVFLCQLEV
Posté le 14-02-2002 à 21:39:57  profilanswer
 

Eniac a écrit a écrit :

 
C'est dans le genre MasterMind, combat naval, puissance 4...




 
C'est pas bon ça ?
Sinon, tu peux tenter le jeux de dame, ou alors le jeux avec les cheveaux(me rappelle plus du nom).


---------------
Mieux vaut faire le con que l'être vraiment - www.lescons.be -
n°100579
Krueger
tout salaire demande dutravail
Posté le 14-02-2002 à 22:14:38  profilanswer
 

Un jeu qui peut être joué en mode textuel comme le Mastermind serait le plus facile à réaliser. Y aura pas ainsi à se faire chier avec les routines graphiques quoique c'est beaucoup plus moche alors... :sweat:


---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi
n°101071
Eniac
Da Mourfis' King
Posté le 15-02-2002 à 19:39:45  profilanswer
 

de toute manière c'est pour rester en ligne de commande DOS, pas pour faire du graphique
 
pas d'autres idées ?


---------------
If you really want something, all the Universe conspires in helping you to achieve it.
n°101080
Krueger
tout salaire demande dutravail
Posté le 15-02-2002 à 21:20:44  profilanswer
 

Un jeu à pion? Par exemple Morpion, Puissance 4, etc.
La grille se réaffiche à chaque fois en dessous de la précédente, mais bon...


---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi
n°101401
Eniac
Da Mourfis' King
Posté le 17-02-2002 à 11:12:10  profilanswer
 

tu peux pas faire un clearscreen puis réaffichage à chaque fois ?


---------------
If you really want something, all the Universe conspires in helping you to achieve it.
n°101424
HelloWorld
Salut tout le monde!
Posté le 17-02-2002 à 12:21:14  profilanswer
 

En mode texte, tu peux aussi faire un serpent ou un tron ;)


---------------
FAQ fclc++ - FAQ C++ - C++ FAQ Lite
n°101427
speedyop
Posté le 17-02-2002 à 12:26:50  profilanswer
 

armagetron rulez!!

n°101443
Titoine42
Posté le 17-02-2002 à 14:30:28  profilanswer
 

tétris?

n°101445
tagada001
Posté le 17-02-2002 à 14:35:54  profilanswer
 

PONG

mood
Publicité
Posté le 17-02-2002 à 14:35:54  profilanswer
 

n°101447
j0ga
Posté le 17-02-2002 à 14:55:03  profilanswer
 

scrabble  :D

n°101504
Cherrytree
cn=?
Posté le 17-02-2002 à 18:37:37  profilanswer
 

Street Fighter (en mode texte)
 
OK, je sors :D


---------------
Le site de ma maman
n°101505
Krueger
tout salaire demande dutravail
Posté le 17-02-2002 à 18:38:05  profilanswer
 

Eniac a écrit a écrit :

tu peux pas faire un clearscreen puis réaffichage à chaque fois ?  




 
Je sais pas, je sais pas faire ça. Mais je sais afficher plusieurs retours à la ligne afin de faire sortir la grille précédente de l'espace d'affichage du terminal. :D


---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi
n°101506
Krueger
tout salaire demande dutravail
Posté le 17-02-2002 à 18:38:27  profilanswer
 

Cherrytree a écrit a écrit :

Street Fighter (en mode texte)
 
OK, je sors :D  




 
 
 
:lol:


---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi
n°101523
Eniac
Da Mourfis' King
Posté le 17-02-2002 à 19:45:58  profilanswer
 

HelloWorld a écrit a écrit :

En mode texte, tu peux aussi faire un serpent ou un tron ;)  




 
un serpent ??? comment ? je dis bien en mode texte, en invite MS Dos...  je vois pas comment tu voudrais faire remonter le serpent par exemple...
 
A+


---------------
If you really want something, all the Universe conspires in helping you to achieve it.
n°101562
Ace17
Posté le 17-02-2002 à 21:21:29  profilanswer
 

Tu peux faire aussi un jeu dont vous etes le héros

n°101576
Eniac
Da Mourfis' King
Posté le 17-02-2002 à 22:07:57  profilanswer
 

un jeu de rôle ?
il faut utiliser les pointeurs...
 
puis en mode texte, lourdeur power :)
 
A+


---------------
If you really want something, all the Universe conspires in helping you to achieve it.
n°101582
Je@nb
Kindly give dime
Posté le 17-02-2002 à 22:35:41  profilanswer
 

Le jeu avec l'ordi ki fait un nombre au hasard et tu entres des nombres et il te dis  + petit ou + grand  :D  :D  :D  :D

n°101588
Krueger
tout salaire demande dutravail
Posté le 17-02-2002 à 22:51:06  profilanswer
 

Ça j'y avais pensé mais c'est trop facile à programmer. :lol:


---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi
n°101589
Je@nb
Kindly give dime
Posté le 17-02-2002 à 22:53:42  profilanswer
 

Oué c clair  :lol:  :lol:  :lol:  :lol:  
Sinonc bien ça fait apprendre les conditions les boucles qq procédures ..............;;;

n°101622
Jubijub
Parce que je le VD bien
Posté le 17-02-2002 à 23:50:15  profilanswer
 

je suis désolé, pour apprendre c très bien ce jeu : tu peux calculer un score, faire une table de highscore sauvegardée...en fait ca touche pas mal de notions si tu le custom un peu


---------------
Jubi Photos : Flickr - 500px
n°2258627
warnau
Posté le 22-05-2015 à 21:27:42  profilanswer
 

Eniac a écrit :


 
un serpent ??? comment ? je dis bien en mode texte, en invite MS Dos...  je vois pas comment tu voudrais faire remonter le serpent par exemple...
 
A+


 
 
Si c'est possible  :D Mais assez compliqué ... :ouch:

Citation :



 

Code :
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include<time.h>
  6. #include<ctype.h>
  7. #include <time.h>
  8. #include <windows.h>
  9. #include <process.h>
  10. #define UP 72
  11. #define DOWN 80
  12. #define LEFT 75
  13. #define RIGHT 77
  14. int length;
  15. int bend_no;
  16. int len;
  17. char key;
  18. void record();
  19. void load();
  20. int life;
  21. void Delay(long double);
  22. void Move();
  23. void Food();
  24. int Score();
  25. void Print();
  26. void gotoxy(int x, int y);
  27. void GotoXY(int x,int y);
  28. void Bend();
  29. void Boarder();
  30. void Down();
  31. void Left();
  32. void Up();
  33. void Right();
  34. void ExitGame();
  35. int Scoreonly();
  36. struct coordinate{
  37.     int x;
  38.     int y;
  39.     int direction;
  40. };
  41. typedef struct coordinate coordinate;
  42. coordinate head, bend[500],food,body[30];
  43. int main()
  44. {
  45.     char key;
  46.     Print();
  47.     system("cls" );
  48.     load();
  49.     length=5;
  50.     head.x=25;
  51.     head.y=20;
  52.     head.direction=RIGHT;
  53.     Boarder();
  54.     Food(); //to generate food coordinates initially
  55.     life=99; //number of extra lives
  56.     bend[0]=head;
  57.     Move();   //initialing initial bend coordinate
  58.     return 0;
  59. }
  60. void Move()
  61. {
  62.     int a,i;
  63.     do{
  64.         Food();
  65.         fflush(stdin);
  66.         len=0;
  67.         for(i=0;i<30;i++)
  68.         {
  69.             body[i].x=0;
  70.             body[i].y=0;
  71.             if(i==length)
  72.             break;
  73.         }
  74.         Delay(length);
  75.         Boarder();
  76.         if(head.direction==RIGHT)
  77.             Right();
  78.         else if(head.direction==LEFT)
  79.             Left();
  80.         else if(head.direction==DOWN)
  81.             Down();
  82.         else if(head.direction==UP)
  83.             Up();
  84.         ExitGame();
  85.     }while(!kbhit());
  86.     a=getch();
  87.     if(a==27)
  88.     {
  89.         system("cls" );
  90.         exit(0);
  91.     }
  92.     key=getch();
  93.     if((key==RIGHT&&head.direction!=LEFT&&head.direction!=RIGHT)||(key==LEFT&&head.direction!=RIGHT&&head.direction!=LEFT)||(key==UP&&head.direction!=DOWN&&head.direction!=UP)||(key==DOWN&&head.direction!=UP&&head.direction!=DOWN))
  94.     {
  95.         bend_no++;
  96.         bend[bend_no]=head;
  97.         head.direction=key;
  98.         if(key==UP)
  99.             head.y--;
  100.         if(key==DOWN)
  101.             head.y++;
  102.         if(key==RIGHT)
  103.             head.x++;
  104.         if(key==LEFT)
  105.             head.x--;
  106.         Move();
  107.     }
  108.     else if(key==27)
  109.     {
  110.         system("cls" );
  111.         exit(0);
  112.     }
  113.     else
  114.     {
  115.         printf("\a" );
  116.         Move();
  117.     }
  118. }
  119. void gotoxy(int x, int y)
  120. {
  121. COORD coord;
  122. coord.X = x;
  123. coord.Y = y;
  124. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  125. }
  126. void GotoXY(int x, int y)
  127. {
  128.     HANDLE a;
  129.     COORD b;
  130.     fflush(stdout);
  131.     b.X = x;
  132.     b.Y = y;
  133.     a = GetStdHandle(STD_OUTPUT_HANDLE);
  134.     SetConsoleCursorPosition(a,b);
  135. }
  136. void load(){
  137.     int row,col,r,c,q;
  138.     gotoxy(36,14);
  139.     printf("loading..." );
  140.     gotoxy(30,15);
  141.     for(r=1;r<=20;r++){
  142.     for(q=0;q<=100000000;q++);//to display the character slowly
  143.     printf("%c",177);}
  144.     getch();
  145. }
  146. void Down()
  147. {
  148.     int i;
  149.     for(i=0;i<=(head.y-bend[bend_no].y)&&len<length;i++)
  150.     {
  151.         GotoXY(head.x,head.y-i);
  152.         {
  153.             if(len==0)
  154.                 printf("v" );
  155.             else
  156.                 printf("*" );
  157.         }
  158.         body[len].x=head.x;
  159.         body[len].y=head.y-i;
  160.         len++;
  161.     }
  162.     Bend();
  163.     if(!kbhit())
  164.         head.y++;
  165. }
  166. void Delay(long double k)
  167. {
  168.     Score();
  169.     long double i;
  170.     for(i=0;i<=(10000000);i++);
  171. }
  172. void ExitGame()
  173. {
  174.     int i,check=0;
  175.     for(i=4;i<length;i++)   //starts with 4 because it needs minimum 4 element to touch its own body
  176.     {
  177.         if(body[0].x==body[i].x&&body[0].y==body[i].y)
  178.         {
  179.             check++;    //check's value increases as the coordinates of head is equal to any other body coordinate
  180.         }
  181.         if(i==length||check!=0)
  182.             break;
  183.     }
  184.     if(head.x<=10||head.x>=70||head.y<=10||head.y>=30||check!=0)
  185.     {
  186.         /*life--; perte d'une vie*/
  187.         if(life>=0)
  188.         {
  189.             head.x=25;
  190.             head.y=20;
  191.             bend_no=0;
  192.             head.direction=RIGHT;
  193.             Move();
  194.         }
  195.         else
  196.         {
  197.             system("cls" );
  198.             printf("Vous avez perdu !\nVous ferez mieux la prochaine fois!!!\ntapez une lettre pour continuer\n" );
  199.             record();
  200.             exit(0);
  201.         }
  202.     }
  203. }
  204. void Food()
  205. {
  206.     if(head.x==food.x&&head.y==food.y)
  207.     {
  208.         length++;
  209.         time_t a;
  210.         a=time(0);
  211.         srand(a);
  212.         food.x=rand()%70;
  213.         if(food.x<=10)
  214.             food.x+=11;
  215.         food.y=rand()%30;
  216.         if(food.y<=10)
  217.             food.y+=11;
  218.     }
  219.     else if(food.x==0)/*to create food for the first time coz global variable are initialized with 0*/
  220.     {
  221.         food.x=rand()%70;
  222.         if(food.x<=10)
  223.             food.x+=11;
  224.         food.y=rand()%30;
  225.         if(food.y<=10)
  226.             food.y+=11;
  227.     }
  228. }
  229. void Left()
  230. {
  231.     int i;
  232.     for(i=0;i<=(bend[bend_no].x-head.x)&&len<length;i++)
  233.     {
  234.         GotoXY((head.x+i),head.y);
  235.        {
  236.                 if(len==0)
  237.                     printf("<" );
  238.                 else
  239.                     printf("*" );
  240.         }
  241.         body[len].x=head.x+i;
  242.         body[len].y=head.y;
  243.         len++;
  244.     }
  245.     Bend();
  246.     if(!kbhit())
  247.         head.x--;
  248. }
  249. void Right()
  250. {
  251.     int i;
  252.     for(i=0;i<=(head.x-bend[bend_no].x)&&len<length;i++)
  253.     {
  254.         //GotoXY((head.x-i),head.y);
  255.         body[len].x=head.x-i;
  256.         body[len].y=head.y;
  257.         GotoXY(body[len].x,body[len].y);
  258.         {
  259.             if(len==0)
  260.                 printf(">" );
  261.             else
  262.                 printf("*" );
  263.         }
  264.         /*body[len].x=head.x-i;
  265.         body[len].y=head.y;*/
  266.         len++;
  267.     }
  268.     Bend();
  269.     if(!kbhit())
  270.         head.x++;
  271. }
  272. void Bend()
  273. {
  274.     int i,j,diff;
  275.     for(i=bend_no;i>=0&&len<length;i--)
  276.     {
  277.             if(bend[i].x==bend[i-1].x)
  278.             {
  279.                 diff=bend[i].y-bend[i-1].y;
  280.                 if(diff<0)
  281.                     for(j=1;j<=(-diff);j++)
  282.                     {
  283.                         body[len].x=bend[i].x;
  284.                         body[len].y=bend[i].y+j;
  285.                         GotoXY(body[len].x,body[len].y);
  286.                         printf("*" );
  287.                         len++;
  288.                         if(len==length)
  289.                             break;
  290.                     }
  291.                 else if(diff>0)
  292.                     for(j=1;j<=diff;j++)
  293.                     {
  294.                         /*GotoXY(bend[i].x,(bend[i].y-j));
  295.                         printf("*" );*/
  296.                         body[len].x=bend[i].x;
  297.                         body[len].y=bend[i].y-j;
  298.                         GotoXY(body[len].x,body[len].y);
  299.                         printf("*" );
  300.                         len++;
  301.                         if(len==length)
  302.                             break;
  303.                     }
  304.             }
  305.         else if(bend[i].y==bend[i-1].y)
  306.         {
  307.             diff=bend[i].x-bend[i-1].x;
  308.             if(diff<0)
  309.                 for(j=1;j<=(-diff)&&len<length;j++)
  310.                 {
  311.                     /*GotoXY((bend[i].x+j),bend[i].y);
  312.                     printf("*" );*/
  313.                     body[len].x=bend[i].x+j;
  314.                     body[len].y=bend[i].y;
  315.                     GotoXY(body[len].x,body[len].y);
  316.                         printf("*" );
  317.                    len++;
  318.                    if(len==length)
  319.                            break;
  320.                }
  321.            else if(diff>0)
  322.                for(j=1;j<=diff&&len<length;j++)
  323.                {
  324.                    /*GotoXY((bend[i].x-j),bend[i].y);
  325.                    printf("*" );*/
  326.                    body[len].x=bend[i].x-j;
  327.                    body[len].y=bend[i].y;
  328.                    GotoXY(body[len].x,body[len].y);
  329.                        printf("*" );
  330.                    len++;
  331.                    if(len==length)
  332.                        break;
  333.                }
  334.        }
  335.    }
  336. }
  337. void Boarder()
  338. {
  339.    system("cls" );
  340.    int i;
  341.    GotoXY(food.x,food.y);   /*displaying food*/
  342.        printf("F" );
  343.    for(i=10;i<71;i++)
  344.    {
  345.        GotoXY(i,10);
  346.            printf("!" );
  347.        GotoXY(i,30);
  348.            printf("!" );
  349.    }
  350.    for(i=10;i<31;i++)
  351.    {
  352.        GotoXY(10,i);
  353.            printf("!" );
  354.        GotoXY(70,i);
  355.        printf("!" );
  356.    }
  357. }
  358. void Print()
  359. {
  360.    //GotoXY(10,12);
  361.    printf("\tBienvenu(e) dans Snake !!\n(appuyez sur une touche pour continuer)\n" );
  362.   getch();
  363.    system("cls" );
  364.    printf("\tinstructions :\n" );
  365.    printf("\n-> Utilisez les fleches pour diriger le serpent.\n\n-> Vous devrez manger des aliments qui apparaitront a differents endroits de l'ecran. A chaque fois que vous mangez une pomme, votre serpent s'agrandit de *.\n\n-> Vous avez un nombre illimite de vie (Merci qui ? ;) ). Vous ne perdrez pas de vies si vous touchez les murs ou le corp du serpent (Re-merci qui ? ;) ).\n\n-> Pour mettre le jeu en pause, appuyez sur une touche puis rappuyez sur la meme pour reprendre\n\n-> Si vous voulez quiter appuyez sur echap. \n" );
  366.    printf("\n\nAppuyez sur une touche pour jouer..." );
  367.    if(getch()==27)
  368.    exit(0);
  369. }
  370. void record(){
  371.    char plname[20],nplname[20],cha,c;
  372.    int i,j,px;
  373.    FILE *info;
  374.    info=fopen("record.txt","a+" );
  375.    getch();
  376.    system("cls" );
  377.    printf("Entrez votre nom\n" );
  378.    scanf("%[^\n]",plname);
  379.    // ************************
  380.    for(j=0;plname[j]!='\0';j++){ //to convert the first letter after space to capital
  381.    nplname[0]=toupper(plname[0]);
  382.    if(plname[j-1]==' '){
  383.    nplname[j]=toupper(plname[j]);
  384.    nplname[j-1]=plname[j-1];}
  385.    else nplname[j]=plname[j];
  386.    }
  387.    nplname[j]='\0';
  388.    // *****************************
  389.    //sdfprintf(info,"\t\t\tPlayers List\n" );
  390.    fprintf(info,"Nom du joueur :%s\n",nplname);
  391.     //for date and time
  392.    time_t mytime;
  393.   mytime = time(NULL);
  394.   fprintf(info,"derniere date de jeu :%s",ctime(&mytime));
  395.      // **************************
  396.      fprintf(info,"Score:%d\n",px=Scoreonly());//call score to display score
  397.      //fprintf(info,"\nLevel:%d\n",10);//call level to display level
  398.    for(i=0;i<=50;i++)
  399.    fprintf(info,"%c",'_');
  400.    fprintf(info,"\n" );
  401.    fclose(info);
  402.    printf("Pour voir vos anciens scores appuyez sur 'y'\n" );
  403.    cha=getch();
  404.    system("cls" );
  405.    if(cha=='y'){
  406.    info=fopen("record.txt","r" );
  407.    do{
  408.        putchar(c=getc(info));
  409.        }while(c!=EOF);}
  410.      fclose(info);
  411. }
  412. int Score()
  413. {
  414.    int score;
  415.    GotoXY(20,8);
  416.    score=length-5;
  417.    printf("SCORE : %d",(length-5));
  418.    score=length-5;
  419.    GotoXY(50,8);
  420.    printf("Life : %d",life);
  421.    return score;
  422. }
  423. int Scoreonly()
  424. {
  425. int score=Score();
  426. system("cls" );
  427. return score;
  428. }
  429. void Up()
  430. {
  431.    int i;
  432.    for(i=0;i<=(bend[bend_no].y-head.y)&&len<length;i++)
  433.    {
  434.        GotoXY(head.x,head.y+i);
  435.        {
  436.            if(len==0)
  437.                printf("^" );
  438.            else
  439.                printf("*" );
  440.        }
  441.        body[len].x=head.x;
  442.        body[len].y=head.y+i;
  443.        len++;
  444.    }
  445.    Bend();
  446.    if(!kbhit())
  447.        head.y--;
  448. }


Message édité par gilou le 23-05-2015 à 11:13:05
n°2258708
theshockwa​ve
I work at a firm named Koslow
Posté le 25-05-2015 à 14:19:09  profilanswer
 

Outre le déterrage phénoménal, c'est une super idée de faire du code qui n'est pas portable pour s'entrainer à la programmation ...  [:cerveau pfff]


---------------
last.fm
n°2258723
rat de com​bat
attention rongeur méchant!
Posté le 25-05-2015 à 21:27:28  profilanswer
 

theshockwave a écrit :

Outre le déterrage phénoménal, c'est une super idée de faire du code recopier d'internet du code qui n'est pas portable pour s'entrainer à la programmation ...  [:cerveau pfff]


FTFY...

mood
Publicité
Posté le   profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

   [ C ] Cherche idée de petit jeu à faire (newbie inside)

 

Sujets relatifs
[SQL] J'ai un petit prob avec un Update ...CHAT cherche une solution pour éviter rafraîchissement visuel
Cherche cour de graphique sur c++CamL light vous connaissez [prob inside]
[PHP + SQL] explications + code inside (requete SQL)[PHP] Upload de fichiers (script inside)
Idee pour un plug in ICQ pour les forumeurs d'hfr[VB6] Brêle cherche tutorial
Cherche doc,howto, cours,.....Cherche infos sur implémentation DES et AES
Plus de sujets relatifs à : [ C ] Cherche idée de petit jeu à faire (newbie inside)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR