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….
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 🙏🏻🙏🏻
Sir is mtlb kya ptani ho nahi rha hai k was not declared in this scope
Bhai game start kr ke dikha v dete
Sir please explain in english in can't understand behind increasing snake body
thank you sir wonderfull explanations so very very thank sir please videos make in mario game in c/c++ please sir
Tell me how to stable the border of the game
Thank You very much sir this series was very helpful for me…thank you thanks a lot. 🙂
Wow…what a astounding explanation sir… hats off
Whole program continuously watched
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.
great explaination bhai.
Very vvvvvv Thank u bro
Snake Tail is doesn't increase
Part 5 is Giving error of my code.
Reaally 🔥🔥🔥itss chik chik boom firee explaination on YouTube itss great I really thnakful to uuu nd you deserve moree likess
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….
Thanks for knowledge sir
Sir why you didn't use delay function instead of for loop
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!
thank you so much sir, from Indonesia
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 🙏🏻🙏🏻
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….🙏
Thanks a lot sir awesome explanation really helpful for me espically the simple logic ………
I have a better code for this program and my program also doesnot flicker
and my program also has some better features.
Code here:
https://github.com/Lovish-Garg/Projects/tree/master/C/Game/Non-GUI/Snake
Good job bro
Thank you bro for such a detailed explanation. You just saved thousands of students!!
You are just 👍👏 awesome man
Thanks ❤️🔥 brother
yes you are really a good teacher we want more c projects
Which editor?
Please vo jo boardee blink ho ry uska kuch ho sakta kya
👌👌👌
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..
यह कोडिंग कौन से ऐप में किए हैं
Thanks bro
Kitne parts hai iske
Code kahan hai?
Tell me where is code?
Where is code?
good
how to display score
bro I salute your hardwork
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
Can u send me code file of snake game!!
Great job sir thanks
please provide snake game code.
Very well explained!
One more condition sir…..
Snake should not move in backward direction
Thanku ❤️
Thanku so much sir for these videos because of these I understand it very
Clearly from scratch🙏🙏 thanks allot
Sir you are doing great job ☺️👍 .
only video on YouTube where I am getting it's explanation
Very good explanation sir
Keep going for students like us👍