#include"DxLib.h"
int st2std[10],st2stdl[10],st2wk2[12],st2wk2l[12];
//移動の際使う
int x, y;
//iとmでアニメーションの周期速度調整
int i = 0, m = 0,P=0,Q=0;
//向き muki>=0右 muki<0左
int muki;
//初期位置
int shokix = 50, shokiy = 320;
//当判定 左上xy,右下xy
int at[4] = {17,18,42,45};
int AT[4];
//重力
int GPOWER;
//自機画像左上のポイント
int Yzah, Xzah;
//接地している場合0 していない場合1 ※考え中
int setti=0;
int st[];
void st2stdrv();
void st2stdlv();
void st2wk2rv();
void st2wk2lv();
void zahyou();
void jump();
void gravity();
void stage0();
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
//右向き
muki = 0;
//↓画像10分割,横5分割,縦2分割,一つの横サイズ63,一つの縦サイズ48,代入する変数
LoadDivGraph("画像/style2-stand.png",10,5,2,63,48,st2std);
LoadDivGraph("画像/style2-standl.png", 10, 5, 2, 63, 48, st2stdl);
LoadDivGraph("画像/st2-walk2.png", 12, 6, 2, 63, 48, st2wk2);
LoadDivGraph("画像/st2-walk2l.png", 12, 6, 2, 63, 48, st2wk2l);
while (ScreenFlip() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0) {
Xzah = x + shokix;
Yzah = y + shokiy;
if (CheckHitKey(KEY_INPUT_0))zahyou();
if(muki>=0)st2stdrv();
if (muki < 0)st2stdlv();
// ボックスの左上[移動先(x)+初期位置(50)+当たり判定X座標左上(17)] FALSE= 塗りつぶしなし
if (CheckHitKey(KEY_INPUT_RIGHT))st2wk2rv();
if (CheckHitKey(KEY_INPUT_LEFT))st2wk2lv();
//if (CheckHitKey(KEY_INPUT_UP))y=y--;
//if (CheckHitKey(KEY_INPUT_DOWN))y=y++;
//ジャンプ上昇
if (CheckHitKey(KEY_INPUT_SPACE))jump();
//ジャンプからボタンを離すとゆるやかに数字が下降
if (CheckHitKey(KEY_INPUT_SPACE) == 0)Q--, gravity();
//Qがマイナスにならないよう処理
if (Q < 0)Q = 0;
//座標表示
if (CheckHitKey(KEY_INPUT_Q))zahyou();
stage0();
DrawFormatString(10, 25, GetColor(255, 255, 255), "Q=%d", Q);
DrawFormatString(10, 65, GetColor(255, 255, 255), "Y座標=%d", Yzah);
DrawFormatString(10, 80, GetColor(255, 255, 255), "X座標=%d", Xzah);
DrawFormatString(10, 115, GetColor(255, 255, 255), "GPOWER=%d", GPOWER);
DrawFormatString(10, 150, GetColor(255, 255, 255), "at[0]=%d", at[0]);
DrawFormatString(10, 165, GetColor(255, 255, 255), "y=%d", y);
DrawFormatString(10, 200, GetColor(255, 255, 255), "x=%d", x);
DrawFormatString(10, 215, GetColor(255, 255, 255), "shokiy=%d", shokiy);
DrawFormatString(10, 230, GetColor(255, 255, 255), "shokix=%d", shokix);
}
DxLib_End();
return 0;
}
void st2stdrv() {
//立ち状態右向き
DrawFormatString(100, 170, GetColor(255, 255, 255), "i=%d,m=%d", i, m);
DrawGraph(x + shokix, y + shokiy, st2std[i], TRUE);
m++;
if (m % 5 == 0)i++;
if (i >= 10)i = 0;
if (m >= 50)m = 0;
//自機の白い四角
DrawBox(x + shokix + at[0], y + shokiy + at[1], x + shokix + at[2], y + shokiy + at[3], GetColor(255, 255, 255), FALSE);
//自機の足元ピンク
DrawLine(x + shokix + at[0], y + shokiy + at[3], x + shokix + at[2] , y + shokiy + at[3], GetColor(255, 0, 255));
}
void st2stdlv() {
//立状態左向き
DrawFormatString(70, 170, GetColor(255, 255, 255), "i=%d,m=%d", i, m);
DrawGraph(x + shokix, y + shokiy, st2stdl[i], TRUE);
m++;
if (m % 5 == 0)i++;
if (i >= 10)i = 0;
if (m >= 50)m = 0;
DrawBox(x + shokix + at[0], y + shokiy + at[1], x + shokix + at[2], y + shokiy + at[3], GetColor(255, 255, 255), FALSE);
}
void st2wk2rv() {
//右歩き
ClearDrawScreen();
DrawGraph(x + shokix, y + shokiy, st2wk2[i], TRUE);
x = x + 2;
m++;
if (m % 5 == 0)i++;
if (i >= 10)i = 0;
if (m >= 50)m = 0;
muki = 0;
DrawBox(x + shokix + at[0], y + shokiy + at[1], x + shokix + at[2], y + shokiy + at[3], GetColor(255, 255, 255), FALSE);
if(m==1)PlaySound("foot_SE.mp3", DX_PLAYTYPE_NORMAL);
}
void st2wk2lv() {
//左歩き
ClearDrawScreen();
DrawGraph(x + shokix, y + shokiy, st2wk2l[i], TRUE);
x = x = x - 2;
m++;
if (m % 5 == 0)i++;
if (i >= 10)i = 0;
if (m >= 50)m = 0;
muki = -1;
DrawBox(x + shokix + at[0], y + shokiy + at[1], x + shokix + at[2], y + shokiy + at[3], GetColor(255, 255, 255), FALSE);
}
void zahyou()
{
//x座標数字表示
for (int i = 0; i <= 600; i++)
{
if (i % 50 == 0)
{
DrawLine(i, 0, i, 10, GetColor(255, 255, 255));
DrawFormatString(i, 10, GetColor(255, 255, 255), "%d", i);
}
}
//y座標数字表示
for (int i = 0; i <= 600; i++)
{
if (i > 0)
if (i % 50 == 0)
{
DrawLine(0, i, 10, i, GetColor(255, 255, 255));
DrawFormatString(10, i, GetColor(255, 255, 255), "%d", i);
}
}
//縦線座標表示
for (int Q = 0; Q <= 700; Q++)
{
if (Q % 50 == 0)
{
for (int i = 0; i <= 450; i++)
{
if (i % 50 == 0)DrawLine(Q, i - 5, Q, i + 5, GetColor(255, 255, 255));
}
}
}
//横線座標表示
for (int Q = 0; Q <= 700; Q++)
{
if (Q % 50 == 0)
{
for (int i = 0; i <= 450; i++)
{
if (i % 50 == 0)DrawLine(Q - 5, i, Q + 5, i, GetColor(255, 255, 255));
}
}
}
}
void jump()
{
Q++;
if (Q >= 33)Q=33;
if (Q == 1)y = y - 10;
if (Q == 2)y = y - 9;
if (Q == 3)y = y - 9;
if (Q == 4)y = y - 7;
if (Q == 5)y = y - 7;
if (Q == 6)y = y - 7;
if (Q == 7)y = y - 6;
if (Q == 8)y = y - 6;
if (Q == 9)y = y - 6;
if (Q == 10)y = y - 6;
if (Q == 11)y = y - 5;
if (Q == 12)y = y - 5;
if (Q == 13)y = y - 5;
if (Q == 14)y = y - 5;
if (Q == 15)y = y - 5;
if (Q == 16)y = y - 4;
if (Q == 17)y = y - 4;
if (Q == 18)y = y - 4;
if (Q == 19)y = y - 4;
if (Q == 20)y = y - 3;
if (Q == 21)y = y - 3;
if (Q == 22)y = y - 2;
if (Q == 23)y = y - 2;
if (Q == 24)y = y - 2;
if (Q == 25)y = y - 2;
if (Q == 26)y = y - 2;
if (Q == 27)y = y - 2;
if (Q == 28)y = y - 1;
if (Q == 29)y = y - 1;
if (Q == 30)y = y - 1;
if (Q == 31)y = y - 1;
if (Q == 32)y = y - 1;
/*
if (Q == 1)y = y - 8;
if (Q == 2)y = y - 7;
if (Q == 3)y = y - 7;
if (Q == 4)y = y - 6;
if (Q == 5)y = y - 6;
if (Q == 6)y = y - 6;
if (Q == 7)y = y - 5;
if (Q == 8)y = y - 5;
if (Q == 9)y = y - 5;
if (Q == 10)y = y - 5;
if (Q == 11)y = y - 4;
if (Q == 12)y = y - 4;
if (Q == 13)y = y - 4;
if (Q == 14)y = y - 4;
if (Q == 15)y = y - 4;
if (Q == 16)y = y - 3;
if (Q == 17)y = y - 3;
if (Q == 18)y = y - 3;
if (Q == 19)y = y - 3;
if (Q == 20)y = y - 3;
if (Q == 21)y = y - 3;
if (Q == 22)y = y - 2;
if (Q == 23)y = y - 2;
if (Q == 24)y = y - 2;
if (Q == 25)y = y - 2;
if (Q == 26)y = y - 2;
if (Q == 27)y = y - 2;
if (Q == 28)y = y - 1;
if (Q == 29)y = y - 1;
if (Q == 30)y = y - 1;
if (Q == 31)y = y - 1;
if (Q == 32)y = y - 1;
*/
}
void gravity()
{
GPOWER = (33 - Q)/3;
y = y + GPOWER;
if (Yzah >= 450)y=y - 450;
if (CheckHitKey(KEY_INPUT_P))y = y - GPOWER;
}
void stage0()
{
int AT[4] = { x + shokix + at[0], y + shokiy + at[1], x + shokix + at[2], y + shokiy + at[3] };
DrawFormatString(10, 130, GetColor(255, 255, 255), "AT[0]=%d", AT[0]);
DrawFormatString(100, 130, GetColor(255, 255, 255), "AT[1]=%d", AT[1]);
DrawFormatString(190, 130, GetColor(255, 255, 255), "AT[2]=%d", AT[2]);
DrawFormatString(280, 130, GetColor(255, 255, 255), "AT[3]=%d", AT[3]);
// ここから ここまで
DrawLine(60, 420, 120,420, GetColor(255, 255, 255));
if (((60 <= AT[0] && AT[0] <= 120) || (60 <= AT[2] && AT[2] <= 120)) && (420<=AT[3]&&AT[3]<=430))y = y-GPOWER;
}