サンプルプロジェクトを分割コンパイルすると正常に動作しません...
Posted: 2014年2月20日(木) 17:04
初めて投稿します、よろしくお願いします。
サンプルプログラム(http://dixq.net/g/01_01.html)をダウンロードし
RPGを作りたいと思い機能ごとに分割しました。
以下がソースになりますが本来ならば右キー入力時にキャラが歩くはずなのですが
キャラクタの画像すら表示されません。
プログラミング歴が浅いので初歩的な間違い、もしくはタブーを犯している可能性があるので
ここで質問させていただきました。
ご指摘よろしくお願いします。
>> main.cpp
>>Player.cpp
>>Player.h
サンプルプログラム(http://dixq.net/g/01_01.html)をダウンロードし
RPGを作りたいと思い機能ごとに分割しました。
以下がソースになりますが本来ならば右キー入力時にキャラが歩くはずなのですが
キャラクタの画像すら表示されません。
プログラミング歴が浅いので初歩的な間違い、もしくはタブーを犯している可能性があるので
ここで質問させていただきました。
ご指摘よろしくお願いします。
>> main.cpp
#include <stdio.h>
#include "DxLib.h"
#include "Player.h"
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow )
{
if( ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() == 1 ) return -1;
while( !ProcessMessage() && !ClearDrawScreen())
{
// デバッグ用
DrawFormatString( 200, 130, GetColor(0, 255, 0), "OK! -> 01");
//--------------------------------------------------------------------------------------------
// キャラクタの移動と表示( Player.cpp )
//--------------------------------------------------------------------------------------------
f_MoveDrowCharacter();
ScreenFlip();
}
DxLib_End();
return 0;
}
#include "DxLib.h"
typedef struct
{
int x;
int y;
char img;
}ch_t;
char Key[256];
void f_MoveDrowCharacter(void)
{
ch_t ch;
int image[12];
ch.x = 32;
ch.y = 160;
SetDrawScreen( DX_SCREEN_BACK );
LoadDivGraph( "画像/image.png", 12, 3, 4, 32, 32, image );
ch.img=image[2];
////////// デバッグ用
DrawFormatString( 200, 155, GetColor(0, 255, 0), "OK! -> 02");
if( Key[ KEY_INPUT_RIGHT ] == 1 )
{
ch.x++;
}
else if( ch.x % 32 != 0 )
{
ch.x++;
// 移動画像の選択
if (ch.x % 32 == 0 ) ch.img = image[7];
else if( ch.x % 32 == 1 ) ch.img = image[8];
else if( ch.x % 32 == 2 ) ch.img = image[8];
else if( ch.x % 32 == 3 ) ch.img = image[8];
else if( ch.x % 32 == 4 ) ch.img = image[8];
else if( ch.x % 32 == 5 ) ch.img = image[8];
else if( ch.x % 32 == 6 ) ch.img = image[8];
else if( ch.x % 32 == 7 ) ch.img = image[8];
else if( ch.x % 32 == 8 ) ch.img = image[8];
else if( ch.x % 32 == 9 ) ch.img = image[6];
else if( ch.x % 32 == 10 ) ch.img = image[6];
else if( ch.x % 32 == 11 ) ch.img = image[6];
else if( ch.x % 32 == 12 ) ch.img = image[6];
else if( ch.x % 32 == 13 ) ch.img = image[6];
else if( ch.x % 32 == 14 ) ch.img = image[6];
else if( ch.x % 32 == 15 ) ch.img = image[6];
else if( ch.x % 32 == 16 ) ch.img = image[6];
else if( ch.x % 32 == 17 ) ch.img = image[8];
else if( ch.x % 32 == 18 ) ch.img = image[8];
else if( ch.x % 32 == 19 ) ch.img = image[8];
else if( ch.x % 32 == 20 ) ch.img = image[8];
else if( ch.x % 32 == 21 ) ch.img = image[8];
else if( ch.x % 32 == 22 ) ch.img = image[8];
else if( ch.x % 32 == 23 ) ch.img = image[8];
else if( ch.x % 32 == 24 ) ch.img = image[8];
else if( ch.x % 32 == 25 ) ch.img = image[7];
else if( ch.x % 32 == 26 ) ch.img = image[7];
else if( ch.x % 32 == 27 ) ch.img = image[7];
else if( ch.x % 32 == 28 ) ch.img = image[7];
else if( ch.x % 32 == 29 ) ch.img = image[7];
else if( ch.x % 32 == 30 ) ch.img = image[7];
else if( ch.x % 32 == 31 ) ch.img = image[7];
}
DrawGraph( ch.x, ch.y, ch.img, TRUE);
////////// デバッグ用
DrawFormatString( 200, 180, GetColor(0, 255, 0), "OK! -> 03");
ScreenFlip();
}