実行すると、初期化したはずのarray配列に変な値が代入されています。
あと、入力にも問題があります。
二つとも、悩みに悩んで解決できませんでした。
どうか、ソースコードにどのような問題があるのかご指導お願いします。
ソースコードは以下です。
#include "DxLib.h" extern int array[15][15]; extern int i,j,turn,stone; int clear(void); int screen_cl(void); int screen_st(void); int input(int); //////////////////////////////////////////////////////// char Key[256]; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ if( ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() == -1 ) return -1; //初期化処理 SetDrawScreen( DX_SCREEN_BACK ); //裏画面に設定 while(!ProcessMessage() && !ClearDrawScreen() && !GetHitKeyStateAll( Key ) && !Key[KEY_INPUT_ESCAPE]){ //↑メッセージ処理 ↑画面をクリア ↑キーボード入力状態取得 ↑ESCが押されていない //////////////////////////////////////////////////////// int turn; clear(); screen_cl(); screen_st(); ScreenFlip(); // メインループ // for (turn = 0;turn<100;turn++) { screen_st(); if (turn == 0) { } input(turn); ScreenFlip(); } } DxLib_End(); return 0; } int clear(void) { int array[15][15]; int i,j; /*初期化*/ for (i=0;i<15;i++) { for (j=0;j<15;j++) { array[j] = 0; } } return 0; } int screen_cl(void) { int k; int i,j; int white = GetColor( 255,255,255 ); int black = GetColor( 0,0,0 ); //碁盤の枠 DrawBox(80,0,559,479,white,TRUE); for (i=0;i<15;i++) { if (i==0 || i==14) { DrawBox( 108 , 30*i+28 , 532 , 30*i+32 , black , TRUE ); } else { DrawBox( 109 , 30*i+29 , 531 , 30*i+31 , black , TRUE ); } } for (j=0;j<15;j++) { if (j==0 || j==14) { DrawBox( 30*j+108 , 28 , 30*j+112 , 452 , black , TRUE ); } else { DrawBox( 30*j+109 , 29 , 30*j+111 , 451 , black , TRUE ); } } int guid[5][2] = { {199,120}, {439,120}, {319,240}, {199,360}, {439,360} }; for (k=0;k<5;k++) { DrawCircle( guid[k][0] , guid[k][1] , 5 , black , TRUE ); } return 0; } int screen_st(void) { //碁石 int m,n; int i,j; int array[15][15]; int white = GetColor( 255,255,255 ); int black = GetColor( 0,0,0 ); for (i=0;i<15;i++) { for (j=0;j<15;j++) { m = 30*i+29; n = 30*j+109; if (array[j] == 1) { DrawCircle( n , m , 10 , black , TRUE ); } else if (array[j] == 2) { DrawCircle( n , m , 10 , black , TRUE ); DrawCircle( n , m , 8 , white , TRUE ); } } } return 0; } int input(int turn) { int i,j,stone; int array[15][15]; int MouseX,MouseY,MouseInput; int x,y,hasi_x,hasi_y; if (turn%2 == 0) { stone = 1; } else { stone = 2; } // マウスを表示状態にする SetMouseDispFlag( TRUE ) ; // マウスの入力を待つ MouseInput = GetMouseInput() ; do { while( ( MouseInput & MOUSE_INPUT_LEFT ) == 0 ) { // メッセージ処理 if( ProcessMessage() == -1 ) { break ; // エラーが起きたらループから抜ける } // マウスの入力を得る MouseInput = GetMouseInput() ; } while( ( MouseInput & MOUSE_INPUT_LEFT ) == 1 ) { // メッセージ処理 if( ProcessMessage() == -1 ) { break ; // エラーが起きたらループから抜ける } // マウスの入力を得る MouseInput = GetMouseInput() ; // マウスの位置を取得 GetMousePoint( &MouseX , &MouseY ) ; } } while ( ( (MouseX < 85) || (MouseX > 555) ) && ( (MouseY < 5) || (MouseY > 475) ) ); //判定部分 hasi_x = 94; hasi_y = 14; x = MouseX - hasi_x; y = MouseY - hasi_y; for (i=0;i<15;i++) { for (j=0;j<15;j++) { if ( (y >= i*30) && (y < i*30+30) && (x >= j*30) && (x < j*30+30) ) { array[j] = stone; } } } return 0; }
相変わらず覚束ない日本語ですみません。><