forked from NaiJi/project-kyoku
Init
This commit is contained in:
commit
5b1a00adeb
|
@ -0,0 +1,73 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(project-kyoku LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(SOURCES application.cpp main.cpp)
|
||||
set(HEADER_FILES application.h)
|
||||
|
||||
# STATIC #
|
||||
# You need to build SFML from sources with cmake
|
||||
set(SFML_LIB_DIR
|
||||
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-graphics.so.2.5
|
||||
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-system.so.2.5
|
||||
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-window.so.2.5)
|
||||
set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include)
|
||||
include_directories(${SFML_INCL_DIR})
|
||||
add_executable(project-kyoku ${SOURCES} ${HEADER_FILES} )
|
||||
target_link_libraries(project-kyoku ${SFML_LIB_DIR})
|
|
@ -0,0 +1,66 @@
|
|||
#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();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
//#include <SFML/Audio/Music.hpp>
|
||||
#include <SFML/System/Clock.hpp>
|
||||
#include <SFML/Graphics/RectangleShape.hpp>
|
||||
|
||||
#include <stack>
|
||||
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
void run();
|
||||
void update();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
sf::RenderWindow game_window;
|
||||
sf::Clock music;
|
||||
//sf::Music music;
|
||||
sf::RectangleShape pulse_mask;
|
||||
|
||||
std::stack<sf::Int64> timeline;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
Loading…
Reference in New Issue