zoukankan      html  css  js  c++  java
  • 火箭发射

    #include <graphics.h>
    #include <conio.h>
    #include <stdlib.h>
    #define START_X  100
    #define START_Y  400
    void draw(int x, int y)         /*自定义函数draw画出火箭外形*/
    {
        setcolor(14);
        setfillstyle(1, 15);
        rectangle(x, y, x + 30, y + 60);
        floodfill(x + 10, y + 10, 14);
        setfillstyle(1, RED);
        line(x + 15, y - 15, x, y);
        line(x + 15, y - 15, x + 30, y);
        floodfill(x + 15, y - 5, 14);
        setfillstyle(2, RED);
        line(x - 20, y + 80, x, y + 60);
        line(x + 50, y + 80, x + 30, y + 60);
        line(x - 20, y + 80, x + 50, y + 80);
        floodfill(x + 10, y + 70, 14);
        line(x, y + 90, x - 10, y + 100);
        setcolor(RED);
        line(x + 10, y + 90, x, y + 100);
        line(x + 20, y + 90, x + 30, y + 100);
        setcolor(14);
        line(x + 30, y + 90, x + 40, y + 100);
    }

    void play()         /*自定义火箭发射函数*/
    {
        int x, y;
        int s = 4;
        for (x = START_X, y = START_Y; y >= 15; y -= s)
        {
            cleardevice();       /*清屏*/
            draw(x, y);       /*画火箭*/
            delay(1e20);       /*延迟时间*/
        }
        outtextxy(200, 100, "The demo is over !");   /*在屏幕指定位置输出字符串*/
    }

    main()
    {
        char ch;
        int x = START_X, y = START_Y;
        int gdriver = DETECT;
        int gmode;
        initgraph(&gdriver, &gmode, "");    /*图形方式初始化*/
        setbkcolor(BLACK);      /*设置背景颜色为黑色*/
        cleardevice();       /*清屏*/
        setcolor(WHITE);       /*设置绘图颜色为白色*/
        settextstyle(TRIPLEX_FONT, 0, 2);    /*设置输出的文本形式*/
        outtextxy(200, 100, "Press any key to begin!");  /*在指定位置输出字符串*/
        draw(x, y);        /*调用画火箭函数*/
        getch();
        play();         /*调用自定义的play()函数*/
        getch();
        closegraph();       /*退出图形状态*/
    }

  • 相关阅读:
    zabbix
    Tomcat 部署Web应用
    WebLogic
    WebLogic部署集群和代理服务器
    WebLogic 中的基本概念
    GIT详解和GITHUB
    Tomcat 内存溢出对应解决方式
    apache和tomcat区别
    数据库介绍
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/1960127.html
Copyright © 2011-2022 走看看