|
Dernière réponse | ||
---|---|---|
Sujet : cherche jeux en C pour mon projet info | ||
[SDF]Poire |
|
Aperçu |
---|
Vue Rapide de la discussion |
---|
[SDF]Poire |
|
nico76 | j'utilise DEV-C++
pour chez moi à l'école, je suis sous unix enfin, c'est pas grave : du moment que ça marche sous win je vais bien y arriver, il faut que je mette dedans, c'est tout. Merci @+ |
[SDF]Poire | Il faut que tu compiles pour dos.... il manque ptet des headers en + (mais je pense pas....)
Tu compiles avec quoi ? edit : Pas compatible du tout mon source avec linux..... [edtdd]--Message édité par [SDF]Poire--[/edtdd] |
nico76 | voici le pb de compilation que j'ai ds sylvain.h
183 u:\lecoutre\fichie~1\projet~1\sylvain.h warning: comparison between pointer and integer j'ai remplacé NULL par 0, ça compile mais j'obtiens cette page d'erreur : C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x249b):serpent.c: undefined reference to `_setcursortype' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x24ba):serpent.c: undefined reference to `gotoxy' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x24d8):serpent.c: undefined reference to `textcolor' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x24e5):serpent.c: undefined reference to `textbackground' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x2504):serpent.c: undefined reference to `_setcursortype' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x2586):serpent.c: undefined reference to `random' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x259e):serpent.c: undefined reference to `random' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x2695):serpent.c: undefined reference to `textcolor' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x26b0):serpent.c: undefined reference to `gotoxy' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x26d2):serpent.c: undefined reference to `textcolor' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x26df):serpent.c: undefined reference to `textbackground' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x26ee):serpent.c: undefined reference to `gotoxy' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x2712):serpent.c: undefined reference to `textbackground' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x278f):serpent.c: undefined reference to `gotoxy' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x279c):serpent.c: undefined reference to `textcolor' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x27d7):serpent.c: undefined reference to `delay' C:\WINDOWS\TEMP\ccLPXcgb.o(.text+0x27fb):serpent.c: undefined reference to `delay' alors, je sais po [edtdd]--Message édité par nico76--[/edtdd] |
[SDF]Poire |
|
nico76 | j'ai une petite erreur de compilation,
mais je vais trouver. sinon, si tu en as d'autres (tout simple) : ça m'interresse. ;) |
[SDF]Poire |
|
nico76 | :bounce: |
nico76 | merci beaucoup, je teste ça dès que possible.
bon, encore merci. et à bientôt. |
[SDF]Poire | Et le header à moi :D (sylvain.h) :
#ifndef SYLVAIN #define SYLVAIN #include <conio.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <dos.h> #define KUP -8 #define KDOWN -2 #define KLEFT -4 #define KRIGHT -6 #define UP 72 #define DOWN 80 #define LEFT 75 #define RIGHT 77 #define CENTRED 0 #define LADJUSTED -1 #define RADJUSTED 1 #define SHADED 'y' #define NOT_SHADED 'n' #define SINGLE 1 #define DOUBLE 2 struct color { int txt; //col0 int select; //col1 int frame; //col2 int backgrd; //col3 int frame_backgrd; //col4 int shade; //col5 int pt_backgrd; //col6 int txt_select; //col7 }; void fenetre(int x1,int y1,int x2,int y2,int ombre,int type,struct color col); void fond(int col_backgrd); void rfond(int x1,int y1,int x2,int y2,int col_backgrd); void end(); void back(struct color col); void rback(int x1,int y1,int x2,int y2,struct color col); void entree(char *string); int menu(int x, int y,int nb,char txt[25][80],int centre,struct color col); int middle(int len, int size); int screenmiddlex(int len); int screenmiddley(int len); int getkey(); void entree(char *string) { char c; int i = 0; while ( (c = getche()) != 13 ) { string[i] = c; i++; } } int getkey() { char c; if (kbhit() != 0) { c = getch(); if (c == 0) { c = getch(); if (c == UP) return KUP; if (c == DOWN) return KDOWN; if (c == LEFT) return KLEFT; if (c == RIGHT) return KRIGHT; } else return c; } return 0; } int screenmiddlex(int len) { return (80 - len) / 2; } int screenmiddley(int len) { return (25 - len) / 2; } int middle(int len, int size) { return (size - len) / 2; } void rfond(int x1,int y1,int x2,int y2,int col_backgrd) { int i; char esp[81]; textcolor(col_backgrd); textbackground(col_backgrd); for (i=0;i<(x2-x1)+1;i++) esp[i]=' '; for (i=y1;i<=y2;i++) { gotoxy(x1,i); cprintf("%.*s",(x2-x1)+1,esp); } } void rback(int x1,int y1,int x2,int y2,struct color col) { int i; char esp[81]; textcolor(col.pt_backgrd); textbackground(col.backgrd); for (i=0;i<(x2-x1)+1;i++) esp[i]='°'; for (i=y1;i<y2;i++) { gotoxy(x1,i); cprintf("%.*s",(x2-x1)+1,esp); } } void back(struct color col) { int i; char esp[81]; textcolor(col.pt_backgrd); textbackground(col.backgrd); for (i=0;i<80;i++) esp[i]='°'; for (i=2;i<25;i++) { gotoxy(1,i);cprintf("%.*s",80,esp); } } void end() { _setcursortype(_NORMALCURSOR); textbackground(0); textcolor(7); cprintf("" ); clrscr(); fflush(stdin); //flushall(); exit(EXIT_SUCCESS); } int menu(int x, int y, int nb,char txt[25][80],int centre,struct color col) { int c[25],t1,t2,ic=0,it=0,i,rep=0,n; for (i=0;i<nb+1;i++) { if (strlen(txt[i]) > strlen(txt[it])) it=i; } c[0]=col.select; for (i=1;i<nb+1;i++) c[i]=col.txt; textbackground(col.frame_backgrd); while(1) { for (i=0;i<nb+1;i++) { textcolor(c[i]); if (centre == LADJUSTED) n = x; if (centre == CENTRED) n= x + ( strlen(txt[it]) - strlen(txt[i]) ) / 2; if (centre == RADJUSTED) n = x + strlen(txt[it]) - strlen(txt[i]); gotoxy(n, y + i); cprintf("%s",txt[i]); } t1=getch(); if (t1 == 13) return rep; if (t1 == NULL) { t2=getch(); if (t2 == DOWN) { c[ic]=col.txt; if (ic == nb-1) ic=-1; c[++ic]=col.select; rep=ic; } if (t2 == UP) { c[ic]=col.txt; if (ic == 0) ic=nb; c[--ic]=col.select; rep=ic; } } } } void fond(int col_backgrd) { int i,i2,y,ii; char esp[81]; textcolor(col_backgrd); textbackground(col_backgrd); y=1;ii=0; for (i=0;i<80;i++) { esp[ii]=' '; ii++; } for (i2=0;i2<25;i2++) { gotoxy(1,y);cprintf("%.*s",80,esp); y=y+1; } } void fenetre (int x1,int y1,int x2,int y2,int ombre,int type,struct color col) { int i; if (type == DOUBLE) { textcolor(col.frame); textbackground(col.frame_backgrd); for (i=1;i<x2-x1;i++) { gotoxy(x1+i,y1);cprintf("Í" ); gotoxy(x1+i,y2);cprintf("Í" ); } gotoxy(x1,y1);cprintf("É" ); gotoxy(x2,y1);cprintf("»" ); gotoxy(x1,y2);cprintf("È" ); gotoxy(x2,y2);cprintf("¼" ); for (i=1;i<y2-y1;i++) { gotoxy(x1,y1+i);cprintf("º" ); gotoxy(x2,y1+i);cprintf("º" ); } } else { textcolor(col.frame); textbackground(col.frame_backgrd); for (i=1;i<x2-x1;i++) { gotoxy(x1+i,y1);cprintf("Ä" ); gotoxy(x1+i,y2);cprintf("Ä" ); } gotoxy(x1,y1);cprintf("Ú" ); gotoxy(x2,y1);cprintf("¿" ); gotoxy(x1,y2);cprintf("À" ); gotoxy(x2,y2);cprintf("Ù" ); for (i=1;i<y2-y1;i++) { gotoxy(x1,y1+i);cprintf("³" ); gotoxy(x2,y1+i);cprintf("³" ); } } rfond(x1 + 1, y1 + 1, x2 - 1, y2 - 1, col.backgrd); if (ombre == SHADED) { textcolor(col.shade); textbackground(col.backgrd); gotoxy(x1+2,y2+1); for (i=0;i<x2-x1+1;i++) cprintf("Û" ); for (i=1;i<y2-y1+1;i++) { gotoxy(x2+1,y1+i); cprintf("ÛÛ" ); } } } #endif |
[SDF]Poire | Donc voilà le serpent (amélioration possible) :
#include "d:\sylvain\bp\sylvain.h" struct point { int x; int y; }; int jeux(int difficult); void enrscore(int score, char *nom); void main() { int rep2 = -2, rep, niv; struct color col; char txt[25][80] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "QUITTER"}; char txt2[25][80] = {"Rejouer", "Quitter"}; col.txt = 5; col.select = 13; col.frame = 15; col.backgrd = 3; col.frame_backgrd = 3; col.shade = 8; clrscr(); randomize(); _setcursortype(_NOCURSOR); fenetre(27, 6, 52, 19, SHADED, DOUBLE, col); textcolor(0); gotoxy(29, 7); cprintf("Niveau de difficult? :" ); niv = menu(37, 9, 10, txt, CENTRED, col); if (niv == 9) end(); do { rep = jeux(niv + 1); if ( (rep == -1) || (rep == 1) ) { fenetre(33, 10, 45, 15, SHADED, DOUBLE, col); rep2 = menu(36, 12, 2, txt2, CENTRED, col); } } while (rep2 != 1); end(); } int jeux(int difficult) { struct point serpent[1794]; int i, i2, len = 0, dx = 1, dy = 0, px, py, score = 0, tst = 0; unsigned char mur[80][25]; char c = 0, nom[20]; struct color col; col.txt = 5; col.select = 13; col.frame = 15; col.backgrd = 3; col.frame_backgrd = 3; col.shade = 8; for (i = 0; i < 80; i++) { for (i2 = 0; i2 < 25; i2++) mur[i][i2] = 0; } for (i = 0; i < 80; i++) { mur[i][0] = 1; mur[i][24] = 1; } for (i = 0; i < 25; i++) { mur[0][i] = 1; mur[79][i] = 1; } for (i = 0; i < 10; i++) { serpent[i].x = 20 - i; serpent[i].y = 15; len++; } do { px = random(78) + 1; py = random(23) + 1; for (i = 0; i < len; i++) { if ( (serpent[i].x != px + 1) && (serpent[i].y != py + 1) ) { tst = 1; break; } } } while ( (mur[px][py] != 1) && (tst != 1) ); mur[px][py] = 2; clrscr(); fond(1); rfond(2, 2, 79, 24, 0); textcolor(0); textbackground(1); gotoxy(1, 25); cprintf("Score : %d", score); textbackground(0); textcolor(13); for (i = 0; i < len; i++) { gotoxy(serpent[i].x, serpent[i].y); cprintf("Û" ); } textcolor(RED); gotoxy(px + 1, py + 1); cprintf("%c", 207); while (1) { c=getkey(); if (c == KLEFT) { dx = -1; dy = 0; } else if (c == KRIGHT) { dx = 1; dy = 0; } else if (c == KUP) { dx = 0; dy = -1; } else if (c == KDOWN) { dx = 0; dy = 1; } else if (c == 27) return 1; gotoxy(serpent[len - 1].x, serpent[len - 1].y); cprintf(" " ); for (i = 1; i < len; i++) { serpent[len - i].x = serpent[len - i - 1].x; serpent[len - i].y = serpent[len - i - 1].y; } serpent[0].x = serpent[0].x + dx; serpent[0].y = serpent[0].y + dy; for (i = 1; i < len; i++) { if (serpent[0].x == serpent[i].x && serpent[0].y == serpent[i].y) { fenetre(33, 10, 45, 15, SHADED, DOUBLE, col); gotoxy(35, 12); textcolor(1); textbackground(3); _setcursortype(_SOLIDCURSOR); cprintf("Entrez votre nom : " ); textcolor(7); textbackground(0); gotoxy(35,13); entree(nom); //cprintf("%s",nom); //getch(); _setcursortype(_NOCURSOR); return -1; } } if (mur[ serpent[0].x - 1 ][ serpent[0].y - 1 ] == 1) { fenetre(23, 10, 54, 15, SHADED, DOUBLE, col); gotoxy(25, 12); textcolor(1); textbackground(3); _setcursortype(_SOLIDCURSOR); cprintf("Entrez votre nom : " ); gotoxy(25,13); fflush(stdin); textcolor(7); textbackground(0); entree(nom); _setcursortype(_NOCURSOR); return -1; } if (mur[ serpent[0].x - 1 ][ serpent[0].y - 1 ] == 2) { score = score + 10; mur[px][py] = 0; tst = 0; do { px = random(78) + 1; py = random(23) + 1; for (i = 0; i < len; i++) { if ( (serpent[i].x != px + 1) && (serpent[i].y != py + 1) ) { tst = 1; break; } } } while ( (mur[px][py] != 1) && (tst != 1) ); mur[px][py] = 2; textcolor(RED); gotoxy(px + 1, py + 1); cprintf("%c", 207); textcolor(0); textbackground(1); gotoxy(1, 25); cprintf("Score : %d", score); textbackground(0); serpent[len].x = serpent[len - 1].x; serpent[len].y = serpent[len - 1].y; len++; } gotoxy(serpent[0].x, serpent[0].y); textcolor(13); cprintf("Û" ); if (dy != 0) delay( 125 - (difficult*10) ); else delay( 100 - (difficult*10) ); } } void enrscore(int score, char *nom) { FILE *fichier, *f2; int i = 0, s; char n[20]; int state; fichier = fopen("score.scr", "r" ); f2 = fopen("score.tmp", "w+" ); state = fscanf(fichier, "%d\t%s", &s, &n); while( (i < 10) && (state != EOF) ) { if (score > s) { fprintf(f2, "%d\t%s", score, *nom); fprintf(f2, "%d\t%s", s, n); } else fprintf(f2, "%d\t%s", s, n); state = fscanf(fichier, "%d\t%s", &s, &n); i++; } } |
veryfree | le serpent le serpent!
jerry |
[SDF]Poire |
|
nico76 | oui, s'il te plait
j'avais recuperer le serpent, mais il ne marchait pas alors donnes ton listing stp merci d'avance |
[SDF]Poire | Faire un serpent C pas trop dur....
Le listing.... je te le donnes où pas ? |
nico76 | merci à toi
j'essaye ça dès que possible encore merci |
deathsharp | strict minimum:
|
deathsharp | donc une fenetre dos voila
pas une interface avec des tous beaux bouton |
nico76 | je comprends po
on tape nos programmes sous linux. enfin, je l'ai retapé sous dev c++, qd j'execute, ça ouvre une fenetre ms dos enfin, si tu peux m'aider, je suis preneur [edtdd]--Message édité par nico76--[/edtdd] |
deathsharp | ligne de command ou interface graphique? |
nico76 | je ne suis qu'un pov étudiant qui ne fait pas de c dans la boite où il travaille (alternance) donc j'ai beaucoup de mal a etre bon en c :cry: :cry: :cry: |
deathsharp | arrive pas a faire une simple calculette? |
nico76 | salut à vous je dois terminer mon projet informatique de c, j'aimerais rajouter un ou deux jeux.. alors, si vous avez des listing de ce que je cherche maillez moi [edtdd]--Message édité par nico76--[/edtdd] |