- 首先我们需要下载EasyX。官网传送门来喽。
- 位于EasyX的头文件<graphics.h>的函数如下。
initgraph(n,m);//设置显示框的大小
setbkcolor(color);//设置背景颜色 settextcolor(color);//设置文字颜色 setfillcolor(color);//设置填充颜色
fillcircle(x,y,r);//在第x列y行画一个半径为r的填充的圆
cleardevice();//清屏
outtextxy(x,y,str);//在第x列y行打印str
- 开始写代码
#include<graphics.h> #include<bits/stdc++.h> #include<conio.h> using namespace std; int main(){ initgraph(600,600); int x=300,y=0,v=5,h=0,r=30,b=0; setbkcolor(WHITE); settextcolor(BLUE); setfillcolor(BLUE); while(1){ cleardevice(); if(y+v>300||y+v<h){ v=-v,h+=10; } if(h>=300){ b=2; setfillcolor(RED); } fillcircle(x,y+=v,r+=b); outtextxy(x-1,y-v,"核弹"); Sleep(10); } _getch(); }
C++ EasyX之坠落的小“核弹”
于 2022-12-21 14:13:44 首次发布