#2
by みけCAT » 1年前
適当にコードを補って動かしてみた結果、Game_Save関数にはクリックした場所に対応する番号が渡されていました。
よって、Game_Save関数もしくはその他の未公開の部分にバグがあると推測できます。
コード:
#include <DxLib.h>
#include <vector>
struct Date_s {
int Year, Mon, Day, Hour, Min, Sec;
Date_s() : Year(0), Mon(0), Day(0), Hour(0), Min(0), Sec(0) {}
};
void Game_Save(int x) {
printfDx("saved %d\n", x);
}
int WINAPI WinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) {
if (ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() != 0) return 1;
int SAVE_BG_D = MakeScreen(128, 128, FALSE);
SetDrawScreen(SAVE_BG_D);
DrawBox(0, 0, 128, 128, GetColor(255, 128, 128), TRUE);
DrawBox(10, 10, 118, 118, GetColor(128, 64, 64), TRUE);
SetDrawScreen(DX_SCREEN_BACK);
const int SAVE_PAGE = 0;
int FontHandle_L = CreateFontToHandle(NULL, -1, -1, -1);
std::vector<Date_s> Date(100);
int pMouseButton = 0, cMouseButton;
while (ScreenFlip() == 0 && ClearDrawScreen() == 0 && ProcessMessage() == 0) {
int x, y, z;
int Mouse_X, Mouse_Y, Mouse_CL;
GetMousePoint(&Mouse_X, &Mouse_Y);
cMouseButton = GetMouseInput();
Mouse_CL = (cMouseButton & MOUSE_INPUT_LEFT) && !(pMouseButton & MOUSE_INPUT_LEFT);
pMouseButton = cMouseButton;
//セーブ画面作成
for (y = SAVE_PAGE * 4; y < SAVE_PAGE * 4 + 4; y++) {
for (z = 0; z < 3; z++) {
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
DrawGraph(10 + (z % 3) * 416, 30 + (y % 4) * 169, SAVE_BG_D, TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
}
}
//画面上でのセーブ場所決定
for (y = SAVE_PAGE * 4; y < SAVE_PAGE * 4 + 4; y++) {//セーブ場所決定 X座標 横方向
x = 0;
for (z = 0; z < 3; z++) {//セーブ場所決定 Y座標 縦方向
DrawFormatStringToHandle(10 + ((z % 3) * 416), 30 + ((y % 4) * 169), GetColor(0, 0, 0), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
if (Mouse_X > 10 + ((z % 3) * 416) && Mouse_X < 426 + ((z % 3) * 416) && Mouse_Y>30 + ((y % 4) * 169) && Mouse_Y < 199 + ((y % 4) * 169)) {//クリック判定設定
DrawFormatStringToHandle(9 + ((z % 3) * 416), 29 + ((y % 4) * 169), GetColor(255, 255, 255), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
if (Mouse_CL != 0) {
x = (3 * (y % 4)) + (z % 3);//セーブするファイルナンバー
Game_Save(x = (3 * (y % 4)) + (z % 3)); }//セーブ処理
}
else
{
DrawFormatStringToHandle(9 + ((z % 3) * 416), 29 + ((y % 4) * 169), GetColor(192, 192, 192), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
}
}
}
}
DxLib_End();
return 0;
}
- test1_ss1.png (15.72 KiB) 閲覧数: 3348 回
適当にコードを補って動かしてみた結果、Game_Save関数にはクリックした場所に対応する番号が渡されていました。
よって、Game_Save関数もしくはその他の未公開の部分にバグがあると推測できます。
[code]
#include <DxLib.h>
#include <vector>
struct Date_s {
int Year, Mon, Day, Hour, Min, Sec;
Date_s() : Year(0), Mon(0), Day(0), Hour(0), Min(0), Sec(0) {}
};
void Game_Save(int x) {
printfDx("saved %d\n", x);
}
int WINAPI WinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) {
if (ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() != 0) return 1;
int SAVE_BG_D = MakeScreen(128, 128, FALSE);
SetDrawScreen(SAVE_BG_D);
DrawBox(0, 0, 128, 128, GetColor(255, 128, 128), TRUE);
DrawBox(10, 10, 118, 118, GetColor(128, 64, 64), TRUE);
SetDrawScreen(DX_SCREEN_BACK);
const int SAVE_PAGE = 0;
int FontHandle_L = CreateFontToHandle(NULL, -1, -1, -1);
std::vector<Date_s> Date(100);
int pMouseButton = 0, cMouseButton;
while (ScreenFlip() == 0 && ClearDrawScreen() == 0 && ProcessMessage() == 0) {
int x, y, z;
int Mouse_X, Mouse_Y, Mouse_CL;
GetMousePoint(&Mouse_X, &Mouse_Y);
cMouseButton = GetMouseInput();
Mouse_CL = (cMouseButton & MOUSE_INPUT_LEFT) && !(pMouseButton & MOUSE_INPUT_LEFT);
pMouseButton = cMouseButton;
//セーブ画面作成
for (y = SAVE_PAGE * 4; y < SAVE_PAGE * 4 + 4; y++) {
for (z = 0; z < 3; z++) {
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
DrawGraph(10 + (z % 3) * 416, 30 + (y % 4) * 169, SAVE_BG_D, TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
}
}
//画面上でのセーブ場所決定
for (y = SAVE_PAGE * 4; y < SAVE_PAGE * 4 + 4; y++) {//セーブ場所決定 X座標 横方向
x = 0;
for (z = 0; z < 3; z++) {//セーブ場所決定 Y座標 縦方向
DrawFormatStringToHandle(10 + ((z % 3) * 416), 30 + ((y % 4) * 169), GetColor(0, 0, 0), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
if (Mouse_X > 10 + ((z % 3) * 416) && Mouse_X < 426 + ((z % 3) * 416) && Mouse_Y>30 + ((y % 4) * 169) && Mouse_Y < 199 + ((y % 4) * 169)) {//クリック判定設定
DrawFormatStringToHandle(9 + ((z % 3) * 416), 29 + ((y % 4) * 169), GetColor(255, 255, 255), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
if (Mouse_CL != 0) {
x = (3 * (y % 4)) + (z % 3);//セーブするファイルナンバー
Game_Save(x = (3 * (y % 4)) + (z % 3)); }//セーブ処理
}
else
{
DrawFormatStringToHandle(9 + ((z % 3) * 416), 29 + ((y % 4) * 169), GetColor(192, 192, 192), FontHandle_L, "%d/%d/%d/%d/%d/%d", Date[x].Year, Date[x].Mon, Date[x].Day, Date[x].Hour, Date[x].Min, Date[x].Sec);//日付け表示
}
}
}
}
DxLib_End();
return 0;
}
[/code]
[attachment=0]test1_ss1.png[/attachment]