処理が重くなっていく
Posted: 2009年8月31日(月) 10:23
オプション画面で選択した画像を何回か選んでいるとどんどん動きが重くなるのはどうしてでしょうか?
あと矢印キーとZで選択したいのですがどうすればいいのでしょうか?
作成したプログラムをんのせます。
#include "DxLib.h"
int function_status=0,White;
char KeyBuf[ 256 ] ;
void Menu();
void Games();
void Option();
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode( TRUE ) ; //ウィンドウモードに変更
SetWindowText("Defend the fish!!");
SetGraphMode( 800 , 600 , 32 ) ;
if( DxLib_Init() == -1 ) return -1; // DXライブラリ初期化処理 エラーが起きたら終了
White = GetColor( 255 , 255 , 255 ) ; //色の取得
SetDrawScreen( DX_SCREEN_BACK ) ; // 描画先を裏画面に設定
while( 1 ){
ClearDrawScreen(); // 裏画面のデータを全て削除
GetHitKeyStateAll( KeyBuf ) ; // すべてのキーの状態を得る
switch(function_status){
case 0:
Menu();
break;
case 1:
Games();
break;
case 2:
Option();
break;
case 3:
Menu();
break;
case 4:
Option();
LoadGraphScreen( 410 , 50 , "EN1.bmp" , TRUE ) ;
break;
case 5:
Option();
LoadGraphScreen( 410 , 50 , "EN2.bmp" , TRUE ) ;
break;
case 6:
Option();
LoadGraphScreen( 410 , 50 , "EN3.bmp" , TRUE ) ;
break;
case 7:
Option();
LoadGraphScreen( 410 , 50 , "EN4.bmp" , TRUE ) ;
break;
default:
DxLib_End() ; // DXライブラリ使用の終了処理
return 0;
break;
}
if( ProcessMessage() == -1 ) break ; //エラーが起きたら終
ScreenFlip() ; // 裏画面データを表画面へ反映
}
DxLib_End();
return 0;
}
void Menu(){
int image; //ハンドルを受け取るためのint型変数を宣言
image = LoadGraph( "back1.bmp" ) ; //back1.bmpのハンドルを代入
DrawGraph( 0 , 0 , image , FALSE ) ; //画像を表示
SetFontSize( 50 ) ; //サイズを30に変更
SetFontThickness( 10 ) ; //太さを8に変更
ChangeFont( "MS 明朝" ) ; //種類をMS明朝に変更
ChangeFontType( DX_FONTTYPE_ANTIALIASING ); //アンチエイリアスフォントに変更
DrawString(200,200,"Defend the fish!!",GetColor(0,0,0));
SetFontSize( 20 ) ;
DrawString(320,310,"スタート(S)",GetColor(0,0,0));
if(KeyBuf[KEY_INPUT_S]==1)
function_status=1;
DrawString(320,360,"オプション(O)",GetColor(0,0,0)); //サイズを20に変更
if(KeyBuf[KEY_INPUT_O]==1)
function_status=2;
DrawString(320,410,"終了(E)",GetColor(0,0,0));
if(KeyBuf[KEY_INPUT_E]==1)
function_status=8;
}
void Games(){
if(KeyBuf[KEY_INPUT_[/url]==1)
function_status=3;
}
void Option(){
int White,Red,G_Blue;
int image; //ハンドルを受け取るためのint型変数を宣言
image = LoadGraph( "back1.bmp" ) ; //back2.bmpのハンドルを代入
DrawGraph( 0 , 0 , image , FALSE ) ; //画像を表示
White = GetColor( 0 , 0 , 0 ) ; // 白色の値を取得
Red = GetColor( 255 , 0 , 0 ) ; // 赤色の値を取得
G_Blue = GetColor( 0 , 255 , 255 ) ; // 緑と青の混合色の値を取得
DrawBox ( 720 , 50 , 410 , 400 , White , FALSE) ; // 四角形を描画(左上x座標,左上y座標,右下x座標,右下y座標)
DrawBox ( 30 , 50 , 400 , 200 , White , FALSE) ; // 四角形を描画(左上x座標,左上y座標,右下x座標,右下y座標)
DrawString(60,60,"カスタム1(キー1)",White);
if(KeyBuf[KEY_INPUT_1]==1)
function_status=4;
DrawString(60,90,"カスタム2(キー2)",White);
if(KeyBuf[KEY_INPUT_2]==1)
function_status=5;
DrawString(60,120,"カスタム3(キー3)",White);
if(KeyBuf[KEY_INPUT_3]==1)
function_status=6;
DrawString(60,150,"カスタム4(キー4)",White);
if(KeyBuf[KEY_INPUT_4]==1)
function_status=7;
DrawString(160,250,"変更",White);
DrawString(660,560,"もどる(R)",White);
if(KeyBuf[KEY_INPUT_[/url]==1)
function_status=3;
}
あと矢印キーとZで選択したいのですがどうすればいいのでしょうか?
作成したプログラムをんのせます。
#include "DxLib.h"
int function_status=0,White;
char KeyBuf[ 256 ] ;
void Menu();
void Games();
void Option();
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode( TRUE ) ; //ウィンドウモードに変更
SetWindowText("Defend the fish!!");
SetGraphMode( 800 , 600 , 32 ) ;
if( DxLib_Init() == -1 ) return -1; // DXライブラリ初期化処理 エラーが起きたら終了
White = GetColor( 255 , 255 , 255 ) ; //色の取得
SetDrawScreen( DX_SCREEN_BACK ) ; // 描画先を裏画面に設定
while( 1 ){
ClearDrawScreen(); // 裏画面のデータを全て削除
GetHitKeyStateAll( KeyBuf ) ; // すべてのキーの状態を得る
switch(function_status){
case 0:
Menu();
break;
case 1:
Games();
break;
case 2:
Option();
break;
case 3:
Menu();
break;
case 4:
Option();
LoadGraphScreen( 410 , 50 , "EN1.bmp" , TRUE ) ;
break;
case 5:
Option();
LoadGraphScreen( 410 , 50 , "EN2.bmp" , TRUE ) ;
break;
case 6:
Option();
LoadGraphScreen( 410 , 50 , "EN3.bmp" , TRUE ) ;
break;
case 7:
Option();
LoadGraphScreen( 410 , 50 , "EN4.bmp" , TRUE ) ;
break;
default:
DxLib_End() ; // DXライブラリ使用の終了処理
return 0;
break;
}
if( ProcessMessage() == -1 ) break ; //エラーが起きたら終
ScreenFlip() ; // 裏画面データを表画面へ反映
}
DxLib_End();
return 0;
}
void Menu(){
int image; //ハンドルを受け取るためのint型変数を宣言
image = LoadGraph( "back1.bmp" ) ; //back1.bmpのハンドルを代入
DrawGraph( 0 , 0 , image , FALSE ) ; //画像を表示
SetFontSize( 50 ) ; //サイズを30に変更
SetFontThickness( 10 ) ; //太さを8に変更
ChangeFont( "MS 明朝" ) ; //種類をMS明朝に変更
ChangeFontType( DX_FONTTYPE_ANTIALIASING ); //アンチエイリアスフォントに変更
DrawString(200,200,"Defend the fish!!",GetColor(0,0,0));
SetFontSize( 20 ) ;
DrawString(320,310,"スタート(S)",GetColor(0,0,0));
if(KeyBuf[KEY_INPUT_S]==1)
function_status=1;
DrawString(320,360,"オプション(O)",GetColor(0,0,0)); //サイズを20に変更
if(KeyBuf[KEY_INPUT_O]==1)
function_status=2;
DrawString(320,410,"終了(E)",GetColor(0,0,0));
if(KeyBuf[KEY_INPUT_E]==1)
function_status=8;
}
void Games(){
if(KeyBuf[KEY_INPUT_[/url]==1)
function_status=3;
}
void Option(){
int White,Red,G_Blue;
int image; //ハンドルを受け取るためのint型変数を宣言
image = LoadGraph( "back1.bmp" ) ; //back2.bmpのハンドルを代入
DrawGraph( 0 , 0 , image , FALSE ) ; //画像を表示
White = GetColor( 0 , 0 , 0 ) ; // 白色の値を取得
Red = GetColor( 255 , 0 , 0 ) ; // 赤色の値を取得
G_Blue = GetColor( 0 , 255 , 255 ) ; // 緑と青の混合色の値を取得
DrawBox ( 720 , 50 , 410 , 400 , White , FALSE) ; // 四角形を描画(左上x座標,左上y座標,右下x座標,右下y座標)
DrawBox ( 30 , 50 , 400 , 200 , White , FALSE) ; // 四角形を描画(左上x座標,左上y座標,右下x座標,右下y座標)
DrawString(60,60,"カスタム1(キー1)",White);
if(KeyBuf[KEY_INPUT_1]==1)
function_status=4;
DrawString(60,90,"カスタム2(キー2)",White);
if(KeyBuf[KEY_INPUT_2]==1)
function_status=5;
DrawString(60,120,"カスタム3(キー3)",White);
if(KeyBuf[KEY_INPUT_3]==1)
function_status=6;
DrawString(60,150,"カスタム4(キー4)",White);
if(KeyBuf[KEY_INPUT_4]==1)
function_status=7;
DrawString(160,250,"変更",White);
DrawString(660,560,"もどる(R)",White);
if(KeyBuf[KEY_INPUT_[/url]==1)
function_status=3;
}