#include "DxLib.h"
#include <math.h>
#define g 9.8067
#define y_max 2.000
typedef struct{
int px,py,handle;
int time,time1;
}ch_t;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
char Key[256];
int handle[16];
int haikei;
int flag=0;
ch_t ch;
double t;
if(ChangeWindowMode(TRUE)!=DX_CHANGESCREEN_OK||DxLib_Init()==-1) return -1;
ch.px=320;
ch.py=240;
SetDrawScreen(DX_SCREEN_BACK);
LoadDivGraph("画像/キャラクタ10.png",16,4,4,32,32,handle);
//haikei=LoadGraph("画像/無題.png");
while(!ProcessMessage() && !ClearDrawScreen() && !GetHitKeyStateAll( Key ) && !Key[KEY_INPUT_ESCAPE]){
if(Key[KEY_INPUT_RIGHT]==1)
ch.px+=5;
if(ch.px>640-32) ch.px=640-32;
if(Key[KEY_INPUT_LEFT]==1)
ch.px-=5;
if(ch.px<0) ch.px=0;
if(Key[KEY_INPUT_UP]==1){
ch.time=GetNowCount();
flag=1;
}
ch.handle=handle[8];
DrawGraph(ch.px,ch.py,ch.handle,TRUE);
if(flag==1){
ch.time1=GetNowCount();
t=(double)(ch.time1-ch.time)/1000.000;
ch.py=(int)((sqrt(2.000*g*y_max)*t-0.500*g*t*t)*480.000/y_max);
if(ch.py>0)
DrawGraph(ch.px,480-ch.py,handle[8],TRUE);
else
flag=0;
}
ScreenFlip();
}
DxLib_End();
return 0;
}
画像左右の動きはできるのですが、y軸のジャンプがうまくできず、UPキーを押すと、yの0の位置に画像が描画されます。
何が間違ってるのか教えてください