snake game code in c full explanation in hindi (part 5 of 5) - playproduction.de

snake game code in c full explanation in hindi (part 5 of 5)

Vashishth Muni Singh
Views: 37292
Like: 862

114 Comments

  1. Sir is mtlb kya ptani ho nahi rha hai k was not declared in this scope

  2. Sir please explain in english in can't understand behind increasing snake body

  3. thank you sir wonderfull explanations so very very thank sir please videos make in mario game in c/c++ please sir

  4. Tell me how to stable the border of the game

  5. Thank You very much sir this series was very helpful for me…thank you thanks a lot. 🙂

  6. Wow…what a astounding explanation sir… hats off

  7. Sir in this program snake tail doesn't increase as well as score didn't get updated help me sir . I have written the same code as you coded.

  8. Snake Tail is doesn't increase
    Part 5 is Giving error of my code.

  9. Reaally 🔥🔥🔥itss chik chik boom firee explaination on YouTube itss great I really thnakful to uuu nd you deserve moree likess

  10. sir can u put the code in on this " https://www.onlinegdb.com/ "website i went it as mine has caused come errors…n i am not able to debug the problem as the length of the snake is not increasing in mine!

    sir u can create an account on this site and shar the code with ur students who are facing an issue….

  11. Sir why you didn't use delay function instead of for loop

  12. Sir the fruit is generated only twice then it is not generated.

    #include"stdio.h"
    #include<conio.h>
    #include<stdlib.h>
    #include<windows.h>
    void hidecursor()
    {
    HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO info;
    info.dwSize = 100;
    info.bVisible = FALSE;
    SetConsoleCursorInfo(consoleHandle, &info);
    }
    int tailx[100],taily[100];
    char sym='#',ch;
    int width=25,height=25,gameover,flag;
    int x,y,fruitX,fruitY,score=0;
    int count=0;
    int logic()
    {
    int i;
    int prevx=tailx[0]; //tailx=1,taily=1,prevx=1
    int prevy=taily[0];
    tailx[0]=x,taily[0]=y;
    int prevx2,prevy2;
    for(i=1;i<count;i++)
    {
    prevx2=tailx[i];
    prevy2=taily[i];
    tailx[i]=prevx;
    taily[i]=prevy;
    prevx=prevx2;
    prevy=prevy2;
    }
    switch(flag)
    {
    case 1:
    x–;
    break;
    case 2:
    x++;
    break;
    case 3:
    y–;
    break;
    case 4:
    y++;
    break;
    }
    if(x<0||x>height-1||y<0||y>width-1)
    gameover=1;
    for(i=0;i<count;i++)
    {
    if(x==tailx[i]&&y==taily[i])
    gameover=1;
    }
    if(x==fruitX&&y==fruitY)
    {
    fruitX=rand()%height;
    fruitY=rand()%width;
    score++;
    count++;
    }
    }
    int input()
    {
    if(kbhit())
    {
    switch(getch()){
    case 72:
    flag=1;//up
    break;
    case 80:
    flag=2;//down
    break;
    case 75:
    flag=3;//left
    break;
    case 77:
    flag=4;//right
    break;
    default:
    break;
    }
    }
    }
    int setup()
    {
    x=height/2;
    y==width/2;
    fruitX=rand()%height;
    fruitY=rand()%width;
    score=0;
    }
    draw(void)
    {
    int i,j,k;
    system("cls");
    for(i=-1;i<height;i++)
    {
    for(j=-1;j<width;j++)
    {
    if(i==-1||i==height-1||j==-1||j==width-1)
    {
    printf("%c",sym);
    }
    else{
    if(i==x&&j==y)
    printf("O");
    else if(i==fruitX&&j==fruitY)
    printf("F");
    else
    {
    int ch=0;
    for(k=0;k<count;k++)
    {
    if(i==tailx[k]&&j==taily[k])
    {
    printf("o");
    ch=1;
    }
    }
    if(ch==0)
    printf(" ");
    }
    }
    }
    printf("n");
    }
    }
    int main()
    {
    int m,n;
    setup();
    while(gameover!=1){
    printf("tttttScore=%dn",score);
    hidecursor();
    draw();
    input();
    logic();

    }
    }

    This is the source code.Please help!

  13. thank you so much sir, from Indonesia

  14. Extremely thanks for your effort, your way of explanation is fabulous and I try this code, it run and work but the problem is that the snake size enhance only one time further it eat fruit but didn't enhance size , what Happened this sir reply me please 🙏🏻🙏🏻

  15. ThanQ soo much sir
    Form past few days i am searching for a good video which teaches me better ..
    Nd i fount it there…
    Thankuu soo much sir….🙏

  16. Thanks a lot sir awesome explanation really helpful for me espically the simple logic ………

  17. Thank you bro for such a detailed explanation. You just saved thousands of students!!

  18. yes you are really a good teacher we want more c projects

  19. Please vo jo boardee blink ho ry uska kuch ho sakta kya

  20. Learned a lot from you thank you but why is the boderline of the game is not stable ? and what should i do to make stable those boderline?

    again thank you so much..
    please explain sir..

  21. RKHMQ (RK Hindi Motivational Quotes) says:

    यह कोडिंग कौन से ऐप में किए हैं

  22. Why this channel have 7.6k subscribers it should be more than 1m. Thank you sir for this excellent lecture. Thank you thank you so much

  23. One more condition sir…..
    Snake should not move in backward direction

  24. Thanku so much sir for these videos because of these I understand it very
    Clearly from scratch🙏🙏 thanks allot

  25. Sir you are doing great job ☺️👍 .

  26. only video on YouTube where I am getting it's explanation
    Very good explanation sir
    Keep going for students like us👍

Leave a Reply

Your email address will not be published.