ALT_IMG

You are the cause of my pain

You are the cause of my pain, yet the love I feel for you is my only consolation, my only cure..

ALT_IMG

Saw the girl, whom once I thought as my best friend

Remembering my classmates, after few years, My eyes were filled with tears, Everyone is busy a lot, No one escaped destiny's plot, Saw the girl, whom once I thought as my best friend, Today she is some body else's girl friend, After months remembered about her for a little while, Heard she is happy, that made me smile.

Alt img

It’s been raining since you left me

It’s been raining since you left me, now I’m drowning in the flood. You see, I’ve always been a fighter, but without you I give up.

ALT_IMG

Sweet Heart

Sweetheart.....I miss ......THe whisper of your voice...The warmth of your touch and all the wonderful times that we shared together.......

ALT_IMG

When I see you

When I see you smile and know that it's not for me, that's when I miss you the most.

Showing posts with label Game. Show all posts
Showing posts with label Game. Show all posts
Sunday, June 12, 2011

MAKE SIMPLE GAME IN C

0 comments



Hi friends,here we will make a simple Game in C language.Enjoy C programming.Compile below code and Generate EXE file. 

Source code of Game:

#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <stdlib.h>
#include <time.h>

#define PAS 20

struct time t;
int keye=250;
int coordX=0;
int coorde=0;
int coordY=0;
int coordYe=0;
int tmp=0;
int tmp2=0;
int i;

void moveMyshipLeft(void);
void moveMyshipRight(void);
void moveMyshipUp(void);
void moveMyshipDown(void);
void desenMyShip(int,int,int);

void getConflict(it coordX,int coordXe,int coordY,int coordYe)
{
int stuffz,stuffy;
stuffz=coordX;
}
int getSecTime(void)
{
gettime(&t);
return t.ti_hund;
}
int pressedKey(void)
{
keye=getch();
return(keye);
}

void desenEnemyShip(int coordXe,int coordYe,int culoare)
{
setfillstyle(1,culoare);
bar(0+coordXe,0+coordYe,60+coordXe,40+coordYe);

}
void initDefault(void)
{
}
void desenEnemyShip(int coordX,int coordY,int culoare)
{
setfillstyle(1,culoare);
bar(coordX,coordY,60+coordX,40+coordY);
getConflict(coordX,coordY,coordXe,coordYe);
}

void moveMyShip(void)
{
if ((keye==75) && coordX >getmaxx()-1023)
{
moveMyShipLeft();
}
if ((keye==77) && coordX >getmaxx()-1023)
{
moveMyShipRight();
}
if ((keye==80) && coordY
{
moveMyShipUp();
}
if ((keye==72) && coordY >getmaxy()-767)
{
moveMyShipDown();
}

}
void moveEnemyShips(int coordXe,int coordYe,int culoare)
desenEnemyShip(coordXe,coordYe,0);
coordYe=coordYe+1;
desenEnemyShip(coordXe,coordYe,culoare);
tmp=getSecTime();
}
void initEnamies(void)
{
}
void moveMyShipLeft(void)
{
desenMyShip(coordX,coordY,0);
coordX=coordX-PAS;
desenMyShip(coordX,coordY,2);
}
void moveMyShipRight(void)
{
desenMyShip(coordX,coordY,0);
coordX=coordX+PAS;
desenMyShip(coordX,coordY,3);
}
void moveMyShipUp(void)
{
desenMyShip(coordX,coordY,0);
coordY=coordX+PAS;
desenMyShip(coordX,coordY,4);
}
void moveMyShipDown(void)
{
desenMyShip(coordX,coordY,0);
coordY=coordX-PAS;
desenMyShip(coordX,coordY,5);
}
int huge DetectVGA256(void)
{
int vid=4;
return vid;
}
void doGame(void)

{
initDefault();
coordYe=1000;
do
{
if(coordYe>8oo)
{
coordXe=rand()%1023;
coordYe=40;
}
if(kbhit()){
pressedKey();
moveMyShip();
}
desenMyShip(coordX,coordY,4);
if(getSecTime()+10!=tmp+10)
{
desenEnemyShip(coordXe,coordYe-15,coordY-15,0);
moveEnemyShips(coordXe,coordYe,12);
coordYe=coordYe+15;
}
}
while (keye!=27);
}
void main(void)
{
int gdriver,gmode,errorcode;
gdriver=installuserdriver("svga256",DetectVGA256);
gdriver=DETECT;
initgraph(&gdriver,&gmode,"..\bgi\svga256.bgi");
errocode=graphresult();
if(errorcode!=gr0k)
{
printf("Graphics error:%s\n",grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
doGame();


Pls add your comments.Thanks! Enjoy! :)


Continue reading →