投稿者です。
やはり画像がないと答えづらいと思うので、画像を添付します。
添付画像は、
http://www.tekepon.net/fsm/EFMAPが配布しているフリー画像素材です。
よって、著作権はREFMAPに帰属します。
ソースについては、
#include "DxLib.h"
typedef struct{
int x , y , img , muki , walking_flag ;
} ch_t ;
int hantei [ 15 ] [ 20 ] = {
{ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ,
{ 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 } ,
{ 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 } ,
{ 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 } ,
{ 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ,
} ;
int can_or_cannot ( int x , int y , int muki ) {
if ( muki == 0 )
if ( hantei [ y / 32 - 1 ] [ x / 32 ] == 1 )
return 1 ;
if ( muki == 1 )
if ( hantei [ y / 32 ] [ x / 32 - 1 ] == 1 )
return 1 ;
if ( muki == 2 )
if ( hantei [ y / 32 + 1 ] [ x / 32 ] == 1 )
return 1 ;
if ( muki == 3 )
if ( hantei [ y / 32 ] [ x / 32 + 1 ] == 1 )
return 1 ;
return 0 ;
}
int WINAPI WinMain ( HINSTANCE hinstance, HINSTANCE hprevInstance, LPSTR loCmaLine, int CmaShow ) {
int image [ 12 ] , i , j ;
char Key [ 256 ] ;
ch_t ch ;
if ( ChangeWindowMode ( TRUE ) != DX_CHANGESCREEN_OK || DxLib_Init() == -1 ) return -1 ;
ch.x = 32 ;
ch.y = 448 ;
ch.walking_flag = 0 ;
ch.muki = 0 ;
int Color_Yellow = GetColor ( 255 , 255 , 0 ) ;
int Color_White = GetColor ( 255 , 255 , 255 ) ;
SetDrawScreen ( DX_SCREEN_BACK ) ;
LoadDivGraph ( "$vx_chara09_d.png" , 12 , 3 , 4 , 32 , 48 , image ) ;
while ( ! ProcessMessage() && ! ClearDrawScreen() && ! GetHitKeyStateAll ( Key ) && ! Key [ KEY_INPUT_ESCAPE ] ) {
for ( i = 0 ; i < 15 ; i++ )
for ( j = 0 ; j < 20 ; j++ )
if ( hantei [ i ] [ j ] == 1 )
DrawBox ( j * 32 , i * 32 , ( j + 1 ) * 32 , ( i + 1 ) * 32 , Color_White , TRUE ) ;
if ( ch.x % 32 == 0 && ch.y % 32 == 0 ) {
ch.walking_flag = 1 ;
if ( Key [ KEY_INPUT_UP ] == 1 )
ch.muki = 0 ;
else if ( Key [ KEY_INPUT_LEFT ] == 1 )
ch.muki = 1 ;
else if ( Key [ KEY_INPUT_DOWN ] == 1 )
ch.muki = 2 ;
else if ( Key [ KEY_INPUT_RIGHT ] == 1 )
ch.muki = 3 ;
else
ch.walking_flag = 0 ;
if ( ch.walking_flag == 1 )
if ( can_or_cannot ( ch.x , ch.y , ch.muki ) == 1 )
ch.walking_flag = 0 ;
}
if ( ch.walking_flag == 1 ) {
if ( ch.muki == 0 )
ch.y-- ;
else if ( ch.muki == 1 )
ch.x-- ;
else if ( ch.muki == 2 )
ch.y++ ;
else if ( ch.muki == 3 )
ch.x++ ;
}
ch.img = image [ ( ch.x % 32 + ch.y % 32 ) / 8 + ch.muki * 4 ] ;
DrawCircle ( 400 , 240 , 16 , Color_Yellow ) ;
DrawGraph ( ch.x , ch.y , ch.img , TRUE ) ;
ScreenFlip() ;
}
WaitKey() ;
DxLib_End() ;
return 0 ;
}
すみません…。
どこまで必要になるか分からなかったので、とりあえず全部書きました。
では、改めてよろしくお願いします。
