/*広告*/
/*STGの作り方 加速・摩擦などを利用したプログラム*/
#include "DxLib.h" void my_init_point(void); void my_init_color(void); void my_move_point(void); void my_to_center(void); void my_draw_back(void); void my_draw_point(void); void my_draw_score_board(void); double x,y,draw_x,draw_y; /*移動量*/ double m_x,m_y; /*加速度*/ double a_x,a_y; /*摩擦係数*/ double f_x,f_y; int count; int Color_White; int Color_Gray; int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ ChangeWindowMode(TRUE); DxLib_Init(); SetDrawScreen(DX_SCREEN_BACK); my_init_point(); my_init_color(); while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){ my_draw_back(); my_move_point(); my_to_center(); my_draw_point(); my_draw_score_board(); count++; } DxLib_End(); return 0; } void my_init_point(){ x = -220; y = 0; draw_x = 0; draw_y = 0; /*移動量の初期化*/ m_x = 1; m_y = 0; /*加速度の初期化*/ a_x = 0; a_y = 0; } void my_init_color(){ Color_White = GetColor(255, 255, 255); Color_Gray = GetColor(100, 100, 100); } void my_move_point(){ /*座標に移動量を足し合わせる部分*/ x = x + m_x; y = y + m_y; /*移動量に加速度を足し合わせる部分*/ m_x = m_x + a_x; m_y = m_y + a_y; } void my_to_center(){ draw_x = x + 220; draw_y = ((-1) * y) + 240; } void my_draw_back(){ DrawLine(0, 240, 440, 240, Color_White); DrawLine(220, 0, 220, 480, Color_White); DrawFormatString(220, 240, Color_White, "(0,0)"); } void my_draw_score_board(){ DrawBox(440,0,640,480,Color_Gray,true); DrawFormatString(490, 20, Color_White, "C言語入門"); DrawFormatString(475, 40, Color_White, "STGの作り方"); DrawFormatString(460, 60, Color_White, "関数表示プログラム"); DrawFormatString(500, 280, Color_White, "count:%d",count); DrawFormatString(500, 300, Color_White, "x座標:%d",(int)x); DrawFormatString(500, 320, Color_White, "y座標:%d",(int)y); DrawFormatString(465, 340, Color_White, "移動量x:%f",m_x); DrawFormatString(465, 360, Color_White, "移動量y:%f",m_y); DrawFormatString(465, 380, Color_White, "加速度x:%f",a_x); DrawFormatString(465, 400, Color_White, "加速度y:%f",a_y); DrawFormatString(465, 420, Color_White, "摩擦係数x:%f",f_x); DrawFormatString(465, 440, Color_White, "摩擦係数y:%f",f_y); } void my_draw_point(){ DrawCircle(draw_x,draw_y, 5, Color_White, 1); }/*Copyright 2016 K.N/petitetech.com*/
/*広告*/