# Include "stdio. h"
# Include "graphics. h"
Int tanke_size = 30, star_size = 30;
Int guan_ka = 1;
/* 1: blue 2: green 3: light blue 4: red 5: fen red 6: zong 7: white 8: light white */
Int tanke_current_x, tanke_current_y;
Int tanke_left = 20, tanke_right = 620, tanke_top = 20, tanke_bottom = 450;
Int fist_star_x, fist_star_y;
Int zidan_current_x =-1, zidan_current_y =-1, zidan_color = 4;
Int mifeng_x [6] [18], mifeng_y [6] [18];
Int mifeng_count = 0;
Void main ()
{
Int I, j, k;
Int first_star_x = 50;
Int first_star_y = 50;
ChuShiHuaGraphics ();
Rectangle (tanke_left-1, tanke_top-1, tanke_right + 1, tanke_bottom );
Tanke_current_x = 290; tanke_current_y = 410;
CreateTanke (tanke_current_x, tanke_current_y );
/* CreateStar (100,100 );*/
For (I = 0; I <6; I ++)
{
For (j = 0; j <18; j ++)
{
CreateStar (first_star_x, first_star_y,-1 );
Mifeng_x [I] [j] = first_star_x;
Mifeng_y [I] [j] = first_star_y;
/* Printf ("(% d, % d)", mifeng_x [I] [j], mifeng_y [I] [j]); */
First_star_x + = star_size;
Mifeng_count ++;
}
First_star_x = 50;
First_star_y + = star_size;
}
/* Printf ("% d", mifeng_count );*/
StartGame ();
Getchar ();
}
CreateStar (int x, int y, int color)
{
Int A_x = x + 15, A_y = y;
Int B _x = x + 2, B _y = y + 10;
Int C_x = x + 7, C_y = y + 30;
Int D_x = x + 22, D_y = y + 30;
Int E_x = x + 28, E_y = y + 10;
Int temp_color;
Temp_color = getcolor ();
If (color =-1)
{
Setcolor (x % 8 = 0? X + 1: x % 8 );
}
Else
{
Setcolor (color );
}
Line (A_x, A_y, C_x, C_y );
Line (A_x, A_y, D_x, D_y );
Line (B _x, B _y, D_x, D_y );
Line (B _x, B _y, E_x, E_y );
Line (C_x, C_y, E_x, E_y );
Setcolor (temp_color );
}
CreateTanke (int x, int y)
{
Int twidth = 4, tem_color;
Tem_color = getcolor ();
If (getcolor ()! = Getbkcolor ())
{
Setcolor (2 );
}
Rectangle (x, y + 10, x + tanke_size, y + tanke_size );
Circle (x + tanke_size/2, y + 10 + tanke_size/2-5, tanke_size/2-7 );
Rectangle (x + tanke_size/2-twidth/2, y, x + tanke_size/2 + twidth/2, y + 10 + tanke_size/2-5-(tanke_size/2-7) -2 + 10 );
Setcolor (tem_color );
/* CreateZidan (5, 5, getbkcolor ());*/
/* CreateZidan (5, 5, 6 );*/
CreateZidan (int x, int y, int color)
{
Int temcolor = getcolor ();
Setcolor (color );
Circle (x + 15, y + 15, tanke_size/2 );
Setcolor (temcolor );
}
StartGame ()
{
Char sign =;
While (1)
{
While (! Kbhit ())
{
AUTO ();
}
Sign = getch ();
Switch (sign)
{
Casea: turn_left (); break;
Cased: turn_right (); break;
Case p: exit (0); break;
}
}
}
Turn_left ()
{
Int x = tanke_curren
T_x, y = tanke_current_y;/* dang qian wei zhi */
Int temcolor;
If (x = tanke_left)
{
Return;
}
Temcolor = getcolor ();
Setcolor (getbkcolor ());
CreateTanke (x, y );
Setcolor (2 );
X = x-tanke_size;
CreateTanke (x, y );
Tanke_current_x = x;
Setcolor (temcolor );
}
Turn_right ()
{
Int x = tanke_current_x, y = tanke_current_y;
Int temcolor;
If (x = tanke_right-tanke_size)
{
Return;
}
Temcolor = getcolor ();
Setcolor (0 );
CreateTanke (x, y );
Setcolor (2 );
X = x + tanke_size;
CreateTanke (x, y );
Tanke_current_x = x;
Setcolor (temcolor );
AUTO ()
{
/* Int delaytime = 1000, tanke_top = 20;
Int temcolor = getcolor ();
Setcolor (0 );
CreateZidan (x, y );
Setcolor (2 );
Y = y-tanke_size;
CreateZidan
(X, y );
Tanke_current_y = y;
Setcolor (temcolor );*/
If (zidan_current_y = tanke_top)
{
CreateZidan (zidan_current_x, zidan_current_y, getbkcolor ());
Zidan_current_x =-1;
}
If (zidan_current_x =-1)
{
CreateZidan (tanke_current_x, tanke_current_y-tanke_size, zidan_color );
Zidan_current_x = tanke_current_x;
Zidan_current_y = tanke_current_y-tanke_size;
Time_delay ();
}
Else
{
CreateZidan (zidan_current_x, zidan_current_y, getbkcolor ());
Zidan_current_y-= tanke_size;
CreateZidan (zidan_current_x, zidan_current_y, zidan_color );
Time_delay ();
}
IfEat ();
}
IfEat ()
{
/* Zidan_current_x, zidan_curren