课程太简单?!!大一新生在上课期间自学C++敲出打地鼠游戏!!!

252 阅读1分钟

VC++棒子打老鼠游戏源代码,俗称打地鼠,程序可以编译,但运行时候棒子的显示有些问题,也就是程序在处理BMP图像时候有些不完善,不过整体可以玩,相信大家都知道这款游戏 ,现在发布源代码供研究。

![](https://upload-images.jianshu.io/upload_images/24762785-7d8a2a5e56217aec.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

项目截图:

![](https://upload-images.jianshu.io/upload_images/24762785-dda98b1cbb195605.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

动图

![](https://upload-images.jianshu.io/upload_images/24762785-1a8b2ffe3ad944f9.gif?imageMogr2/auto-orient/strip)

代码展示:

![](https://upload-images.jianshu.io/upload_images/24762785-50511ec7d81812c4.gif?imageMogr2/auto-orient/strip)

这个游戏纯属土鳖思路,没有用到什么游戏引擎。

1.使用按钮或QLabel铺满窗口。

2.通过简单算法随机动态的设置按钮矩阵中某个按钮的背景图像。

3.同步2过程反复设置多个按钮背景实现图像动起来,注意调节刷新时间。

4.重写按钮组鼠标事件,设置鼠标移入时光标的图案,可以是个小锤子。

5.单击事件后鼠标同理切换鼠标图案打下和抬起。

6.加入一点声音。

7.没有了。

![](https://upload-images.jianshu.io/upload_images/24762785-4edee29721c97709.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

最后,如果你想了解更多,请点击了解更多资料,更有免费开源项目和课程等你观看哦!

![](https://upload-images.jianshu.io/upload_images/24762785-75657287227d8439.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/24762785-d1edc1769228334f.gif?imageMogr2/auto-orient/strip)