https://blog.csdn.net/thefutureisour/article/details/7576712
这份代码在我的本地编译的时候出现了错误:
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x79): undefined reference to `__imp_GetStockObject'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x2a8): undefined reference to `__imp_Rectangle'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x2cc): undefined reference to `__imp_MoveToEx'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x2ee): undefined reference to `__imp_LineTo'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x315): undefined reference to `__imp_MoveToEx'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x334): undefined reference to `__imp_LineTo'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x3a7): undefined reference to `__imp_Ellipse'
C:\Users\msn\AppData\Local\Temp\ccXLLaev.o:3.cpp:(.text+0x450): undefined reference to `__imp_RoundRect'
collect2.exe: error: ld returned 1 exit status
请问如何解决?
g++加编译参数 -lgdi32
在开始代码工程之前,我们应当明确,我们是要做一个什么类型的游戏。接着,使用面向对象的思想,构思一下这个游戏,有哪些类,有哪些接口,怎么定义继承关系,来尽可能地减少工程复杂度,使要做的游戏更加清晰。最好是写设计文档,将游戏的雏形描绘在设计上,切忌一上来便新建文件夹。马克思说:“最蹩脚的建筑师从一开始就比最灵巧的蜜蜂高明的地方,是他在用蜂蜡建筑蜂房之前已经在自己头脑中把它建成了。”(当然,该系列博客中适当略去了前期工作,重点是如何用代码真正实现,做一个完完整整的游戏)
例如,在这里我想实现的是一个类似魔塔的 2D RPG 游戏,希望做出一部 2D RPG 的知名手游《明日方舟》的同人单机游戏。与魔塔不同的是,我希望能够在游戏中增加一些 Rougelike 元素,提高游戏的可玩性。至于具体设计嘛,设计文档中有一些描述,这里当然略过啦!
那么,让我们上手开发出一个属于自己的 Windows 游戏吧!