Xpchess is a little beta, but will be improved, available at:
http://eirikn.net/lulf/projs/xpchess-0.5.tar.gz
Programmed in C with SDL and SDL_image libraries. It works great in Unix clones, but I haven't been able to make it work in Windows.
Xpchess is a little beta, but will be improved, available at:
http://eirikn.net/lulf/projs/xpchess-0.5.tar.gz
Programmed in C with SDL and SDL_image libraries. It works great in Unix clones, but I haven't been able to make it work in Windows.
% gcc -v
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.3.3 [FreeBSD] 20031106
I have included the project files for Code::Blocks, MinGW Developer Studio and Dev C++.Code:Operating system: XP SP3 Compiler: MSVC 2008 Express Graphics Library: SDL 1.2 Other Libraries: SDL_ttf, SDL_image Description: Simple Memory Game Where You Can Make Your Own Card set.
They should all compile with proper settings.
Try beating the computer with 8 x 8 card pairs, which is at least impossible for me
Memory_Game_1.zip
C Source code for knights tour
Code:/****Knight's Tour*******/ #include<stdio.h> #include<stdlib.h> #include<graphics.h> #include<conio.h> typedef struct { int x,y,s2; }chessboard; typedef struct { int u,v,s1; }hamiltonian; int b,p,q,w=5; int j=0; chessboard chess[8][8]; hamiltonian path[64]; void search(); void push(); void pop(); void pawn(int,int,int); void knight(int,int,int); void main() { int i,j,l,m; /* request auto detection */ int gdriver = DETECT, gmode, errorcode; FILE *fp; clrscr(); /* initialize graphics, local variables*/ initgraph(&gdriver, &gmode, "f:\\tc\\bgi"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } printf("\n\n\n\n\n\n\n\n\n\n\n\tPROGRAM TO CHECK WHETHER A KNIGHT CAN REACH A PAWN IN A CHESSBOARD"); printf("\n\n\n\t\t THE CO-ORDINATES MUST BE GIVEN FROM 1-8"); printf("\n\n\nEnter the position of the Pawn: "); scanf("%d,%d",&a,&b); printf("\n\nEnter the position of the Knight: "); scanf("%d,%d",&p,&q); cleardevice(); //chessboard setcolor(3); for(i=80;i<=560;i+=60) { line(i,0,i,480); line(i+1,0,i+1,480); } for(i=0;i<480;i+=60) { line(80,i,560,i); line(80,i+1,560,i+1); } line(80,478,560,478); line(80,479,560,479); setfillstyle(1,15); for(i=0;i<=7;i++) for(j=0;j<=7;j++) chess[i][j].s2=0; for(i=0;i<=63;i++) path[i].s1=-1; for(i=20;i<=440;i+=120) for(j=100;j<=520;j+=120) floodfill(j,i,3); for(i=80;i<=440;i+=120) for(j=160;j<=520;j+=120) floodfill(j,i,3); for(i=0,l=30;i<=7,l<=450;i++,l+=60) for(j=0,m=110;j<=7,m<=530;j++,m+=60) { chess[i][j].x=m; chess[i][j].y=l; } pawn(chess[b][a].x,chess[b][a].y,RED); setcolor(1); setfillstyle(1,1); /*settextstyle(10,1,2); setcolor(MAGENTA); outtextxy(10,20,"Magenta = Start = Knight"); settextstyle(10,1,2); setcolor(RED); outtextxy(575,5,"Red = Destination = Pawn "); fclose(fp);*/ path[0].u=chess[q][p].x; path[0].v=chess[q][p].y; chess[q][p].s2=1; path[j].s1=1; knight(chess[q][p].x,chess[q][p].y,MAGENTA); getch(); search(); getch(); cleardevice(); printf("\t\t\tThe Knight reached the pawn"); getch(); closegraph(); } void search() { int r,s,c=0,flag; char ch; if(path[j].u==chess[b][a].x&&path[j].v==chess[b][a].y) { knight(path[j].u,path[j].v+10,MAGENTA); return; } while(1) { r=random(8); s=random(8); if(path[j].u+120==chess[r][s].x&&path[j].v+60==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; continue; } flag=1; knight(path[j].u+120,path[j].v+70,GREEN); break; } else if(path[j].u+120==chess[r][s].x&&path[j].v-60==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u+120,path[j].v-50,GREEN); break; } else if(path[j].u-120==chess[r][s].x&&path[j].v+60==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u-120,path[j].v+70,GREEN); break; } else if(path[j].u-120==chess[r][s].x&&path[j].v-60==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u-120,path[j].v-50,GREEN); break; } else if(path[j].u+60==chess[r][s].x&&path[j].v+120==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u+60,path[j].v+130,GREEN); break; } else if(path[j].u+60==chess[r][s].x&&path[j].v-120==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u+60,path[j].v-110,GREEN); break; } else if(path[j].u-60==chess[r][s].x&&path[j].v-120==chess[r][s].y) { if(path[j].s1==chess[r][s].s2) { c++; if(c==8) break; continue; } flag=1; knight(path[j].u-60,path[j].v-110,GREEN); break; } else continue; } /*ch=getch(); if(ch==' ') { j--; search(); }*/ if(flag==1) { push(); path[j].u=chess[r][s].x; path[j].v=chess[r][s].y; chess[r][s].s2=1; path[j].s1=1; getch(); search(); } } void pawn(int r, int s,int c) { s=s+4; setcolor(c); setfillstyle(6,c); circle(r,s-10,5); floodfill(r,s-7,c); line(r,s-10,r-11,s+15); line(r,s-10,r+11,s+15); rectangle(r-13,s+15,r+13,s+18); floodfill(r,s+10,c); floodfill(r,s+17,c); } void knight(int r,int s,int c) { setcolor(c); setfillstyle(6,c); arc(r,s-10,0,180,14); line(r-14,s-10,r,s-10); line(r-3,s-10,r-14,s+10); line(r+14,s-10,r+14,s+10); rectangle(r-17,s+10,r+17,s+13); floodfill(r,s-8,c); floodfill(r,s+12,c); } void push() { j++; } void pop() { j--; }
Anothe code for knights tour
Code:#include <stdio.h> #include <conio.h> #include<graphics.h> #include<dos.h> #include<stdlib.h> typedef struct { int n,color; }sq; struct link { int x,y; struct link *next; }; typedef struct link l; l *h=NULL,*e=NULL,*p=NULL; void inilink(); void graph(); void chessboard(sq [8][8]); void iniboard(sq [8][8]); void drawpawn(int,int); void drawknight(int,int); void rec(l*,int,int); char name[][2]={"A","B","C","D","E","F","G","H","0","1","2","3","4","5","6","7"}; int flag=0; void main() { int i,j,i1,i2,j1,j2; sq c[8][8]; clrscr(); printf("Enter the coordinates of pawn"); scanf("%d,%d",&i1,&j1); printf("Enter the coordinates of the knight"); scanf("%d,%d",&i2,&j2); if(i1==i2&&j1==j2) exit(1); for(i=0;i<8;i++) for(j=0;j<8;j++) c[8][8].n=0; c[i1][j1].n=2; c[i2][j2].n=1; inilink(); e->next=h; graph(); iniboard(c); chessboard(c); setcolor(BLUE); setfillstyle(1,BLUE); drawpawn(i1,j1); setfillstyle(1,RED); drawknight(i2,j2); setfillstyle(1,GREEN); for(p=h;p->next!=h;p=p->next) if(p->x==i2&&p->y==j2) break; getch(); rec(p,i1,j1); drawknight(i1,j1); getch(); closegraph(); } void rec(l *p,int i2,int j2) { if((p->x==i2&&p->y==j2)||(flag==1)) return; drawknight(p->next->x,p->next->y); delay(1000); rec(p->next,i2,j2); } void inilink() { FILE *fp; l *n; fp=fopen("N:\\K.txt","r"); while(!feof(fp)) { n=(l*)malloc(sizeof(l)); fscanf(fp,"%d %d",&n->x,&n->y); n->next=NULL; if(h==NULL) h=e=n; else { n->next=h; h=n; } } fclose(fp); } void iniboard(sq c[8][8]) { int i,j,k; for(i=0;i<8;i++) for(j=0;j<8;j++) if(i%2==1) { c[i][j++].color=BROWN; c[i][j].color=LIGHTRED; } else { c[i][j++].color=LIGHTRED; c[i][j].color=BROWN; } } void chessboard(sq c[8][8]) { int i,j,k,l; cleardevice(); setbkcolor(GREEN); //to make the board setlinestyle(SOLID_LINE,1,2); setcolor(BLUE); for(i=60;i<=540;i+=60) line(i,20,i,460); for(i=20;i<=460;i+=55) line(60,i,540,i); for(i=60,k=0;i<540;i+=60,k++) for(j=20,l=0;j<468;j+=56,l++) { setfillstyle(1,c[k][l].color); floodfill(i+2,j+2,BLUE); } //to draw the border line(40,1,40,479); line(560,1,560,479); line(40,1,560,1); line(40,479,560,479); line(40,1,60,20); line(560,479,540,460); line(40,479,60,460); line(560,1,540,20); setfillstyle(1,YELLOW); floodfill(45,2,BLUE); floodfill(45,25,BLUE); floodfill(45,478,BLUE); floodfill(545,455,BLUE); //to label the board settextstyle(2,0,4); setcolor(RED); for(i=50;i<=545;i+=495) for(j=43,k=0;j<468;j+=56,k++) outtextxy(i,j,name[k]); for(j=5;j<=468;j+=460) for(i=90,k=8;i<=550;i+=60,k++) outtextxy(i,j,name[k]); } void graph(void) { // request auto detection int gdriver = DETECT, gmode, errorcode; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "e:\\tc\\bgi"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurRED */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } } void drawpawn(int i,int j) { int pawn[]={25,20,25,22,28,22,28,35,20,35,20,40,15,40,15,45,45,45,45,40,40,40,40,35,32,35,32,22,35,22,35,20,25,20}; int k,fac1=(j+1)*60,fac2=i*55+25; for(k=0;k<34;k+=2) { pawn[k]+=fac1; pawn[k+1]+=fac2; } circle(30+fac1,15+fac2,5); floodfill(31+fac1,16+fac2,BLUE); fillpoly(17,pawn); } void drawknight(int i,int j) { int knight[]={20,55,20,60,15,60,15,65,45,65,45,60,40,60,40,55}; int k,fac1=(j+1)*60,fac2=i*55+5; for(k=0;k<16;k+=2) { knight[k]+=fac1; knight[k+1]+=fac2; } drawpoly(8,knight); if(j<4) { arc(33+fac1,40+fac2,105,230,20); line(30+fac1,17+fac2,33+fac1,22+fac2); line(30+fac1,17+fac2,27+fac1,22+fac2); line(33+fac1,22+fac2,48+fac1,30+fac2); line(48+fac1,30+fac2,48+fac1,35+fac2); line(48+fac1,35+fac2,42+fac1,35+fac2); arc(7+fac1,45+fac2,343,17,35); circle(35+fac1,30+fac2,1); floodfill(45+fac1,34+fac2,BLUE); circle(35+fac1,30+fac2,3); } else { arc(25+fac1,42+fac2,320,70,20); line(30+fac1,18+fac2,33+fac1,23+fac2); line(30+fac1,18+fac2,27+fac1,23+fac2); line(27+fac1,23+fac2,12+fac1,31+fac2); line(12+fac1,31+fac2,12+fac1,36+fac2); line(12+fac1,36+fac2,18+fac1,36+fac2); arc(52+fac1,45+fac2,165,199,35); circle(25+fac1,31+fac2,1); floodfill(13+fac1,31+fac2,BLUE); circle(25+fac1,31+fac2,3); } }
I am coding an open source game: ad infinitum
Link: ad-infinitum | Free Real Time Strategy software downloads at SourceForge.net
The project is currently a work in progress but an alpha version can be dowloaded at link. I hope this version gives a clear indication of the games direction.
project is programed in C for windows and using the libraries of directX draw. The programs code can be found in the "code" file of the download. The game is conpiled using the free lcc-win32 compiler
I welcome ideas, suport and help, and may come a calling here for assistance in programming.
Yours ever, BB
ad infinitum planet view zoomed in
ad infinitum orbital view of a world
@BrodieBrodie, for some reason I can't download the latest version of your game!...
EDIT: Never mind, I can now.
Devoted my life to programming...
your game is the closest I can find to what I want to do. However, I JUST started learning programming. I find seeing code and how it works, I learn a lot better, but I still want my game to be my own. Problem: I only have mobile internet at the moment and can't download your program code to learn. Would you be willing to send it to my email? As soon as I understand the principles better, I can even help you with your game better if you like. Please help, and I can assure you your game will improve because of it. Also, as I create mine I will share the code with you and you can see if you like it and want to use any of it's principles.
Last edited by Salem; 02-28-2013 at 09:30 AM. Reason: no email
Here's my first game. No-frills console tic-tac-toe. CPU AI would be nice addition.
An yahtzee game i have been working on in my free time.
Farm chores first, code later, you know?
made with code::blocks w/mingw
compiler gcc
runs from cmd.exe on windows, should work on unix/linux terminal.
Hope someone enjoys it, and i hope to finish it soon!
yaht-C version 1.2 has been released under the GNU GPLv3.
I do not use linux/unix OS, and i have not tested it with those OS's.
You may download it, and any further versions, here: http://sourceforge.net/projects/yahtc/
Last edited by ramidavis; 02-04-2013 at 01:21 PM.
Well here it is! I know that everyone was just itching for a sequal to part one! I didn't even know the first one was a part one :P
Anyway, here's part two.
Code:Operating system: Win 98 (been known to work on XP though :p) Compiler: Dev-C++ 4.9.8.0 Graphics Library: Mathimatical symbology and other punctuation marks Other Libraries: I have yet to figure this out :) Description: A text adventure! (Not so short this time :p)
Beware of Harriet the Hamster! She's the truly terrible one!
Send your comments to:[email protected]
Last edited by sean; 02-27-2005 at 11:37 AM. Reason: wrong email address
"Whether you think that you can, or that you can't, you are usually right."
This is a Text-based game that kinda needs work.
This is a beta-version and the final version will be much much, longer, and will have more features.
I'm a big newbie to C programming so please email me with bugs or something that should be added to the final version.
Email Me
This is a small file, no worries. Feel free to try all the possiblities in the games menu.
Which 'a Huh?
gotta post code with itOriginally posted by Mustang5670
This is a Text-based game that kinda needs work.
This is a beta-version and the final version will be much much, longer, and will have more features.
I'm a big newbie to C programming so please email me with bugs or something that should be added to the final version.
Email Me
This is a small file, no worries. Feel free to try all the possiblities in the games menu.
I posted my game, but it didn't have the source code with it.This has the source code with it. I've been sick with the flu, so I haven't worked on it any.
Which 'a Huh?
Originally Posted by Mustang5670Mustang I loved your source! I made an expansion pack for Small World, I hope you're feeling better :). The expansion is also incomplete lol. It's a text game. It works perfectly on Linux with gcc 3.3.5 (GNU C Compiler). I hope someone finds it useful! :)Code:Operating system: ANY Compiler: Any C/C++ Compiler Language: C/C++ Description: A small textbased RPG