游戏中的背景移动
easyx吧
全部回复
仅看楼主
level 7
白芦花 楼主
#include <stdio.h>
# include <graphics.h>
#include<vector>
#define ScreenWidth 800
#define ScreenHight 600
int main(int argc, char *argv[])
{
initgraph(ScreenWidth, ScreenHight, 1);
IMAGE m;
loadimage(&m, "花纹.png");
int t0 = GetTickCount();
int y0 = -401;
BeginBatchDraw();
do {
cleardevice();
//背景移动
for (int y = y0; y < ScreenHight + 198; y += 198) {
for (int x = 0; x < ScreenWidth; x += 336) {
putimage(x, y, &m);//图像大小:336,198
}
}
//控制滚动速度
int time = GetTickCount() - t0;
if (time > 100) {
t0 = GetTickCount();
y0++; if (y0 >= 0)y0 = -398;
}
FlushBatchDraw();
} while (1);
return 0;
}
2025年01月24日 01点01分 1
level 4
艾不是你把我当傻子呢
2025年01月24日 02点01分 2
不能运行吗?
2025年01月24日 03点01分
没懂,你得具体说你遇到了什么问题呀
2025年11月01日 08点11分
1