画面のちらつきをなくしたい
Posted: 2012年1月06日(金) 17:34
#include "DxLib.h"
//*******************************
//画像のロード
//*******************************
int grf[9];
void g_load()
{
grf[0]=LoadGraph("フェイス.png");
grf[1]=LoadGraph("図書館.png");
}
//**********************************
//メインループ
//**********************************
int WINAPI WinMain( HINSTANCE , HINSTANCE,LPSTR , int )
{
ChangeWindowMode(TRUE),SetWindowSize(1000,600),DxLib_Init(),SetDrawScreen(DX_SCREEN_BACK); //ウィンドウモード変更、初期化、裏画面設定
g_load();
int a, b, c, ans;
int my=30, teki=50;
int white = GetColor(255,255,255);
while( (my>0) && (teki>0) && ProcessMessage()==0&& ClearDrawScreen()==0
&& ScreenFlip()==0 && CheckHitKey(KEY_INPUT_ESCAPE)==0){
DrawGraph(0,0,grf[1],TRUE);
DrawGraph(0,0,grf[0],TRUE);
a = GetRand(10);
b = GetRand(10);
c = a + b;
if(c>10){ //10以上は表示しないようにする
continue;
}
DrawFormatString(515,20,white,"[yusya_hp:%d]", my); //自分のHP表示座標
DrawFormatString(35,20,white,"[teki_hp:%d] ",teki); //敵のHP表示座標
DrawString(170,10," teki:「このもんだいをといてみろ」",white); //言葉の表示座標
DrawFormatString(300,40,white,"%d+%d=",a,b); //問題の表示座標
ans = KeyInputNumber( 350,40, 10, 0 , FALSE ) ;
if(c==ans){
teki=teki-ans;
my=my+ans;
}
if(c!=ans){
my=my-c;
}
if( teki<=0) {
break;
}
if(my<=0){
break;
}
}
DxLib_End();
return 0;
}