Home
Downloads
Projects
Forum
Portfolio
Contact
Ajinkya Mandhare
"The Goal is not to live forever...the goal is to create something that will"
Saturday, 26 March 2011
Tagged under:
screen saver c++ code
,
SE IV Sem
,
Source codes
Computer Graphics mini project/ Screen Saver code
Anonymous
11:18 am
No comment
1. Car Screensaver:
/******************************************************************* Program : Screensaver: Moving car ********************************************************************/ #include<iostream.h> #include"conio.h" #include<math.h> #include"stdlib.h" #include"dos.h" #include"graphics.h" #define DELAY 1 #define SOUND 3500 void state(int x,int y,int mode); int area,area1; void *ptr1,*ptr2,*burst; void BF(int,int,int,int); void circ_bre(int x,int y,int rad); void draw_burst ( int x, int y,int ); void display(int,int,int,int); void dda(int x1,int y1,int x2,int y2); int COND(int x,int y) { if (x>20 && x<getmaxx()-20 && y>20 && y<getmaxy()-20) return 1; else return 0; } void state(int x,int y,int mode) { while(COND(x,y)&&!kbhit()) { if(x==300&&y==230) { putimage(350,230,burst,COPY_PUT); sound(SOUND); delay(100); cleardevice(); state(30,30,0); } switch(mode) { case 0: // x++; putimage(getmaxx()-x,getmaxy()-y,ptr1,COPY_PUT); // delay(1); putimage(x,y,ptr2,COPY_PUT); // putimage(getmaxx()-x,getmaxy()-y,ptr1,XOR_PUT); // putimage(x,y,ptr2,COPY_PUT); // delay(3); //putimage(x,y,ptr2,XOR_PUT); x++; break; case 1: // x--; // putimage(getmaxx()-x,getmaxy()-y,ptr2,COPY_PUT); // delay(1); putimage(x,y,ptr1,COPY_PUT); putimage(getmaxx()-x,getmaxy()-y,ptr2,COPY_PUT); //putimage(x,y,ptr1,COPY_PUT); //delay(3); //putimage(x,y,ptr1,XOR_PUT); x--; break; case 2: putimage(getmaxx()-x,getmaxy()-y,ptr1,COPY_PUT); //delay(3); putimage(x,y,ptr2,COPY_PUT); //putimage(getmaxx()-x,getmaxy()-y,ptr1,XOR_PUT); //putimage(x,y,ptr2,COPY_PUT); //delay(3); //putimage(x,y,ptr2,XOR_PUT); x--; break; case 3: putimage(getmaxx()-x,getmaxy()-y,ptr2,COPY_PUT); //delay(3); putimage(x,y,ptr1,COPY_PUT); //putimage(getmaxx()-x,getmaxy()-y,ptr2,XOR_PUT); //putimage(x,y,ptr1,COPY_PUT); // delay(3); //putimage(x,y,ptr1,XOR_PUT); x++; break; } // delay(0); nosound(); } cleardevice(); if(y>=getmaxy()-20||y<=20) { sound(SOUND); switch(mode) { case 0: state(++x,y=y-20,2); break; case 1: state(++x,y=y+20,3); break; case 2: state(++x,y=y+20,1); break; case 3: state(++x,y=y+20,0); break; } } if(x>=(getmaxx()-20)||x<=20) { sound(SOUND); switch(mode) { case 0: state(--x,y=y+20,1); break; case 1: state(++x,y=y+20,0); break; case 2: state(--x,y=y-20,3); break; case 3: state(++x,y=y-20,2); break; } } } void main() { int gd = DETECT, gm; /*detect the graphics drivers automatically*/ initgraph(&gd,&gm,"\tc\tc\bgi"); /*Initialise to graphics mode*/ //int area; cleardevice(); // setbkcolor(); //CAR 1 dda(60,70,60,85); dda(60,70,80,75); dda(60,70,90,70); dda(80,75,80,90); dda(60,85,80,90); dda(80,75,110,75); dda(90,70,110,75); dda(90,70,110,55); dda(110,55,130,60); dda(110,75,130,60); dda(80,90,90,90); dda(110,90,160,90); dda(180,90,190,90); dda(190,75,190,90); dda(170,60,190,75); dda(130,60,170,60); dda(150,55,170,60); dda(110,55,150,55); dda(117,73,132,62); dda(132,62,168,62); dda(117,73,183,73); dda(168,62,183,73); dda(150,62,150,73); circ_bre(100,90,10); circ_bre(170,90,10); // BF(70,90,15,12); area=imagesize(59,55,191,100); ptr1=malloc(area); // setcolor(3); // floodfill(70,80,15); getimage(59,55,191,100,ptr1); cleardevice(); //CAR 2 dda(60,75,60,90); dda(60,75,80,60); dda(80,60,120,60); dda(80,60,100,55); dda(100,55,140,55); dda(120,60,140,55); dda(120,60,140,75); dda(140,55,160,70); dda(140,75,160,70); dda(160,70,190,70); dda(170,75,190,70); dda(140,75,170,75); dda(190,70,190,85); dda(170,90,190,85); dda(170,75,170,90); circ_bre(150,90,10); circ_bre(80,90,10); dda(160,90,170,90); dda(90,90,140,90); dda(60,90,70,90); dda(118,62,137,75); dda(80,62,118,62); dda(64,75,80,62); dda(64,75,137,75); dda(100,62,100,75); area=imagesize(59,55,190,100); ptr2=malloc(area); getimage(59,55,191,100,ptr2); cleardevice(); draw_burst(200,300,area1); cleardevice(); state(30,30,0); getch(); closegraph(); } void dda(int x1,int y1,int x2,int y2) { int i,dx,dy,steps; float x,y; float xinc,yinc; dx = (x2-x1); dy = (y2-y1); if(abs(dx)>=abs(dy)) /* decide whether to move along x-direction */ steps = dx; /* or y-direction */ else steps = dy; xinc =(float) dx/steps; /*calculate the increment value for x & y*/ yinc =(float) dy/steps; x = x1; y = y1; putpixel (x,y,RED); /* plot first point */ for (i=1;i<steps;i++) { x = x + xinc; y = y + yinc; /* convert the floating value to its nearest interger value. i.e. same as use of floor or ceil function */ x1 = x + 0.5 ; y1 = y + 0.5 ; putpixel (x1,y1,RED); /* plot the points */ } } void circ_bre(int x,int y,int rad) { float dp; //initialising the descision parameter. int x1,y1; x1 = 0; //initialisng the X,Y cordinates. y1 = rad; dp = 3 - 2*rad; while(x1<=y1) { if(dp<=0) dp += (4 * x1) + 6; else { dp += 4*(x1-y1)+10; y1--; } x1++; display(x1,y1,x,y); } } void display (int x1,int y1,int x,int y) { putpixel(x1+x,y1+y,WHITE); //plotting the pixels. putpixel(x1+x,y-y1,WHITE); putpixel(x-x1,y1+y,WHITE); putpixel(x-x1,y-y1,WHITE); putpixel(x+y1,y+x1,WHITE); putpixel(x+y1,y-x1,WHITE); putpixel(x-y1,y+x1,WHITE); putpixel(x-y1,y-x1,WHITE); } /*void BF(int x,int y,int bc,int fc) {if(getpixel(x,y)!=bc&&getpixel(x,y)!=fc) {putpixel(x,y,fc); BF(x+1,y,bc,fc); BF(x+1,y-1,bc,fc); BF(x,y-1,bc,fc); BF(x-1,y-1,bc,fc); BF(x-1,y,bc,fc); BF(x-1,y+1,bc,fc); BF(x,y+1,bc,fc); BF(x+1,y+1,bc,fc); } } */ void draw_burst ( int x, int y,int area ) { // setlinestyle(0,0,1); line ( x - 16, y - 12, x - 10, y - 2 ) ; line ( x - 10, y - 2, x - 16, y ) ; line ( x - 16, y, x - 10, y + 2 ) ; line ( x - 10, y + 2, x - 16, y + 12 ) ; line ( x - 16, y + 12, x - 6, y + 2 ) ; line ( x - 6, y + 2, x, y + 12 ) ; line ( x, y + 12, x + 6, y + 2 ) ; line ( x + 6, y + 2, x + 16, y + 12 ) ; line ( x - 16, y - 12, x - 6, y - 2 ) ; line ( x - 6, y - 2, x, y - 12 ) ; line ( x, y - 12, x + 6, y - 2 ) ; line ( x + 6, y - 2, x + 16, y - 12 ) ; line ( x + 16, y - 12, x + 10, y - 2 ) ; line ( x + 10, y - 2, x + 16, y ) ; line ( x + 16, y, x + 10, y + 2 ) ; line ( x + 10, y + 2, x + 16, y + 12 ) ; area=imagesize(0,0,32,24); burst=malloc(area); getimage(200-16,300-12,200+16,300+12,burst); // putimage(200-16,300-12,200+16,300+12,burst); cleardevice(); // putimage(200-16,300-12,200+16,300+12,burst); }
Kindly Bookmark and Share it:
Newer Post
Older Post
0 comments:
Post a Comment
Subscribe to:
Post Comments (Atom)
Recommend us on Google!
RSS Feed
Twitter
Google Plus
Whats Hot This Week
Generating a Unique Hardware Fingerprint for Software Licensing
Generating a hardware fingerprint is the most commonly sought technique to ensure security in case of softwares. There can be various met...
Zend Framework from Scratch Part II: MVC and Creating Zend Project
In the Part I of the 'Zend from Scratch' series, we installed Zend and configured the environment to create our first Zend pr...
Secure Login Code using PHP and MySQL / Preventing SQL Injection using PHP
Many Web pages accept parameters from web users and generate SQL queries to the database. SQL Injection is a trick to inject SQL script...
Creating a Barcode in PHP
A barcode is an optical machine-readable representation of data relating to the object to which it is attached. Originally barcode...
Forgot Password Functionality in PHP
When you implement a Login functionality, one thing that becomes an obvious inclusion is the 'Forgot Password' functionality. ...
Zend Framework from Scratch Part I: Install and Configure PHP Zend Framework
Zend Framework (ZF) is an open source, object-oriented, full-stack PHP framework created by Zend Technologies implemented in PHP 5 a...
Auto Refresh a Web Page using AJAX
AJAX is nothing but Asynchronous JavaScript and XML. It is not a new programming language, but a new way to use the existing standa...
Live Search / AutoComplete Using XML & PHP
Many a times, we need to build a search engine for our website, which can serve various purposes like searching through your site! In su...
Multi Window and Ripple Lock Screen for Samsung Galaxy S2 GT-i9100 Jelly Bean(4.1.2)
Samsung recently rolled out the JellyBean 4.1.2 update for Galaxy S2. The S2 users, including myself were eagerly awaiting this upgrade, an...
Root Samsung Galaxy S2 GT-i9100 Jelly Bean and install Clockwork Recovery Mod
With the official Jelly Bean update now available for Galaxy SII, one thing that any android fan would be looking for would be 'How t...
Follow on FaceBook
0 comments:
Post a Comment