从零开始的c++游戏开发 1.可移动的白球

发布时间:2023年12月26日

使用的绘图库为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;
}

文章来源:https://blog.csdn.net/2301_79431343/article/details/135227911
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。