長さの固定されたHPゲージの作り方
Posted: 2015年9月12日(土) 17:19
#include "DxLib.h"
void DrawHP(int hp, int hpMax){
int color = GetColor(255,255,255);
DrawBox(100,100,100+200,100+20,color,FALSE); //枠を描画
DrawBox(100,100,100+200*hp/hpMax,100+20,color,TRUE); //HPゲージを描画
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定
int hp=0, hpMax=180;
while(!ScreenFlip()&&!ProcessMessage()&&!ClearDrawScreen()){
DrawHP(hp,hpMax);
hp++;
if(hp>=hpMax){
hp=0;
}
}
DxLib_End(); // DXライブラリ終了処理
return 0;
}