傾きます
Posted: 2011年7月20日(水) 19:48
よろしくお願いします。
下記のようなソースファイルを書いたのですが、挿入した画像のようにモデルが傾いてしまいます。
どうすればよいでしょうか?
[img]C:\Users\Public\Pictures\SolidFighters_Question_ScreenShot_1.bmp[/img]
わかりにくいソースファイルですみません。
下記のようなソースファイルを書いたのですが、挿入した画像のようにモデルが傾いてしまいます。
どうすればよいでしょうか?
#include <DxLib.h>
typedef struct
{
int model_normal;
float x;
float y;
float speed;
float height;
int model_attack;
}redball;
typedef struct
{
int model;
float x;
float y;
float speed;
float width;
float height;
}bluecube;
typedef struct
{
int model;
float x;
float y;
float speed;
float width;
float height;
}yellowpyramid;
typedef struct
{
int model;
float x;
float y;
float speed;
float width;
float height;
}p1;
typedef struct
{
int model;
float x;
float y;
float z;
int back;
}stage_1;
typedef struct
{
int attack;
int special;
int shield;
int grab;
int appeal;
int up;
int down;
int right;
int left;
int jump;
int pause;
}key;
typedef struct
{
float x;
float y;
float z;
}camera;
typedef struct
{
float x;
float y;
float width;
float height;
float center_x;
float center_y;
}screen;
typedef struct
{
int frame_1_x;
int frame_1_y;
int frame_1_graph;
int frame_2_x;
int frame_2_y;
int frame_2_graph;
int back;
int keyflag;
int selectsound;
int chosesound;
}menu_t;
int attack_redball(float attack_redball_x,float attack_redball_y,int attack_redball_model)
{
MV1SetPosition(attack_redball_model,VGet(attack_redball_x,attack_redball_y,0.0f));
MV1DrawModel(attack_redball_model);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
int DesktopWidth;
int DesktopHeight;
int DesktopColorBitDepth;
redball rb;
stage_1 stage_1;
p1 p1;
key key;
camera camera;
screen screen;
menu_t menu;
//GetDefaultState(&DesktopWidth,&DesktopHeight,&DesktopColorBitDepth);
SetGraphMode(1024,768,16);
SetWindowIconID(100);
SetMainWindowText("SolidFighters");
if(DxLib_Init()==-1) return -1;
SetDrawScreen(DX_SCREEN_BACK);
//REDBALL構造体
rb.model_normal=MV1LoadModel("data\\characters\\redball\\redball.mqo");
rb.x=0.0f;
rb.y=-2400.0f;
rb.speed=5.0f;
rb.height=100.0f;
rb.model_attack=MV1LoadModel("data\\characters\\redball\\burn.mqo");
//STAGE_1構造体
stage_1.model=MV1LoadModel("data\\stages\\stage_1\\stage_1.mqo");
stage_1.x=0.0f;
stage_1.y=-2500.0f;
stage_1.back=LoadGraph("data\\stages\\stage_1\\stage_1_back.png",TRUE);
//KEY構造体
key.attack=(KEY_INPUT_Z);
key.special=(KEY_INPUT_X);
key.shield=(KEY_INPUT_C);
key.grab=(KEY_INPUT_D);
key.appeal=(KEY_INPUT_S);
key.up=(KEY_INPUT_UP);
key.down=(KEY_INPUT_DOWN);
key.right=(KEY_INPUT_RIGHT);
key.left=(KEY_INPUT_LEFT);
key.jump=(KEY_INPUT_UP);
key.pause=(KEY_INPUT_RETURN);
//CAMERA構造体
camera.x=0.0f;
camera.y=-1000.0f;
camera.z=-2500.0f;
//SCREEN構造体
screen.x=0.0f;
screen.y=0.0f;
screen.width=1024.0f;
screen.height=768.0f;
screen.center_x=(screen.x+screen.width)/2.0f;
screen.center_y=(screen.y+screen.height)/2.0f-250.0f;
//MENU構造体
menu.frame_1_x=32;
menu.frame_1_y=32;
menu.frame_1_graph=LoadGraph("data\\menu\\frame_1.bmp");
menu.frame_2_graph=LoadGraph("data\\menu\\frame_2.bmp");
menu.back=LoadGraph("data\\menu\\back.png");
menu.keyflag=0;
menu.selectsound=LoadSoundMem("data\\menu\\select.wav");
menu.chosesound=LoadSoundMem("data\\menu\\chose.wav");
int bright;
while(!ProcessMessage()&&!ClearDrawScreen()&&!CheckHitKey(KEY_INPUT_ESCAPE))
{
DrawGraph(0,0,menu.back,FALSE);
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_1_graph,TRUE);
if(menu.keyflag==0)
{
if(menu.frame_1_x==32&&CheckHitKey(key.right))
{
menu.frame_1_x=352;
PlaySoundMem(menu.selectsound,DX_PLAYTYPE_BACK);
}
else if(menu.frame_1_x==352&&CheckHitKey(key.right))
{
menu.frame_1_x=672;
PlaySoundMem(menu.selectsound,DX_PLAYTYPE_BACK);
}
else if(menu.frame_1_x==352&&CheckHitKey(key.left))
{
menu.frame_1_x=32;
PlaySoundMem(menu.selectsound,DX_PLAYTYPE_BACK);
}
else if(menu.frame_1_x==672&&CheckHitKey(key.left))
{
menu.frame_1_x=352;
PlaySoundMem(menu.selectsound,DX_PLAYTYPE_BACK);
}
if(menu.frame_1_x==32&&CheckHitKey(key.pause))
{
menu.frame_1_graph=menu.frame_2_graph;
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_2_graph,TRUE);
PlaySoundMem(menu.chosesound,DX_PLAYTYPE_NORMAL);
p1.model=rb.model_normal;
p1.x=rb.x;
p1.y=rb.y;
p1.speed=rb.speed;
p1.height=rb.height;
break;
}
if(menu.frame_1_x==352&&CheckHitKey(key.pause))
{
menu.frame_1_graph=menu.frame_2_graph;
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_2_graph,TRUE);
PlaySoundMem(menu.chosesound,DX_PLAYTYPE_NORMAL);
break;
}
if(menu.frame_1_x==672&&CheckHitKey(key.pause))
{
menu.frame_1_graph=menu.frame_2_graph;
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_2_graph,TRUE);
PlaySoundMem(menu.chosesound,DX_PLAYTYPE_NORMAL);
break;
}
}
if(CheckHitKeyAll()) menu.keyflag=1;
if(!CheckHitKeyAll()) menu.keyflag=0;
ScreenFlip();
}
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_2_graph,TRUE);
for(bright=255;bright>0;bright-=5)
{
ClearDrawScreen();
if(CheckHitKey(KEY_INPUT_ESCAPE)) break;
DrawGraph(0,0,menu.back,FALSE);
DrawGraph(menu.frame_1_x,menu.frame_1_y,menu.frame_2_graph,TRUE);
SetDrawBright(bright,bright,bright);
ScreenFlip();
}
SetDrawBright(255,255,255);
while((!ProcessMessage()&&!ClearDrawScreen()&&!CheckHitKey(KEY_INPUT_ESCAPE)))
{
if(CheckHitKey(key.right))
{
rb.x+=rb.speed;
stage_1.x+=rb.speed;
/*camera.z-=rb.speed;
screen.center_x+=rb.speed;*/
}
if(CheckHitKey(key.left))
{
rb.x-=rb.speed;
/*camera.z+=rb.speed;
screen.center_x-=rb.speed;*/
}
if(CheckHitKey(key.special)) attack_redball(rb.x,rb.y,rb.model_attack);
DrawGraph(0,0,stage_1.back,FALSE);
SetCameraPositionAndTargetAndUpVec(VGet(camera.x,camera.y,camera.z),VGet(screen.center_x,screen.center_y,10000.0f),VGet(0.0f,1.0f,0.0f));
SetCameraScreenCenter(screen.center_x,screen.center_y);
SetLightDirection(VGet(-1.0f,-10.0f,1.0f));
MV1SetPosition(rb.model_normal,VGet(rb.x,rb.y,0.0f));
MV1SetPosition(stage_1.model,VGet(stage_1.x,stage_1.y,0.0f));
MV1DrawModel(stage_1.model);
MV1DrawModel(rb.model_normal);
ScreenFlip();
}
DxLib_End();
return 0;
}
わかりにくいソースファイルですみません。