我正在做一个简单的游戏,并尝试从游戏开始后5秒内产生char spawn。这是我的代码的一部分,我不确定是否必须使用time.h或循环函数或其他东西。任何人都可以给我一些建议吗?谢谢经过一段时间后产卵C
char * image =
/**/ "H H"
/**/ "H H"
/**/ "HHHHH"
/**/ "H H"
/**/ "H H";
#define HERO_WIDTH (5)
#define HERO_HEIGHT (5)
void setup_hero(void) {
// Set up the hero at the centre of the screen.
int hero_x = (screen_width() - HERO_WIDTH)/2;
int hero_y = (screen_height() - HERO_HEIGHT)/2;
hero = sprite_create(hero_x, hero_y, HERO_WIDTH, HERO_HEIGHT, image);
wait(5); // not working
sprite_draw(image);
show_screen();
}
的系统调用是暂停x秒通常被称为'sleep',不'wait'。 – PSkocik
因此,当游戏仍在运行时,睡眠功能会如何工作,就像您玩炭时产生的一样? – lufee
你应该从你的编译器得到警告。无论是“wait”还是未声明,或者它都不需要“int”。如果你没有得到它们,调整你的构建系统。 – PSkocik