我正在做一個簡單的遊戲,並嘗試從遊戲開始後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