館のソースコードを用いてキー入力で切り替えができるメニュー画面を独自に作ってみようとしたのですが、最初に張り付けられた画像から変化せず、詰まってしまっています。
#include "DxLib.h"
int Key[256]; // キーが押されているフレーム数を格納する
// キーの入力状態を更新する
int gpUpdateKey() {
char tmpKey[256]; // 現在のキーの入力状態を格納する
GetHitKeyStateAll(tmpKey); // 全てのキーの入力状態を得る
for (int i = 0; i < 256; i++) {
if (tmpKey[i] != 0) { // i番のキーコードに対応するキーが押されていたら
Key[i]++; // 加算
}
else { // 押されていなければ
Key[i] = 0; // 0にする
}
}
return 0;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK); //ウィンドウモード変更と初期化と裏画面設定
int Handle00, Handle01, Handle02, Handle_d00, Handle_s00, Handle_s01, Handle_s02, Handle_s03, Handle_s04, Handle_s05; // 読み込み(s=song)
Handle00 = LoadGraph("画像/menu1.png"); // 上メニュー
Handle01 = LoadGraph("画像/menu2.png"); // 下メニュー
Handle02 = LoadGraph("画像/settings.png"); // 設定ボタン
Handle_d00 = LoadGraph("画像/song-d/difficult.png"); // 難易度表
Handle_s00 = LoadGraph("画像/song/1.png"); //ここからジャケット
Handle_s01 = LoadGraph("画像/song/2.png");
Handle_s02 = LoadGraph("画像/song/3.png");
Handle_s03 = LoadGraph("画像/song/4.png");
Handle_s04 = LoadGraph("画像/song/5.png");
Handle_s05 = LoadGraph("画像/song/6.png");
int x = 300;
// while(裏画面を表画面に反映, メッセージ処理, 画面クリア)
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0) {
DrawRotaGraph(0, 0, 2.85, 0.0, Handle00, TRUE); //画像の描画
DrawGraph(0, 140, Handle01, TRUE); //画像の描画
DrawGraph(555, 435, Handle02, TRUE);//画像の描画
if (Key[KEY_INPUT_RIGHT] >= 1) { // 右キーが押されていたら
x++; // 右へ移動
}
if (Key[KEY_INPUT_LEFT] >= 1) { // 左キーが押されていたら
x--; // 左へ移動
}
if (x == 0 || x == 600) {
x = 300;
}
if (x == 300) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s00, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s05, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s01, TRUE); //左 減算
}
else if (x == 350 || x == 50) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s01, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s00, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s02, TRUE); //左 減算
}
else if (x == 400 || x == 100) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s02, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s01, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s03, TRUE); //左 減算
}
else if (x == 450 || x == 150) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s03, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s02, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s04, TRUE); //左 減算
}
else if (x == 500 || x == 200) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s04, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s03, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s05, TRUE); //左 減算
}
else if (x == 550 || x == 250) {
DrawRotaGraph(520, 80, 0.3, 0.0, Handle_d00, TRUE); //難易度
DrawRotaGraph(320, 310, 0.60, 0.0, Handle_s05, TRUE); //中
DrawRotaGraph(0, 310, 0.45, 0.0, Handle_s04, TRUE); //右 加算
DrawRotaGraph(640, 310, 0.45, 0.0, Handle_s00, TRUE); //左 減算
}
}
DxLib_End(); // DXライブラリ終了処理
return 0;
}
(39行目の値を変えると画像が変わったため)
画像を更新するためにはどのようにすればよろしいのでしょうか。