commit 5b1a00adeb5ed0bd1283a3165d3146c95c6f672e Author: NaiJi Date: Sat Apr 3 20:14:31 2021 +0300 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/.gitignore @@ -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 + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0d7a25d --- /dev/null +++ b/CMakeLists.txt @@ -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}) diff --git a/application.cpp b/application.cpp new file mode 100644 index 0000000..6faa52a --- /dev/null +++ b/application.cpp @@ -0,0 +1,66 @@ +#include "application.h" +#include +#include + +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(); +} diff --git a/application.h b/application.h new file mode 100644 index 0000000..c0499f3 --- /dev/null +++ b/application.h @@ -0,0 +1,28 @@ +#ifndef APPLICATION_H +#define APPLICATION_H + +#include +//#include +#include +#include + +#include + +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 timeline; +}; + +#endif // APPLICATION_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..7fc7a77 --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include +#include "application.h" + +using namespace std; + +int main() +{ + Application app; + app.run(); +}