#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#include<easyx.h>
#include<graphics.h>
#include<math.h>
struct zd
{
int x;
int y;
bool zzaa;
};
void plane(MOUSEMSG m,POINT *plane)
{
clearpolygon(plane, 3);
plane[0] = { m.x ,m.y - 10 };
plane[1] = { m.x + 30,m.y + 5 };
plane[2] = { m.x - 30,m.y + 5 };
solidpolygon(plane, 3);
}
void ks(struct zd*mmm,MOUSEMSG m)
{
mmm->x = m.x;
mmm->y = m.y;
mmm->zzaa = true;
}
void zzd(struct zd* mmm)
{
clearcircle(mmm->x, mmm->y, 7);
mmm->y--;
if(mmm->y)
solidcircle(mmm->x, mmm->y, 7);
}
struct dj
{
int x;
int y;
bool sur;
int js;
};
void dr(struct dj *aad,int mx)
{
aad->sur = true;
aad->x = mx;
aad->y = 0;
}
void djbf(struct dj* aa)
{
clearcircle(aa->x, aa->y, 30);
aa->js++;
if (aa->js == 10)
{
aa->y++;
aa->js = 0;
}
if(aa->y<499)
solidcircle(aa->x, aa->y, 30);
}
void pd(struct dj* abc, struct zd* mmm)
{
for(int i=0;i<4;i++)
for(int j=0;j<20;j++)
if (abc[j].sur && mmm[i].zzaa && ((double)sqrt((abc[j].x - mmm[i].x) * (abc[j].x - mmm[i].x) + (abc[j].y - mmm[i].y) * (abc[j].y - mmm[i].y)) < 30))
{
abc[j].sur = false;
mmm[i].zzaa = false;
clearcircle(abc[j].x, abc[j].y, 30);
clearcircle(mmm[i].x, mmm[i].y, 7);
}
}
void game()
{
POINT planes[3];
MOUSEMSG m;
initgraph(1000, 500);
struct zd mmm[4] = {0};
int count = 0;
UINT ssss;
int in = 0;
int i = 0;
m = GetMouseMsg();
struct dj abc[20] = {0};
for (int fff = 0; fff < 20; fff++)
abc[fff].sur = false;
int cou = 0;
int mx = 0;
int st = 0;
srand((unsigned)time(NULL));
for (int fasaf = 0; fasaf < 4; fasaf++)
mmm[fasaf].zzaa = false;
while (114514)
{
if (MouseHit())
{
m = GetMouseMsg();int
ssss = m.uMsg;
if (ssss==WM_LBUTTONDOWN)
{
if (count < 4)
count++;
else
count = 0;
ks(&mmm[count], m);
}
}
cou++;
if (cou == 500000)
{
dr(&abc[st], rand()%1000);
abc[st].js = 0;
cou = 0;
} plane(m, planes);
if (st == 20)
st = 0;
st++;
in++;
if(in==100)
{
for (i = 0; i < 4; i++)
{
if (mmm[i].y&&mmm[i].zzaa)
zzd(&mmm[i]);
}
for (i = 0; i < 20; i++)
{
if (abc[i].y == 500)
abc[i].sur = false;
if (abc[i].sur)
{
djbf(&abc[i]);
}
}
in = 0;
}
pd(abc, mmm);
}
}
void menu()
{
printf("*****************1.play 飞机大战!!!!!!\n");
printf("*****************0.exit 飞机大战############\n");
}
int main()
{
MOUSEMSG m;
int input = 0;
do
{
menu();
scanf("%d", &input);
switch(input)
{
case 1:
game();
case 0:
break;
}
} while (input);
return 0;
}
飞机大战(easyx绘图)
最新推荐文章于 2023-08-28 22:08:23 发布