C program for game design. This code is all about computer and user based play. There will be a turn for a user player & a computer. Anyone can participate this game. Just try yourself to improve your game developmentknowledge.
SIMPLE GAME CODING IN C
Game coding in C is used to design a game in C language like other flash and any other java games. It is an useful resource for students. It will be consider as C mini projects or school project in C.
CODE SNIPPET:
Q: How to create a game in C programming?
01 
02 
03 
04 
05 
06 
07 
08 
09 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
 | /* Title: Game CodeAuthor: Vinoth Selvaraj*///Header file section#include<stdio.h>#include<conio.h>#define TotalSticks 21void main(){    Program variable    int u_Choice,c_Choice,r_Sticks;    char turn;    clrscr(); //Function to clear previous output    printf("Matchstick game being played between the computer and a user.\n");//Display function    printf("\n Rules for the game are as follows:\n");    printf("\n\n\t 1.There are 21 match sticks\n");    printf("\t 2.The computer asks the player to pick 1, 2, 3, or 4 match sticks\n");    printf("\t 3.After the person picks, the computer does its picking\n");    printf("\t 4.Whoever is forced to pick up the last matchstick loses the game\n");    printf("\n Game starts now....\n");    r_Sticks = TotalSticks;    while(1) //Unconditional statement    {        printf("\n User's turn  \n");        turn='u';        printf("\n Enter ur choice : ");        scanf("%d",&u_Choice); //Getting input function        if(u_Choice > 4 && u_Choice < 1) //Conditional statement        {            printf("\incorrect choice \n");            continue;        }        r_Sticks -= u_Choice;        printf("\n Remaining Sticks  : %d\n",r_Sticks);        if(r_Sticks == 1)        {            printf("\n Computer LOST\n");            break;        }        printf("\n Computer's turn\n  ");        turn = 'c';        printf("\n Computer is picking ....\n");        c_Choice = 5 – u_Choice;        printf("\n Computer choice =%d\n",c_Choice);        r_Sticks -= c_Choice;        printf("\n Remaining Sticks  : %d\n",remSticks);        if(r_Sticks == 1)        {            printf("\n**** You LOST *****\n");            printf("\n**** Computer WON the game *****\n");            break;        }    }    getch();} | 
No comments:
Post a Comment