使用的绘图库为easyx
编译器为visual studio
#include<graphics.h>
#include<iostream>
int main() {
initgraph(1280, 720);
int x = 300,y = 300;
BeginBatchDraw();
while (true) {
ExMessage msg;
while (peekmessage(&msg)) {
if(msg.message == WM_MOUSEMOVE){
x = msg.x;
y = msg.y;
}
}
cleardevice();
solidcircle(x, y, 100);
FlushBatchDraw();
}
EndBatchDraw();
return 0;
}
#include<graphics.h>
//包含easyx中函数的头文件
#include<iostream>
//c++头文件
int main() {
initgraph(1280, 720);
//初始化一个绘图窗口
int x = 300,y = 300;
BeginBatchDraw();
//新建一个渲染缓存区,使得小球不会闪烁
while (true) {
ExMessage msg;
while (peekmessage(&msg)) {
if(msg.message == WM_MOUSEMOVE){
//检测鼠标的移动,并且根据鼠标位置改变x和y的值
x = msg.x;
y = msg.y;
}
}
cleardevice();
//清除掉之前的白球
solidcircle(x, y, 100);
//让白球出现在新的位置
FlushBatchDraw();
//新建一个渲染缓存区,使得小球不会闪烁
}
EndBatchDraw();
//新建一个渲染缓存区,使得小球不会闪烁
return 0;
}