とりあえずステージ画像表示とキャラクター操作のコードをかいてみました。
コンパイルエラーも出なくて、出来たと思い起動してみたところコマンドプロントプトの部分に "Not a JPEG file: starts with 0x89 0x50"
と出てきてDXライブラリのウィンドウには何も表示されませんでした。
自分でいろいろ調べてみたのですがこれが起きているのかがまったくわかりません。ちなみに画像はexeファイルと同じところにおいてあります。
*OSはwindows XP Service Pack3 コンパイラーはBCC32 開発環境はBCC Developer を使っています。
"Not a JPEG file: starts with 0x89 0x50"がなぜ起きるのかだけでも教えていただければ幸いです
下がプログラミングコードです。
//ライブラリ宣言
#include "DxLib.h"
//定数の宣言
#define PLAYER_SIZE 50
#define PLAYER_SIZE_HALF PLAYER_SIZE/2
#define PLAYER_MOVE_HIGH_SPEED 5
#define PLAYER_MOVE_LOW_SPEED 2
#define PLAYER_BALLET_SIZE 12
#define PLAYER_BALLET_HALF_SIZE PLAYER_BALLET_SIZE/2
#define P_FirstY 240
#define P_FirstX 320
#define A_First_in_x 34
#define A_First_in_y 15
#define MINI_MOVE_PLAYER_RANGE_X 34
#define MINI_MOVE_PLAYER_RANGE_Y 15
#define MAX_MOVE_PLAYER_RANGE_X 416
#define MAX_MOVE_PLAYER_RANGE_Y 449
int joypad_state=0;
//Main関数
int main( HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
// DXライブラリの設定
// SetOutApplicationLogValidFlag(TRUE);
SetGraphMode(640,480,16);
ChangeWindowMode( TRUE ) ;
if( DxLib_Init()==-1) return-1;
// SetMouseDispFlag( TRUE ) ;
SetDrawScreen(DX_SCREEN_BACK);
int player_position_x=P_FirstX;
int player_position_y=P_FirstY;
int Area_x=A_First_in_x;
int Area_y=A_First_in_y;
int area_graph_in=LoadGraph("stagein.jpg");
int area_graph_out=LoadGraph("stageout.jpg");
int player_graph=LoadGraph("Player.png");
//関数の宣言
int CharcterOperation(int& player_position_x,int& player_position_y,
int& Player_high,int& Player_low);
//メインループ
while(ProcessMessage()==0)
{
//キャラの範囲指定
if(player_position_x>MAX_MOVE_PLAYER_RANGE_X)player_position_x=MAX_MOVE_PLAYER_RANGE_X;
if(player_position_x<MINI_MOVE_PLAYER_RANGE_X)player_position_x=MINI_MOVE_PLAYER_RANGE_X;
if(player_position_y>MAX_MOVE_PLAYER_RANGE_Y)player_position_y=MAX_MOVE_PLAYER_RANGE_Y;
if(player_position_y<MINI_MOVE_PLAYER_RANGE_Y)player_position_y=MINI_MOVE_PLAYER_RANGE_Y;
//キャラの描画
ClearDrawScreen() ;
DrawGraph(0,0,area_graph_out, TRUE);
DrawGraph(Area_x,Area_y,area_graph_in, FALSE);
DrawGraph(player_position_x-PLAYER_SIZE_HALF,
player_position_y-PLAYER_SIZE_HALF, player_graph,TRUE);
if(CheckHitKey(KEY_INPUT_ESCAPE)==TRUE)break;
}
//終了処理
DxLib_End();
return 0;
}
int CharcterOperation(int& player_position_x,int& player_position_y,
int& Player_high,int& Player_low)
{
//ジョイスティック&キー入力
joypad_state=GetJoypadInputState(DX_INPUT_KEY_PAD1);
if(CheckHitKey(KEY_INPUT_LSHIFT)!=0){
if((joypad_state&PAD_INPUT_LEFT)!=0)player_position_x-=PLAYER_MOVE_LOW_SPEED;
if((joypad_state&PAD_INPUT_RIGHT)!=0)player_position_x+=PLAYER_MOVE_LOW_SPEED;
if((joypad_state&PAD_INPUT_UP)!=0)player_position_y-=PLAYER_MOVE_LOW_SPEED;
if((joypad_state&PAD_INPUT_DOWN)!=0)player_position_y+=PLAYER_MOVE_LOW_SPEED;
}
else{
if((joypad_state&PAD_INPUT_LEFT)!=0)player_position_x-=PLAYER_MOVE_HIGH_SPEED;
if((joypad_state&PAD_INPUT_RIGHT)!=0)player_position_x+=PLAYER_MOVE_HIGH_SPEED;
if((joypad_state&PAD_INPUT_UP)!=0)player_position_y-=PLAYER_MOVE_HIGH_SPEED;
if((joypad_state&PAD_INPUT_DOWN)!=0)player_position_y+=PLAYER_MOVE_HIGH_SPEED;
}
return 0;
}