今現在このようなプログラムでbgm自体は流れるのですがノーツが流れてこなくなってしまいました。
C言語初心者でDXライブラリも使い始めたばかりなので勝手がわからず困っているので是非教えていただきたいです。
#include "DxLib.h"
#define WIN_W 800 //ウインドウの横幅
#define WIN_H 600 //ウインドウの縦幅
#define LANE_SIZE 1 //レーンの数
#define BAR_SIZE 40 //1レーンあたりの最大bar数
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
char buf[256]; //キー押下状態格納用配列
int key[LANE_SIZE] = {
KEY_INPUT_A
};
int score=0;
int SHandle;
static int state = 0;
bool bar_f[LANE_SIZE][BAR_SIZE]; //barの存在フラグ
float bar_y[LANE_SIZE][BAR_SIZE]; //barのY座標
for (int j = 0; j < BAR_SIZE; j++) {
for (int i = 0; i < LANE_SIZE; i++) {
bar_f[i][j] = false; //全てにfalseを代入
}
}
LONGLONG start_time; //開始した時刻
LONGLONG now_time; //現在のフレームの時刻
int currentTime; //開始してからの経過時間
int counter = 0;
const int bpm = 120;
SetMainWindowText("リズムの達人"); //ウインドウのタイトルを設定
ChangeWindowMode(TRUE); //ウィンドウモードで起動
SetGraphMode(WIN_W, WIN_H, 32); //画面の解像度指定
SetWindowSizeChangeEnableFlag(FALSE); //画面サイズ変更不可
if (DxLib_Init() == -1) { return -1; } //DxLib初期化処理
SetDrawScreen(DX_SCREEN_BACK); //描画先を裏画面に設定
enum judge_value {
NONE, GOOD, MISS
};
const int JUDGE_DISPLAY_TIME = 30; // 判定を表示する時間 (フレーム数)
judge_value judge = NONE; // 表示中の判定
int judge_time = 10; // 判定を表示する残り時間 (フレーム数)
//while(裏画面を表画面に反映, メッセージ処理, 画面クリア)
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0) {
LoadGraphScreen(1, 1, "a0.png", TRUE);
if (buf[KEY_INPUT_ESCAPE] == 1) {
break; // 終了
}
SHandle = LoadSoundMem("ゆかいな日常.mp3");
switch (state) {
case 0:
PlaySoundMem(SHandle, DX_PLAYTYPE_BACK);
state = 1;
break;
case 1:
if (CheckSoundMem(SHandle) == 0)
state = 2;
break;
case 2:
StopSoundMem(SHandle);
break;
}
//時間関係
if (counter == 0) {
start_time = GetNowHiPerformanceCount();
}
now_time = GetNowHiPerformanceCount();
currentTime = (int)((now_time - start_time) / 1000); // ms
//bar生成
if (currentTime >= 550000 / bpm * counter) {
for (int i = 0; i < LANE_SIZE; i++) {
bar_f[i][counter % BAR_SIZE] = true;
bar_y[i][counter % BAR_SIZE] = -100.f;
}
counter++;
}
//DrawFormatString(100, 100, GetColor(255, 255, 255), "currentTime---%d", currentTime);
//bar座標更新
for (int i = 0; i < LANE_SIZE; i++) {
for (int j = 0; j < BAR_SIZE; j++) {
if (bar_f[i][j]) {
bar_y[i][j] += 4.f;
//DrawFormatString(100, 120, GetColor(255, 255, 0), "bar_y[i][j]---%f", bar_y[i][j]);
if (bar_y[i][j] > WIN_H + 10) {
bar_f[i][j] = false; //画面外に出たらfalse
// MISSを表示させる
judge = MISS;
DrawFormatString(10, 10, GetColor(0, 0, 255), "MISS");
judge_time = JUDGE_DISPLAY_TIME;
}
}
}
}
// 判定
GetHitKeyStateAll(buf);
for (int i = 0; i < LANE_SIZE; i++) {
for (int j = 0; j < BAR_SIZE; j++) {
if (bar_f[i][j]) {
if (WIN_H / 5 * 4 - 30 < bar_y[i][j] && bar_y[i][j] < WIN_H / 5 * 4 + 30) {
if (buf[key[i]] == 1) {
bar_f[i][j] = false;
// GOODを表示させる
judge = GOOD;
DrawFormatString(10, 10, GetColor(255, 0, 0), "GOOD");
judge_time = JUDGE_DISPLAY_TIME;
}
}
}
}
}
if (judge != NONE) {
if (judge == GOOD) {
DrawFormatString(10, 10, GetColor(255, 0, 0), "GOOD");
// GOODを描画する (テキスト・画像など)
score++;
}
else if (judge == MISS) {
DrawFormatString(10, 10, GetColor(0, 0, 255), "MISS");
// MISSを描画する (テキスト・画像など)
}
judge_time--;
if (judge_time <= 0) judge = NONE; // 指定の時間が経過したら、判定を消す
}
//判定ライン描画
DrawLine(0, WIN_H / 5 * 4, WIN_W, WIN_H / 5 * 4, GetColor(255, 255, 255));
DrawCircleAA(400.f, 480.f, 45.f, 60.f, GetColor(255, 255, 255), FALSE);
//bar描画
for (int i = 0; i < LANE_SIZE; i++) {
for (int j = 0; j < BAR_SIZE; j++) {
if (bar_f[i][j]) {
DrawCircleAA(400.f + i * 1.f, bar_y[i][j] - 10.f,
30.f + 1.f + i * 1.f, bar_y[i][j] + 10.f, GetColor(0, 255, 0), TRUE);
}
}
}
}
DxLib_End(); //DxLibの終了処理
return 0; //正常終了
}