SDL_FillRect
というのを使ってます。引数にMain.cppのソース#ifndef __DEF_H__ #define __DEF_H__ #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "InitEventEnd.h" //ここにすべてのヘッダーファイルを書いておくと便利。 #include "Draw.h" #include "Input.h" #include "Game.h" #pragma comment(lib, "SDL.lib") #pragma comment(lib, "SDLmain.lib") #pragma comment(lib, "SDL_image.lib") #ifdef __MAIN_CPP__ SDL_Surface *screen; //Main.cppなら普通に宣言 #else extern SDL_Surface *screen; //それ以外は、外部宣言 #endif #endif
#define __MAIN_CPP__ #include "Def.h" int main(int argc, char* argv[]) { if(!Init()) //初期化&確認 { printf("初期化に失敗しました"); return 0; } GameInit(); //ゲーム初期へ while(1) //メインループ { SDL_Rect dest; dest.x = 0;dest.y = 0; dest.w = 640;dest.h = 480; Uint32 color= 0x00000000; SDL_FillRect( screen, &dest, color ); //画面をcolorの色で塗りつぶす関数。 GameMain(); //ゲームのメインへ SDL_Flip(screen); if(!Event()) break; //イベント確認 SDL_Delay(30); //休憩。(アニメの動作が遅ければ、ここの数字を減らす) } SDL_FreeSurface(screen); //SDL_Surface型変数の中身を消去する。 //GameEnd(); //ゲーム終了へ End(); //終了処理へ return 0; }
GameMain.cppのソースvoid GameMain(void); //ゲームの処理
#include "Def.h" void GameMain() { MoveChara(); //現段階では自機の移動のみ。 }