飞机大战(easyx绘图)

#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;
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值