forked from jasonmaharjan/QuizmaHeros9000
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Instruction.cpp
75 lines (60 loc) · 1.85 KB
/
Instruction.cpp
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
69
70
71
72
73
74
75
#pragma once
#include <sstream>
#include "DEFINITIONS.hpp"
#include "Instruction.hpp"
#include "MainMenuState.hpp"
#include <iostream>
namespace Quizma
{
Instruction::Instruction(GameDataRef data) : _data(data)
{
}
void Instruction::Init()
{
this->_data->assets.LoadTexture("Instruction Background", INSTRUCTION_SCREEN_FILEPATH);
this->_data->assets.LoadTexture("Next Button Image", NEXT_BUTTON_FILEPATH);
this->_data->assets.LoadTexture("Cursor", CURSOR_FILEPATH);
_background.setTexture(this->_data->assets.GetTexture("Instruction Background"));
_nextButton.setTexture(this->_data->assets.GetTexture("Next Button Image"));
_cursor.setTexture(this->_data->assets.GetTexture("Cursor"));
_nextButton.setPosition(1700, 950);
_cursor.setScale(0.35, 0.35);
}
void Instruction::HandleInput()
{
sf::Event event;
while (this->_data->window.pollEvent(event))
{
if (sf::Event::Closed == event.type)
{
this->_data->window.close();
}
if (sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::Escape)
{
this->_data->window.close();
}
}
if (this->_data->input.IsSpriteClicked(this->_nextButton, sf::Mouse::Left, this->_data->window))
{
this->_data->sound.setBuffer(this->_data->buffer);
this->_data->sound.play();
this->_data->music3.play();
this->_data->machine.AddState(StateRef(new MainMenuState(_data)), true);
}
_cursor.setPosition(static_cast<sf::Vector2f>(sf::Mouse::getPosition(this->_data->window)));
}
}
void Instruction::Update(float dt)
{
}
void Instruction::Draw(float dt)
{
this->_data->window.clear(sf::Color::Black);
this->_data->window.draw(this->_background);
this->_data->window.draw(this->_nextButton);
this->_data->window.draw(this->_cursor);
this->_data->window.display();
}
}