Pacman game का project कैसे बनाये in C programming in Hindi | with source code

 हेलो दोस्तों !

आज की इस Pacman game का project कैसे बनाये in C programming in Hindi पोस्ट में हम pacman game project को C programming की मदद से बनाना सीखेंगे। तो दोस्तों अगर आप इस प्रोजेक्ट को अच्छी तरह सीखना चाहते है तो इस पोस्ट को लास्ट तक जरूर पढ़े। 


इस पोस्ट के मुख्य टॉपिक्स निन्म है -

  1. pacman game क्या है ?
  2. pacman गेम कैसे बनाये ?
  3. pacman game project source code.
  4. pacman game project video.

1. pacman game क्या है :-

दोस्तों सबसे पहले हम यह जान लेते है की pacman game क्या होता है ?


pacman game project in c programming in hindi



दोस्तों pacman गेम एक बहुत ही इंटरेस्टिंग गेम है। इस गेम में एक pacman होता है जो की foods को खाता है और जब pacman सारे foods को खा लेता है तो आप गेम को जीत जाते है। इस गेम में ghost भी होते है जिनसे pacman को हमें बचाना होता है। अगर हमारा pacman ghost से टकराता है तो गेम end हो जाता है और हम गेम हार जाते है। 

इस गेम में हमें pacman को घोस्ट से बचाते हुए सारे फूड्स को खाना होता है। तभी हम गेम को जीत पाते है। और अगर गलती से भी घोस्ट  pacman से टकरा जाता है तो हमारा गेम end हो जाता है। 

2. pacman गेम कैसे बनाये :-

दोस्तों अब हम जान लेते है की pacman गेम को कैसे बनाये ?

तो दोस्तों pacman गेम को c programming में बनाने के लिए सबसे पहले तो आपको C प्रोग्रामिंग लैंग्वेज आनी चाहिए। तभी आप इस प्रोजेक्ट को बना पाएंगे। इसके साथ ही आपको pacman गेम को बनाने के लिए टर्बो ,कोड ब्लॉक्स जैसी कंसोल IDE का यूज़ करना पड़ेगा तभी आप इसे अच्छी तरह बना पाएंगे। 

तो अगर हम बात करें की इस प्रोजेक्ट को कैसे बनाये तो आपको इस प्रोजेक्ट को स्टेप-बाई-स्टेप बनाना है। इसका मतलब है की आपको पहले इस प्रोजेक्ट के किसी एक पार्ट की कोडिंग करनी है और जब उसकी कोडिंग हो जाये  फिर दूसरे पार्ट की कोडिंग करनी है। इस प्रकार पुरे प्रोजेक्ट को छोटे-छोटे पार्ट में बाँट कर कोडिंग करनी है।  इस प्रकार आप इस प्रोजेक्ट को छोटे-छोटे पार्ट में बाँट कर बना सकते है। 

आपको इस प्रोजेक्ट की कोडिंग इसी तरह से करनी है। आपको पुरे प्रोजेक्ट की कोडिंग एक ही बार में करने की नहीं सोचना है। अगर आप ऐसा करेंगे तो आपको प्रोजेक्ट काफी कठिन लगेगा और आप इस प्रोजेक्ट को आसानी से नहीं बना पाएंगे। 

वैसे हमने इस प्रोजेक्ट का सोर्स कोड नीचे दे रखा है अगर आप चाहे तो इस सोर्स कोड से भी आईडिया ले सकते है की आपको किस प्रकार pacman गेम प्रोजेक्ट की कोडिंग करनी है। 

3. pacman game project source code :-

दोस्तों अब हम इस प्रोजेक्ट का source code देख लेते है। 

तो दोस्तों ये है pacman गेम project का सोर्स कोड जोकि C प्रोग्रामिंग में है हमने इसे टर्बो पर बनाया है इसलिए अगर आप इस प्रोजेक्ट को विसुअल स्टूडियो जैसी IDE पर रन करने का प्रयास करेंगे तो आपको इस प्रोजेक्ट में काफी सारी errors मिलेंगे जिनको आप vs code पर सॉल्व नहीं कर पाएंगे। इसलिए आपको इस प्रोजेक्ट को टर्बो या कोड ब्लॉक्स जैसी कंसोल IDE पर बनाना है। 

project source code :-


#include< stdio.h >
#include< stdlib.h >
#include< conio.h > 
#include< dos.h >
#define H 15
#define W 40
char playfield[H][W]={
{"****************************************"},
{"* .....................................*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*......................................*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*..*..*..*..*..*..*..*..*..*..*..*..*..*"},
{"*......................................*"},
{"****************************************"}
}; //this is our playfield

int food_collect=0,game_end=0;
int py=1,px=1;//these variables represent pacman coordinate
int gy1=1,gx1=38,gy2=13,gx2=1;//these variables represent ghosts coordinate
void game_result()
{
//this function check you won the game or not
  clrscr();
  if(food_collect==500)
  {
    printf("\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t        Congratulation!\n");
    printf("\t\t\t       You won the game!\n");
    printf("\t\t\t     Your total score is %d",food_collect);
  }
  else
  {
    printf("\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t          Better luck!\n");
    printf("\t\t\t       You lose the game!\n");
    printf("\t\t\t     Your total score is %d\n",food_collect);
  }
}
void move_ghosts()
{
 if(gy1==1 && gx1 > 1)
 {
   gx1--; //this statement move 1st ghost coordinate to left side
 }
 else if(gx1 == 1 && gy1 < 7)
 {
   gy1++; //this statement move 1st ghost coordinate to down side
 }
 else if(gy1 == 7 && gx1 < 38)
 {
   gx1++; //this statement move 1st ghost coordinate to right side
 }
 else if(gx1 == 38 && gy1 > 1)
 {
   gy1--; //this statement move 1st ghost coordinate to up side
 }

 if(gy2 == 13 && gx2 < 38)
 {
   gx2++; //this statement move 2nd ghost coordinate to right side
 }
 else if(gx2 == 38 && gy2 > 7)
 {
   gy2--; //this statement move 2nd ghost coordinate to up side
 }
 else if(gy2 == 7 && gx2 > 1)
 {
   gx2--; //this statement move 2nd ghost coordinate to left side
 }
 else if(gx2 == 1 && gy2 < 13)
 {
   gy2++; //this statement move 2nd ghost coordinate to down side
 }
}
void user_input()
{
//this function use to take user input
 char c1;
 if(kbhit())
 {
   c1=getch();

   switch(c1)
   {
     case 72:py-=1;break; //cursor up
     case 80:py+=1;break; //cursor down
     case 75:px-=1;break; //cursor left
     case 77:px+=1;break; //cursor right
   }
 }
}
void setup()
{
int a,i,j;
for(i=0;i < H;i++)
{
  for(j=0;j < W;j++)
  {
    if(playfield[i][j]=='#')
    {
      playfield[i][j]=' ';
    }
    if(playfield[i][j]=='@')
    {
      playfield[i][j]='.';
    }
  }
}
if(playfield[py][px]=='.')
{
  food_collect++;
}
if(playfield[py][px]=='*')
{
  py=1;
  px=1;
}
playfield[py][px]='#';
playfield[gy1][gx1]='@';
playfield[gy2][gx2]='@';

if(playfield[py][px]=='@')
{
  game_end=1;
}
}
void draw_playfield()
{
int i,j;
textcolor(YELLOW);
printf("\n\n\n\n");
for(i=0;i < H;i++)
{
  printf("\t\t");
  for(j=0;j < W;j++)
  {
    cprintf("%c",playfield[i][j]);
  }
  printf("\n");
}
printf("Score is %d ",food_collect);
}
void main()
{
int i=100;
while(game_end!=1)
{
  clrscr();
  sound(i);
  setup();
  user_input();
  move_ghosts();
  draw_playfield();
  delay(200);
  if(i < 1000)
  i=i+100;
  else
  i=100;
}
nosound();
game_result();
getch();
}

4. pacman game project video :-

दोस्तों अगर आपको इस प्रोजेक्ट का सोर्स समझ नहीं आ रहा है तो आप हमारी यह वीडियो देख सकते है जिसमें हमने इस pacman गेम प्रोजेक्ट के सोर्स कोड को अच्छी तरह से समझाया है तो वीडियो को पूरा जरूर देखें। 

वीडियो देखने के लिए यहाँ क्लिक करें।


इन पोस्ट को भी पढ़े -


Author :- तो दोस्तों अब हमारी यह Pacman game का project कैसे बनाये in C programming in Hindi पोस्ट ख़त्म होती है हम आशा करते है की आपको हमारी यह पोस्ट जरूर पसंद आई होगी। और आप pacman game का C project बनाना सीख गए होंगे। तो दोस्तों आज के लिए बस इतना ही फिर मिलेंगे ऐसी ही किसी और मज़ेदार पोस्ट में तब तक के लिए अलविदा !

Post a Comment

0 Comments