Birthday gift (to be modified)

Source: Internet
Author: User

Turbo C 2.0 is an excellent C language programming tool in the DOS era, but the majority of users are currently using Windows operating systems. If you want to call a graphic animation program written in C language in windows. there may be many errors that cannot be displayed in graphic animation. This is because the image processing function of C cannot be accurately located on the Windows interface. Therefore, when using the initgraph () function in Turbo C for graph initialization, you must complete the following steps: (assume that Turbo C 2.0 is installed in the C:/TC directory)

① Enter the command in the C:/TC subdirectory:

Bgiobj egavga. BGI

This command converts the driver egavga. BGI to the target file of egavga. obj.
Because the corresponding driver (*. BGI) is not loaded into the execution program at compilation and linking time.

② Add the OBJ file created above to the graphics. Lib library file. The specific method is as follows.
Run the following command in the C:/TC subdirectory:

Tlib C:/TC/lib/graphics. Lib + egavga

 

/* Birthday gift */

 

# Include <stdio. h>
# Include <stdlib. h>
# Include <math. h>
# Include <graphics. h>
# Define PI 3.1415926

Void Star (int x, int y)/* star function */
{
Int I,;
Int n = 5;
Int X1 [5], Y1 [5], X2 [5], Y2 [5];
Setcolor (yellow );
For (I = 0; I <5; I ++)
{
X1 [I] = x + N * Cos (I * 72 * PI/180 );
Y1 [I] = Y + N * sin (I * 72 * PI/180 );
X2 [I] = x + n/2 * Cos (I * 72 * PI/180 + PI/5 );
Y2 [I] = Y + n/2 * sin (I * 72 * PI/180 + PI/5 );
}
For (I = 0; I <5; I ++)
{
A = I + 1;
If (A> 4) A = 0;
Line (x1 [I], Y1 [I], X2 [I], Y2 [I]);/* draw a straight line between two points */
Line (X2 [I], Y2 [I], X1 [a], Y1 [a]);
}
}

Void putstar ()/* function for painting stars */
{
Integer seed = 1858;
Int I, dotx, doty, H, W, color, maxcolor;
Maxcolor = getmaxcolor ();
W = getmaxx ();
H = getmaxy ();
Srand (SEED );
For (I = 0; I <100; I ++)
{
Dotx = I + random (W-1 );
Doty = I + random (h-1 );
Color = random (maxcolor );
Setcolor (color );
Putpixel (dotx, doty, color );
Circle (dotx + 1, doty + 1, 1 );
}
Srand (SEED );
}

Void drawstar ()/* put stars and stars in the sky */
{
Int A [] = {70,280,230,440,140,110,180, 90,500,360 };
Int B [] = {50, 27, 88, 99,100, 37, 67, 98,60, 78 };
Int I;
Setfillstyle (1, 14 );
For (I = 0; I <10; I ++)
{
Star (A [I], B [I]);
Floodfill (A [I], B [I], yellow );
}
Putstar ();
}

Void startflower ()/* function of fireworks */
{
Int I = 0, J;
Int n = 60, n1 = 2;
Int x = 200, y = 200, size = 100;
Int cover = 0;
Int delay1 = 5000;
Int WID, Hei;
Int PX, Py;
Int color = 9;
While (! Kbhit ())
{
If (I <size)
{
For (j = 0; j <n; j ++)
{
Px = x + I * Cos (J * 360/N * PI/180 );
Py = Y + I * sin (J * 360/N * PI/180 );
Putpixel (PX, Py, Rand () % 16 );
Putpixel (PX-1, Py, color );
Putpixel (PX, Py + 1, color );
Putpixel (PX + 1, Py-1, yellow );
Putpixel (PX, Py-1, yellow );
Putpixel (PX + 1, Py, red );
Putpixel (PX + 1, Py + 1, red );
}
}

If (I> size & cover <size)
{
Setcolor (black );
Circle (X, Y, cover ++ );
Delay1 = 1000;
}

If (cover = size)
{
I = 0;
X = 50 + rand () % 550;
Y = rand () % 400;
Cover = 0;
Color = rand () % 16;
Size = 50 + rand () % 250;
Delay1 = 10000;
Clearviewport ();
Drawstar ();

}

I + = N1;
Delay (delay1 );
}
}

Void main ()
{
Int I, J, K;
Int gdriver = detect, gmode;
Registerbgidriver (egavga_driver );
Initgraph (& gdriver, & gmode ,"");
Drawstar ();

Startflower ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.