トップページ > 過去ログ > 記事閲覧
キーパーについて
名前:messi 日時: 2010/09/21 17:02

ゴールの中心にキーパーが立っていて、左にボールが来たときには左側にキャッチする画像を、右ボールがに来たときには右側にキャッチする画像を表示させたいのですがIF文でどの様にプログラムを組めばいいのでしょうか?

Page: 1 |

Re: キーパーについて ( No.1 )
名前:いっち 日時:2010/09/21 19:33

実装に左右されますが、大体以下のような感じではないでしょうか。 マウスの左クリックをすると左右を判定し、右クリックでリセットします。 //- 以下、テストコード -// #include "DxLib.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { ChangeWindowMode( TRUE ); if ( DxLib_Init( ) == -1 ) return -1; SetMouseDispFlag( TRUE ); SetDrawScreen( DX_SCREEN_BACK ); int StrColor = GetColor( 255, 255, 255 ); int state = 0, x, y; while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 ) { if ( GetMouseInput( ) & MOUSE_INPUT_LEFT ) { GetMousePoint( &x, &y ); if ( x < 640 / 2 ) state = 1; else state = 2; } if ( GetMouseInput( ) & MOUSE_INPUT_RIGHT ) { state = 0; } ClearDrawScreen( ); DrawFormatString( 0, 0, StrColor, "TEST" ); if ( state == 1 ) DrawString( 312, 240, "左", StrColor ); else if ( state == 2 ) DrawString( 312, 240, "右", StrColor ); else DrawString( 312, 240, "待", StrColor ); ScreenFlip( ); } DxLib_End( ); return 0; }
Re: キーパーについて ( No.2 )
名前:messi 日時:2010/09/22 15:35

ありがとうございます! 早速試してみたいと思います。

Page: 1 |