-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunningScene.cpp
More file actions
68 lines (56 loc) · 2.19 KB
/
RunningScene.cpp
File metadata and controls
68 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "RunningScene.h"
#include "SceneBase.h"
#include <DxLib.h>
#include "GameUtility.h"
#include "framework.h"
#include "TypeManager.h"
#include "SceneManager.h"
namespace {
TypeManager& typeManager = TypeManager::GetInstance();
}
RunningScene::RunningScene()
: SceneBase("RunningScene"), inputString("") {
}
RunningScene::~RunningScene()
{
}
void RunningScene::Init() {
inputHandle = MakeKeyInput(255, FALSE, FALSE, FALSE);
keySoundHandle = LoadSoundMem("キーボード1.mp3");
backgroundHandle = LoadGraph("background_image.png");
SetActiveKeyInput(inputHandle);
if (inputHandle == -1) {
MessageBox(NULL, "キー入力ハンドルの作成に失敗しました。", NULL, MB_OK | MB_ICONERROR);
}
}
void RunningScene::Update() {
static int before = GetNowCount();
int after = GetNowCount();
float delta = (after - before) / 1000.0f;
before = after;
timer -= delta;
GetKeyInputString(inputString, inputHandle);
if (typeManager.getAmountWord() <= 0) {
SceneManager::GetInstance().ChangeScene("EndingScene");
}
if ((std::string(inputString)._Equal(typeManager.getCurrentWord().typeWord) && typeManager.getAmountWord() > 0) || timer <= 0) {
typeManager.nextWord();
timer = 100.0;
typeManager.correctCount++;
SetKeyInputString("", inputHandle);
}
static int beforeKeyAll = 0;
if (CheckHitKeyAll() && keySoundHandle != -1 && beforeKeyAll == 0) {
PlaySoundMem(keySoundHandle, DX_PLAYTYPE_BACK);
}
beforeKeyAll = CheckHitKeyAll();
}
void RunningScene::Draw() {
DrawGraph(0, 0, backgroundHandle, TRUE);
GameUtility::DrawFix2DText(LEFT, 10, 10, 20, "残り時間: " + std::to_string(timer) + "秒", Color::WHITE, Color::BLACK);
GameUtility::DrawFix2DText(CENTER, Screen::WIDTH / 2, Screen::HEIGHT / 2 - 50, 30, typeManager.getCurrentWord().viewWord, Color::WHITE, Color::BLACK);
GameUtility::DrawFix2DText(CENTER, Screen::WIDTH / 2, Screen::HEIGHT / 2, 30, "(" + typeManager.getCurrentWord().typeWord + ")", Color::WHITE, Color::BLACK);
GameUtility::DrawFix2DText(CENTER, Screen::WIDTH / 2, (Screen::HEIGHT / 2) + 50, 30, inputString, Color::WHITE, Color::BLACK);
DrawBox(0, 500, Screen::WIDTH, 520, Color::BLACK, true);
DrawBox(0, 500, Screen::WIDTH - ((timer / 100) * Screen::WIDTH), 520, GetColor(255, 0, 0), true);
}