嗨,我是Beluga,今天,我为大家带来代买:C++豌豆射手
代码如下
#include
#include
#include
using namespace std;
class p2 {
public:
int size_x;
int size_y;
int init_x;
int init_y;
void _p2(int x1, int y1, int x2, int y2) {
size_x = x1;
size_y = y1;
init_x = x2;
init_y = y2;
}
};
class p3 {
public:
int size_x;
int size_y;
int init_x;
int init_y;
void _p3(int x1, int y1, int x2, int y2) {
size_x = x1;
size_y = y1;
init_x = x2;
init_y = y2;
}
};
int main()
{
p2 ptwo;
p3 pthree;
ptwo._p2(200, 200, 200, 200);
pthree._p3(50, 50, 400, 250);
IMAGE p2, p3;
loadimage(&p2, "p2.png", ptwo.size_x, ptwo.size_y);
loadimage(&p3, "p3.png", pthree.size_x, pthree.size_y);
initgraph(800, 600);
putimage(ptwo.init_x, ptwo.init_y, &p2);
putimage(pthree.init_x, pthree.init_y, &p3);
BeginBatchDraw();//开始批量绘制
while (1)
{
cleardevice();
putimage(ptwo.init_x, ptwo.init_y, &p2);
pthree.init_x += 1;
if (pthree.init_x == 750)
pthree.init_x = 400;
putimage(pthree.init_x, pthree.init_y, &p3);
Sleep(10);
FlushBatchDraw();//批量绘制
}
_getch();
closegraph();
return 0;
}
好了,别忘了点赞,关注,收藏
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)