Add to Favorites    Make Home Page 20388 Online  
 Language Categories  
 Our Services  

Home » C Home » Games and Graphics Home » Shoot The Devil - Game In C

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Shoot The Devil - Game In C
Author Pratap Rajkumar Tokekar
Author Email pratap.tokekar [at] gmail.com
Description Hello,

Hi, I am Pratap Rajkumar Tokekar, 1st Year Engineering student from College of Engineering, Pune. I have developed this very simple game after reading the book "Let us c". This is the 1st game I have developed
which I would like to dedicate to my loving parents.This is a very simple graphics game built in "c". It is very easy and enjoyable to play, especially for kids.I hope u will like it.
Category C » Games and Graphics
Hits 379387
Code Select and Copy the Code
#include <stdio.h> #include<conio.h> #include "graphics.h" #include<alloc.h> #include<dos.h> #include<stdlib.h> void exitmessage(void); void lost(void); void main() { randomize(); int gd=DETECT,gm,no=0,area,maxx,maxy,chance=0; int ch,x=25,y=25,xdir=1,ydir=1,x1=20,y1,x1dir=0,area1; void *buff,*cuff; initgraph(&gd,&gm,"bgi"); setcolor(WHITE); setfillstyle(SOLID_FILL,RED); circle(50,50,15); // floodfill(50,50,WHITE); arc(25,25,335,360,40); arc(75,25,180,205,40); circle(42,45,2); circle(54,45,2); setfillstyle(SOLID_FILL,BLACK); floodfill(42,45,15); floodfill(54,45,15); //draw devil setcolor(10); area=imagesize(25,25,75,75); buff=malloc(area); getimage(25,25,75,75,buff); putimage(25,25,buff,XOR_PUT); //erase devil maxx=getmaxx(); maxy=getmaxy(); y1=maxy/2; setcolor(15); setfillstyle(SOLID_FILL,15); rectangle(10,y1,12,y1+2); // floodfill(11,y1+1,15); //draw bullet area1=imagesize(10,y1,12,y1+2); cuff=malloc(area1); getimage(10,y1,12,y1+2,cuff); putimage(10,y1,cuff,XOR_PUT); //erase bullet setcolor(14); rectangle(0,0,maxx,maxy); setviewport(1,1,maxx-1,maxy-1,1); settextstyle(1,0,3); settextjustify(1,1); delay(4000); setcolor(15); while(no<100) { putpixel(random(maxx),random(maxy),random(16)); no++; } outtextxy(maxx/2,30,"...the world is coming to an end..."); outtextxy(maxx/2,80,"...the devil is going to destoy the universe..."); outtextxy(maxx/2,130,"...destroy the devil before it destroys us..."); outtextxy(maxx/2,180,"...ALL THE BEST..."); delay(2000); outtextxy(maxx/2,270,"use "6" to shoot the devil"); outtextxy(maxx/2,310,"use "8" & "2" to move gun vertically"); outtextxy(maxx/2,360,"You have only 10 bullets"); outtextxy(maxx/2,450,"press any key to continue...."); getch(); flushall(); do { clearviewport(); gotoxy(33,1); printf("Bullets Left: %d",10-chance); no=0; while(no<100) { putpixel(random(maxx),random(maxy),random(16)); no++; } if(kbhit()) { ch=getch(); if(ch==54) //shoot bullet { x1dir=1; chance++; } if(ch==56&&x1dir==0) //move gun up y1=y1-10; if(ch==50&&x1dir==0) //move gun down y1=y1+10; if(ch==27) exitmessage(); } fillellipse(10,y1+1,5,3); putimage(x1,y1,cuff,XOR_PUT); //draw bullet delay(10); putimage(x1,y1,cuff,XOR_PUT); //erase bullet x1=x1+10*x1dir; putimage(x,y,buff,XOR_PUT); //draw devil delay(30); putimage(x,y,buff,XOR_PUT); //erase devil x=x+(xdir*random(30)); y=y+(ydir*random(20)); if(x>=maxx-71) //keep devil within screen { xdir*=-1; x=maxx-71; } if(x<=175&&xdir==1) x=175; if(x<=175&&xdir==-1) xdir*=-1; if(y>=maxy-71) { ydir*=-1; y=maxy-71; } if(y<=30) { ydir*=-1; y=30; } // if(x1>=maxx-3||x<=1) //failed chance { x1=20; x1dir=0; } if(y1>=maxy-20) //keep gun within screen y1=maxy-21; if(y1<=20) y1=21; // if(x1<=x+40&&x1>=x+12&&y1<=y+38&&y1>=y+10) //successful hit { moveto(maxx/2,maxy/2); outtextxy(maxx/2,maxy/2,"...YOU'VE...WON..."); sound(500); delay(5000); nosound(); delay(3000); exit(0); } } while(chance<=10); if(chance=11) lost(); getch(); closegraph(); restorecrtmode(); } void exitmessage() { char cho; outtextxy(getmaxx()/2,getmaxy()/2,"EXIT : Y or N..."); delay(100); flushall(); cho=getch(); if(cho=='y'||cho=='Y') exit(0); else if(cho=='n'||cho=='N') { clearviewport; return; } } void lost() { outtextxy(getmaxx()/2,getmaxy()/2-50,"Your bullets are over"); outtextxy(getmaxx()/2,getmaxy()/2,"The devil destroys the world"); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=818


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review