BCCでSDL 矩形描画 解答例
前回紹介した矩形を描くプログラムです。
適当にソースに追加してコンパイルして確認してください。
なお、rectEffect2に関しては、関数内の塗り潰す処理でアプリケーションのタスクを独占してしまっているので、main()のループ内でこの関数を呼び出すときは関数呼び出しの後、プログラム自体終了させたほうが良いでしょう。
void rectEffect(Uint8 size){ static Uint16 x = 0; static Uint16 y = 0; SDL_Rect dst = { x, y, size, size}; SDL_FillRect( screen, &dst, ~rand()*2 ); if( (x+=size) > WIDTH-size ){ x=0; if( (y+=size) > HEIGHT ){ x=y=0; PaintingOut(0x00000000); } } } void rectEffect2(Uint8 size){ SDL_Rect dst = { 0, 0, size, size }; int color = 0x00000000; PaintingOut(0x0022AAed); for(Uint16 y=0; y <= HEIGHT; y+=size){ for(Uint16 x=0; x <= WIDTH-size; x+=size){ dst.x = x; dst.y = y; SDL_FillRect( screen, &dst, color+=0x00010101); ScreenUpdate(); } } PaintingOut(0x0); } |