Game Boy Color >> C/C++
Delay
參考資訊:
1. bgb
2. doc
3. gbdk_playground
Delay設定
void delay(UWORD ms);
第一個參數是延遲時間,ms為單位
main.c
#include <gb/gb.h> #include <gb/cgb.h> unsigned char sprite[] = { 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, }; unsigned short palette[] = {0, RGB_RED, RGB_GREEN, RGB_BLUE}; void main(void) { SPRITES_8x8; set_sprite_data(0, 2, sprite); set_sprite_palette(0, 1, palette); move_sprite(0, 50, 50); SHOW_SPRITES; while (1) { set_sprite_tile(0, 0); delay(1000); set_sprite_tile(0, 1); delay(1000); } }
完成