デバッグエラー
Posted: 2010年12月28日(火) 00:48
開発環境:VisualC++2008
開発言語:C言語
やりたいこと:ジャンケンゲーム
ソース:
#include<stdio.h>
#include<stdlib.h>
#include "DxLib.h"
#include<time.h>
void kekka( int sum1 , int sum2 );
void comp(int num);
void player();
int Key[256];
int Color = GetColor( 255, 255, 255 ); //基本(黒)
int SRand((unsigned)time(NULL));
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
player();
ScreenFlip();
}
DxLib_End();
return 0;
}
void player(){
int num;
DrawString( 0, 0, "グー=Z チョキ=X パー=C", Color );
if( Key[KEY_INPUT_Z] == 1 ){
num = 1;
}
else if( Key[KEY_INPUT_X] == 1 ){
num = 2;
}
else if( Key[KEY_INPUT_C] == 1 ){
num = 3;
}
comp( num );
}
void comp( int num ){
int comprand = GetRand(3);
kekka(num , comprand );
}
void kekka( int sum1 , int sum2 ){
if( sum1 == sum2 ){
DrawString( 0, 0, "引き分けです!", Color );
}
else if( sum1 ==1 && sum2 == 1 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else if( sum1 == 2 && sum2 == 2 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else if( sum1 == 3 && sum2 == 0 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else
DrawString( 0, 0, "コンピュータの勝利!", Color );
}
こんにちは。じゃんけんゲームを作って、実行してみたら、デバッグエラーが出てしまいました。
何が原因なのでしょうか?
処理の順番(?)は
グーかパーかチョキかを選ばして、乱数でコンピューターの手を選ばして、プレイヤーとコンピューターの手同士を判定して結果を出すって感じです。
開発言語:C言語
やりたいこと:ジャンケンゲーム
ソース:
#include<stdio.h>
#include<stdlib.h>
#include "DxLib.h"
#include<time.h>
void kekka( int sum1 , int sum2 );
void comp(int num);
void player();
int Key[256];
int Color = GetColor( 255, 255, 255 ); //基本(黒)
int SRand((unsigned)time(NULL));
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
player();
ScreenFlip();
}
DxLib_End();
return 0;
}
void player(){
int num;
DrawString( 0, 0, "グー=Z チョキ=X パー=C", Color );
if( Key[KEY_INPUT_Z] == 1 ){
num = 1;
}
else if( Key[KEY_INPUT_X] == 1 ){
num = 2;
}
else if( Key[KEY_INPUT_C] == 1 ){
num = 3;
}
comp( num );
}
void comp( int num ){
int comprand = GetRand(3);
kekka(num , comprand );
}
void kekka( int sum1 , int sum2 ){
if( sum1 == sum2 ){
DrawString( 0, 0, "引き分けです!", Color );
}
else if( sum1 ==1 && sum2 == 1 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else if( sum1 == 2 && sum2 == 2 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else if( sum1 == 3 && sum2 == 0 ){
DrawString( 0, 0, "プレイヤーの勝利!", Color );
}
else
DrawString( 0, 0, "コンピュータの勝利!", Color );
}
こんにちは。じゃんけんゲームを作って、実行してみたら、デバッグエラーが出てしまいました。
何が原因なのでしょうか?
処理の順番(?)は
グーかパーかチョキかを選ばして、乱数でコンピューターの手を選ばして、プレイヤーとコンピューターの手同士を判定して結果を出すって感じです。