Happy Birthday Magic Game Code in C Language with explanation


What is C language 

     C language is a general-purpose low-level programming language that allows you to communicate with the computer. so you have to just code in c language then the computer will behave accordingly.c language is found by denis m riche at bel laboratory. c language is s middle-level language because it supports both the feature of low-level language and high-level language.c language is a starting language for any computer student. means if you are a student of computer engineering then you have to learn first c language. after learning the c language it is easier to learn another language like java or python.c language is very easy to use and very easy to learn. many of institute teaches c language as the starting language to any student of that belongs to software engineering. you can make compiler, machine code, windows app, games, graphics, embedded programming using c language. many universities use the c language for the data structure. c language will build your logic. and I want to tell you another thing that if you will able to make logic in c language then you will also be able to make logic in any programming language. the syntax for a different programming language differs but the main concept and logic for building any program will remain same.

  

   Many of the c users are making games in c language and in today's article, I am gonna show you that how you can make a happy birthday magic game using c language .yesterday was the birthday of my friend karan_dalasania. I have given him a Programmatically surprise him. I have given him a game that was developed using c language. I can not exress the happiness on my friend's face when i did deliver my surprise to my friend Karan Dasani.


 also, Karan dalsania is my classmate. he is also very clever in computer engineering. so he accepted my game code and frame it to that code on his wall.


how to make game in c


 First of all, see below code of happy birthday magic code :::


                     Copy this code and Run it on Turbo c.

                                                                  Then you will see Programmatically Magic. 



#include<stdio.h>

#include<conio.h>

#include<dos.h>

#include<string.h>

#include<stdlib.h>

 void wish();

void sdk();



void karan_dalasania()

{

int x,y;

char *cake="Cake";

  char k,*dk="D.K.";

 clrscr();


 textcolor(3);

   textbackground(6);

cprintf(" Use A S D W keys for Move D.K  ");

textcolor(8);

cprintf("Use Esc for Exit ");






gotoxy(12,4);



}

void move()

{

 int x=12,y=4,m=70,n=19,i,j,ll,k;

 char ch;

 textcolor(9);

 cprintf("D.K");

  gotoxy(m,n);

  textcolor(7);

  cprintf("| cadbory |");

  gotoxy(x,y);

 while((x!=80) && (y!=19))

 {

 ch=getch();

 for(j=50;j<500;j=j+50)

 {

 sound(j);

 delay(20);

 }

 nosound();

 switch(ch)

 {

 case 'a':x--;

 break;

 case 's':y++;

 break;

 case 'd':

 x++;

 break;

 case 'w':y--;

 break;

 case 27:



 clrscr();

 for(k=10;k<1000;k=k+10)

 {sound(k);

 delay(5);}

 nosound();


 gotoxy(18,13);

       cprintf("---------Kaisa Laga Mera Gift--------");

       textcolor(3);

       cprintf("\n Message on my instagram");

       cprintf("\n                                                     Instagram ID :aboti_akshay");


       getch();


  exit(0);

 break;

 }

 clrscr();

 gotoxy(x,y);

 textcolor(2);

 cprintf("D.K");

 gotoxy(m-2,n);

 textcolor(7);


 cprintf("| Cadbory |");

 gotoxy(1,1);


 textcolor(3);

   textbackground(6);

cprintf(" Use A S D W keys for Move instance  ");

textcolor(8);

cprintf("Use Esc When D.K. got Cadbory ");






  }

  textcolor(5);

 for(i=500;i<550;i++)

 {

 sound(i);

  delay(5);

  }

  gotoxy(6,7);

 cprintf(" \n\n\n\n   Wow ! D.K. has got the Cadbory !!");

 nosound();

 getch();

 clrscr();

 for(k=10;k<1000;k=k+10)

 {sound(k);

 delay(5);}

 nosound();

  gotoxy(18,13);

 cprintf("---------Kaisa Laga Mera Gift--------");

       textcolor(3);

       cprintf("\n Message on my instagram");

       cprintf("\n                                                     Instagram ID :aboti_akshay");

       getch();


}



void main()

{       char ch;


char *replay;

int i;

 clrscr();

textcolor(3);

printf("\n\t\t\t     #########   #   #");

printf("\n\t\t\t        #    #   #  #");

printf("\n\t\t\t        #    #   # #");

printf("\n\t\t\t        #    #   ##");

printf("\n\t\t\t        #    #   #");

printf("\n\t\t\t        #    #   ##");

printf("\n\t\t\t        #    #   # #");

printf("\n\t\t\t        #    #   #  #");

printf("\n\t\t\t     ######### * #   # *");

gotoxy(1,11);

  cprintf("\nDo you want to wish ");textcolor(5);cprintf("Dalsania Karan ");textcolor(3);cprintf("for his BIRTHHDAY : ");

  gets(replay);


  if((strcmp(replay,"YES")==0 )||(strcmp(replay,"yes")==0 ) || (strcmp(replay,"Y")==0 ) || (strcmp(replay,"y")==0 ));

  {

  clrscr();

  gotoxy(1,7);

    sdk();

     ch=getch();

     if(ch>='a' && ch<='z');

      clrscr();

      wish();

    getch();

    karan_dalasania();

    move();

  }

   getch();

}

void sdk()

{

int i,k;

char j;

int l;

char *author="--- Created by Aboti Akshay from AVPTI.. ";

char *person="------__HAPPY BIRTHDAY DALSANIA KARAN__------ ";

for(l=50;l<210;l++)

{

sound(l);


textcolor(3);

cprintf("*");

delay(30);

}

nosound();

       printf("\n\n\n\t\t");

  for(i=100,k=0;i<200 && person[k]!='\0';i++,k++)

  {


  textcolor(k+1);

  textbackground(7);

  cprintf("%c",person[k]);

  sound(i);



  delay(150);


  }

  nosound();

   printf("\n\n\n");

   textbackground(0);

  for(l=50;l<210;l++)

{

sound(l);


textcolor(3);

cprintf("*");

delay(30);

}

nosound();

printf("\n\t\t\t\t\t");

     for(i=100,k=0;i<200 && author[k]!='\0';i++,k++)

  {



  textcolor(2);

  cprintf("%c",author[k]);

  sound(i);



  delay(100);



  }

   textcolor(6);

    cprintf("\n\nDon't go back . Stay in the GAME ");

  nosound();


}

void wish()

{

   char *akshay="Many Many Happy Returns of the day";

    int i;

    for(i=0;i<70;i++)

    {

    sound(40);

    textcolor(i+1);

    cputs(akshay);

    sound(3000);

    delay(35);

    sound(10000);

    }

    textbackground(2);

    textcolor(0);

    cprintf("Don't go back . Stay in the GAME ");


    nosound();

}  



Explanation of happy birthday game code:- 

     Happy birthday game is very very simple, after seeing more lines in that code, you think that happy birthday game code is very difficult to understand .but trust me it is very easy to understand and also you can build this game on your own. in this article I will show you that how you can build this game code on your own in an easy manner.


 Explanation of logic behind happy birthday game code:-

      I have just used colors, sound, and arrow keys in that code.

  if you want to make happy birthday game code in c language you need to learn following things firsts:-

  - graphics in C

  - foreground and background color in C

  - use sound in C

  - how to access position in C

  - how to access which key when pressed.


  Explanation of game:- the entire game is divided into three categories.

  1) on that first page when you run that code, you will be simply asked to entering the name whose first you want to celebrate. then it will ask to confirm for wish to that person. after entering yes there. you will see your friend's name is printing using animation with sound


  2) on the second page you will repeatedly see a happy birth happy birthday message with different colors scrolling with sound, when you press any key from the keyboard happy birthday message will disappear.


  3) the main game is here. my friend likes category chocolate, so ultimately you have to feed the category to Karan dalasania. consider Karan dalasania and category as an object. you can use the arrow key to move the Karan dalasania object or you can use the ASDF key to move the Karan dalsania object. when Karan dalasania object reaches the position of category the game will over and message will be print on the screen that is "You have successfully wish to Karan dalsania for his birthday, thank you".





Post a Comment

0 Comments