#include "DxLib.h"
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){
if( DxLib_Init() < 0 ) return -1;
int game=0,zibun=-1,aite=0,hantei=0,temp=0;//ゲームの状態・自分・相手・判定・勝敗チェック用の
char* hand[] = {"グー", "チョキ", "パー"};//パクった グー=0 チョキ=1 パー=2
char* win[] = {"勝ちました", "負けました", "あいこでした"};
SRand(GetNowCount()); SetDrawScreen( DX_SCREEN_BACK ) ;
while( ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0 ){
switch(game){
case 0://初期化
aite=GetRand(2); game=1;
break;
case 1://入力待ち
DrawString(0,0,"グー=Z チョキ=X パー=C 選んでからスペースキーでバトル",GetColor(255,255,255)) ;
if(zibun!=-1)DrawFormatString(0,32,GetColor(255,255,255),"現在の選択は「%s」",hand[zibun]) ;
if(CheckHitKey(KEY_INPUT_Z))zibun=0;
if(CheckHitKey(KEY_INPUT_X))zibun=1;
if(CheckHitKey(KEY_INPUT_C))zibun=2;
if(zibun!=-1 && CheckHitKey(KEY_INPUT_SPACE))game=2;
break;
case 2://判定
DrawFormatString(0,0,GetColor(255,255,255),"自分の手は「%s」、相手の手は「%s」",hand[zibun],hand[aite]) ;
if(zibun==aite)hantei=2; else{
temp=zibun;if(temp==2)temp=-1;if((temp+1)==aite)hantei=0;else hantei=1;}
if(zibun!=-1)DrawFormatString(0,32,GetColor(255,255,255),"%s。エンターキーで再戦、ESCで終了",win[hantei]) ;
if(CheckHitKey(KEY_INPUT_RETURN))game=0;
break;
};
ScreenFlip(); ClearDrawScreen();
}
DxLib_End(); return 0;
}