ページ 11

どうすれば・・・

Posted: 2009年11月13日(金) 00:08
by やばい
このhttp://dixq.net/s/4.htmlの画像のようにしたいのですができません。くろくなってFPSしか表示されませんでしたどうすればよろしいでしょうか?


#include "DxLib.h"

/* グローバル宣言 */

int counter=0;
int color_white;
char Key[256];

//画像ファイルハンドル
int img_background[2];
int img_player[4];


//構造体
typedef struct{
double x,y;
int status,counter;
int shot [11][15];
} BODY_player_t;

BODY_player_t Player;


/******************/

void img_sound_load(){
img_background[0] = LoadGraph("Sh/img/back/background0.png");
img_background[1] = LoadGraph("Sh/img/back/background1.png");
LoadDivGraph( "Sh/img/char/player.png" , 4 , 4 , 1 , 32 , 48 , img_player ) ;
}

void initialization(){
Player.x=200.0;
Player.y=400.0;
Player.counter=0;
Player.status=0;
}

void SetColor(){
color_white = GetColor(255,255,255); //白色ハンドルを取得
}

void Background(){
DrawGraph(0,0,img_background[0],FALSE); //背景を描画
}

void PlayerControl(){
DrawGraph((int)Player.x,(int)Player.y,img_player[0],TRUE);//プレイヤーを描画
}

void Background2(){
DrawGraph(420,0,img_background[1],FALSE); //得点盤を描画
}

void FpsTimeFanction(){
static int FpsTime[2]={0,},FpsTime_i=0;
static double Fps=0.0;

if(FpsTime_i== 0)
FpsTime[0]=GetNowCount(); //1周目の時間取得
if(FpsTime_i==49){
FpsTime[1]=GetNowCount(); //50周目の時間取得
Fps = 1000.0f / ((FpsTime[1] - FpsTime[0]) / 50.0f);//測定した値からfpsを計算
FpsTime_i=0;
}
else
FpsTime_i++; //現在何周目かカウント
if(Fps != 0)
DrawFormatString(565,460,color_white,"FPS %.1f",Fps); //fpsを表示
return;
}

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
int RefreshTime=0;

ChangeWindowMode( TRUE ) ;
if( DxLib_Init() == -1 ) return -1;

SetDrawScreen( DX_SCREEN_BACK ) ; //裏画面を使用する。

img_sound_load(); //画像ファイルをロード
initialization(); //初期化
SetColor(); //色を取得

while(ProcessMessage() == 0 && GetHitKeyStateAll(Key) == 0){
RefreshTime = GetNowCount(); //今の時間を取得
ClearDrawScreen(); //裏画面のデータを全て削除

Background(); //背景描画

PlayerControl(); //プレイヤー描画

Background2(); //得点盤描画

FpsTimeFanction(); //FPS計算

ScreenFlip() ; //裏画面データを表画面へ反映

counter++;

if(Key[KEY_INPUT_ESCAPE]==1) break; //Escapeが押されたら終了
while(GetNowCount() - RefreshTime < 17); //1周の処理が17ミリ秒になるまで待つ
}

DxLib_End() ;
return 0 ;
}

Re:どうすれば・・・

Posted: 2009年11月13日(金) 00:23
by Korsakov
FPSが表示されていると言う事は、FpsTimeFanction()内で
描画そのものは正常に実行されていると考えられますよね。

ここでバグの元となっているのは以下の関数ではないでしょうか?

Background(); //背景描画

PlayerControl(); //プレイヤー描画

Background2(); //得点盤描画

これらの関数にブレークポイントを仕掛けて、画像が読み込めているかなど
確認してみたら?