Simple Snake Game Program in C | With Source Code | C Programming - playproduction.de

Simple Snake Game Program in C | With Source Code | C Programming

Coding Guidelines Tamil
Views: 22821
Like: 797
Simple Snake Game Program in C | with Source Code | C Programming

Please Check Commend Box, In Description Angular Brackets are not Support. So source code pinned in Command Box.

Snake game in c,
c programming for beginners,
Simple snake game in c,
c project,
snake and ladders game in c with source code,
c simple project

Video Keywords:
c programming for beginners in tamil,
c programming for beginners,
c language tutorial for beginners,
for loop in c language,
pattern program in c language,
coding for beginners in tamil,
armstrong number in c,
c program in tamil,
c language in tamil,
c programming tamil,
bubble sort,
pattern printing in c language,
anagram program in c,
call by value and call by reference in c,
c language,
factorial program in c,
what is c programming in tamil,
c++ programming in tamil,
call by value and call by reference in c tamil,
star pattern program in c,
bubble sort in c,
what is coding in tamil,
how to learn coding for beginners in tamil,
loop in c programming,
programming in c tamil,
c language tamil,
pyramid pattern in c,
c language tutorial for beginners in tamil,
c program tamil,
loops in c programming,
c++ programming,
insertion sort,
learn c programming in tamil,
print prime numbers from 1 to 100 in c,
c programming basics in tamil,
loops in c,
coding for beginners,
for loop,
for loop in c,
function in c programming examples,
printing patterns in c,
programming language in tamil,
switch case in c programming,
switch statement in c programming,
array in c programming,
c programming for beginners tamil
//IDE-Code::Blocks
//Simple Snake Game in C Language

9 Comments

  1. //Source Code//IDE-Code::Blocks
    //Simple Snake Game in C Language
    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>
    #include<unistd.h>
    int i,j,H=16,W=16,game_over,score;
    int x,y,point_x,point_y,flag;
    int gameover,score,c=0;
    //function to draw outer wall
    void draw_outer_wall()
    {
    system("cls");
    printf("Press Left, Right, Up or Down Arrow to Start…nn");
    for(i=0;i<H;i++)
    {
    printf(" ");
    for(j=0;j<W;j++)
    {
    if(i==0 || i==H-1|| j==0 || j==W-1)
    printf("[]");
    else
    {
    if(i==x && j==y)
    printf("0 ");
    else if(i== point_x && j==point_y)
    printf("$ ");
    else
    printf(" ");
    }
    }
    printf("n");
    }
    printf("nScore : %dn",score);
    printf("press q for Quit the Gamen");
    }
    //function to generate points to with in a outer wall
    void set_random_ball()
    {
    game_over=0;
    x=H/2;
    y=W/2;
    x_label:
    point_x=rand()%16;
    if(point_x == 0)
    goto x_label;
    y_label:
    point_y=rand()%16;
    if(point_y == 0)
    goto y_label;
    score=0;
    }
    //function to take user input
    void user_input()
    {
    if(kbhit())
    {
    switch(getch())
    {
    case 75: flag=1;
    break;
    case 77: flag=2;
    break;
    case 72: flag=3;
    break;
    case 80: flag=4;
    break;
    case 'q': gameover=2;
    break;
    }
    }
    }
    //function for movement
    void move_logic()
    {
    sleep(.1);
    switch(flag)
    {
    case 1: y–;
    break;
    case 2: y++;
    break;
    case 3: x–;
    break;
    case 4: x++;
    break;
    }
    if(x<1 || x>H -2|| y<1 || y>W-2)
    gameover=1;
    if(x==point_x && y==point_y)
    {
    x_label:
    point_x=rand()%16;
    if(point_x == 0)
    goto x_label;
    y_label:
    point_y=rand()%16;
    if(point_y == 0)
    goto y_label;
    score=score+1;
    }
    }
    void main()
    {
    start:
    gameover=0;
    flag=0;
    c=0;
    set_random_ball();
    while(gameover!=1 && gameover!=2)
    {
    draw_outer_wall();
    user_input();
    move_logic();
    }
    if (gameover==2)
    printf("You Quit the Gamen");
    else
    {
    char ch;
    printf("You Hit the wall want to play again(y/n): ");
    scanf(" %c",&ch);
    if(ch=='y' || ch=='Y')
    goto start;
    else
    printf("Program Endedn");
    }
    }

  2. Bro ithae matheri nanum try pannen but varala bro. Unga insta I’d kuduga bro na athula pesuren

  3. Snake body create panni epdi move pandrathu bro ?

  4. Cant you do a ++ for the snake when it eatsh the food?

  5. Can we make this on linux? Ubuntu?

Leave a Reply

Your email address will not be published.