forked from NaiJi/project-kyoku
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#include "application.h"
|
|
#include <SFML/Graphics/Color.hpp>
|
|
#include <SFML/Window/Event.hpp>
|
|
|
|
Application::Application() :
|
|
game_window({1280, 720}, "Test")
|
|
{
|
|
float x = game_window.getSize().x;
|
|
float y = game_window.getSize().y;
|
|
pulse_mask.setSize({x, y});
|
|
pulse_mask.setOrigin(0.f, 0.f);
|
|
pulse_mask.setFillColor(sf::Color(255, 0, 0, 0));
|
|
}
|
|
|
|
void Application::run()
|
|
{
|
|
game_window.display();
|
|
timeline.push(5500000);
|
|
timeline.push(5000000);
|
|
timeline.push(4500000);
|
|
timeline.push(4000000);
|
|
timeline.push(3500000);
|
|
timeline.push(3000000);
|
|
timeline.push(2500000);
|
|
timeline.push(2000000);
|
|
timeline.push(1500000);
|
|
timeline.push(1000000);
|
|
//music.openFromFile("/home/egor/test.flac");
|
|
//usic.play();
|
|
music.restart();
|
|
while (game_window.isOpen())
|
|
{
|
|
sf::Event event;
|
|
while (game_window.pollEvent(event))
|
|
{
|
|
if (event.type == sf::Event::Closed)
|
|
game_window.close();
|
|
}
|
|
|
|
update();
|
|
draw();
|
|
}
|
|
}
|
|
|
|
void Application::update()
|
|
{
|
|
if (!timeline.empty() && timeline.top() <= music.getElapsedTime().asMicroseconds())
|
|
{
|
|
timeline.pop();
|
|
pulse_mask.setFillColor(sf::Color(255, 0, 0, 255));
|
|
}
|
|
|
|
if (pulse_mask.getFillColor().a > 0)
|
|
{
|
|
const auto alpha = pulse_mask.getFillColor().a - 1;
|
|
pulse_mask.setFillColor(sf::Color(255, 0, 0, alpha));
|
|
}
|
|
|
|
}
|
|
|
|
void Application::draw()
|
|
{
|
|
game_window.clear();
|
|
game_window.draw(pulse_mask);
|
|
game_window.display();
|
|
}
|