refactor: Move from Qt build system to CMake
- Get rid of ptr usings - Rename project to cirno-puzzle - Move resources from src/
This commit is contained in:
parent
34f35f4ac0
commit
c1cd7e4e1b
|
@ -1,74 +1,5 @@
|
||||||
# This file is used to ignore files which are generated
|
# This file is used to ignore files which are generated
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
*~
|
build
|
||||||
*.autosave
|
*.user
|
||||||
*.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
|
|
||||||
|
|
||||||
*.stash
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
project(cirno-puzzle LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wpedantic -g")
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
|
||||||
|
set(CMAKE_RESOURCE_DIRECTORY ${CMAKE_SOURCE_DIR}/resources)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h" "include/*.h")
|
||||||
|
|
||||||
|
find_package(SFML REQUIRED graphics audio window system)
|
||||||
|
add_executable(cirno-puzzle ${SOURCES} ${HEADER_FILES} )
|
||||||
|
target_link_libraries(cirno-puzzle sfml-system sfml-audio sfml-graphics)
|
||||||
|
|
||||||
|
file(COPY "${CMAKE_RESOURCE_DIRECTORY}" DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,14 +0,0 @@
|
||||||
size
|
|
||||||
7 7
|
|
||||||
map
|
|
||||||
2 2 2 2 2 2 2
|
|
||||||
2 0 3 0 0 6 2
|
|
||||||
2 0 0 1 0 0 2
|
|
||||||
2 0 0 1 1 0 2
|
|
||||||
2 1 1 2 2 2 2
|
|
||||||
2 0 0 0 4 0 2
|
|
||||||
2 2 2 2 2 2 2
|
|
||||||
trigger
|
|
||||||
1 5 4 5 6 3 1 3 1
|
|
||||||
charge
|
|
||||||
1 2 2
|
|
|
@ -1,123 +0,0 @@
|
||||||
Bitstream Vera Fonts Copyright
|
|
||||||
|
|
||||||
The fonts have a generous copyright, allowing derivative works (as
|
|
||||||
long as "Bitstream" or "Vera" are not in the names), and full
|
|
||||||
redistribution (so long as they are not *sold* by themselves). They
|
|
||||||
can be be bundled, redistributed and sold with any software.
|
|
||||||
|
|
||||||
The fonts are distributed under the following copyright:
|
|
||||||
|
|
||||||
Copyright
|
|
||||||
=========
|
|
||||||
|
|
||||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream
|
|
||||||
Vera is a trademark of Bitstream, Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of the fonts accompanying this license ("Fonts") and associated
|
|
||||||
documentation files (the "Font Software"), to reproduce and distribute
|
|
||||||
the Font Software, including without limitation the rights to use,
|
|
||||||
copy, merge, publish, distribute, and/or sell copies of the Font
|
|
||||||
Software, and to permit persons to whom the Font Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright and trademark notices and this permission notice
|
|
||||||
shall be included in all copies of one or more of the Font Software
|
|
||||||
typefaces.
|
|
||||||
|
|
||||||
The Font Software may be modified, altered, or added to, and in
|
|
||||||
particular the designs of glyphs or characters in the Fonts may be
|
|
||||||
modified and additional glyphs or characters may be added to the
|
|
||||||
Fonts, only if the fonts are renamed to names not containing either
|
|
||||||
the words "Bitstream" or the word "Vera".
|
|
||||||
|
|
||||||
This License becomes null and void to the extent applicable to Fonts
|
|
||||||
or Font Software that has been modified and is distributed under the
|
|
||||||
"Bitstream Vera" names.
|
|
||||||
|
|
||||||
The Font Software may be sold as part of a larger software package but
|
|
||||||
no copy of one or more of the Font Software typefaces may be sold by
|
|
||||||
itself.
|
|
||||||
|
|
||||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
||||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
|
||||||
BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
||||||
OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL,
|
|
||||||
OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
|
|
||||||
SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
||||||
|
|
||||||
Except as contained in this notice, the names of Gnome, the Gnome
|
|
||||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
|
||||||
otherwise to promote the sale, use or other dealings in this Font
|
|
||||||
Software without prior written authorization from the Gnome Foundation
|
|
||||||
or Bitstream Inc., respectively. For further information, contact:
|
|
||||||
fonts at gnome dot org.
|
|
||||||
|
|
||||||
Copyright FAQ
|
|
||||||
=============
|
|
||||||
|
|
||||||
1. I don't understand the resale restriction... What gives?
|
|
||||||
|
|
||||||
Bitstream is giving away these fonts, but wishes to ensure its
|
|
||||||
competitors can't just drop the fonts as is into a font sale system
|
|
||||||
and sell them as is. It seems fair that if Bitstream can't make money
|
|
||||||
from the Bitstream Vera fonts, their competitors should not be able to
|
|
||||||
do so either. You can sell the fonts as part of any software package,
|
|
||||||
however.
|
|
||||||
|
|
||||||
2. I want to package these fonts separately for distribution and
|
|
||||||
sale as part of a larger software package or system. Can I do so?
|
|
||||||
|
|
||||||
Yes. A RPM or Debian package is a "larger software package" to begin
|
|
||||||
with, and you aren't selling them independently by themselves.
|
|
||||||
See 1. above.
|
|
||||||
|
|
||||||
3. Are derivative works allowed?
|
|
||||||
Yes!
|
|
||||||
|
|
||||||
4. Can I change or add to the font(s)?
|
|
||||||
Yes, but you must change the name(s) of the font(s).
|
|
||||||
|
|
||||||
5. Under what terms are derivative works allowed?
|
|
||||||
|
|
||||||
You must change the name(s) of the fonts. This is to ensure the
|
|
||||||
quality of the fonts, both to protect Bitstream and Gnome. We want to
|
|
||||||
ensure that if an application has opened a font specifically of these
|
|
||||||
names, it gets what it expects (though of course, using fontconfig,
|
|
||||||
substitutions could still could have occurred during font
|
|
||||||
opening). You must include the Bitstream copyright. Additional
|
|
||||||
copyrights can be added, as per copyright law. Happy Font Hacking!
|
|
||||||
|
|
||||||
6. If I have improvements for Bitstream Vera, is it possible they might get
|
|
||||||
adopted in future versions?
|
|
||||||
|
|
||||||
Yes. The contract between the Gnome Foundation and Bitstream has
|
|
||||||
provisions for working with Bitstream to ensure quality additions to
|
|
||||||
the Bitstream Vera font family. Please contact us if you have such
|
|
||||||
additions. Note, that in general, we will want such additions for the
|
|
||||||
entire family, not just a single font, and that you'll have to keep
|
|
||||||
both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add
|
|
||||||
glyphs to the font, they must be stylistically in keeping with Vera's
|
|
||||||
design. Vera cannot become a "ransom note" font. Jim Lyles will be
|
|
||||||
providing a document describing the design elements used in Vera, as a
|
|
||||||
guide and aid for people interested in contributing to Vera.
|
|
||||||
|
|
||||||
7. I want to sell a software package that uses these fonts: Can I do so?
|
|
||||||
|
|
||||||
Sure. Bundle the fonts with your software and sell your software
|
|
||||||
with the fonts. That is the intent of the copyright.
|
|
||||||
|
|
||||||
8. If applications have built the names "Bitstream Vera" into them,
|
|
||||||
can I override this somehow to use fonts of my choosing?
|
|
||||||
|
|
||||||
This depends on exact details of the software. Most open source
|
|
||||||
systems and software (e.g., Gnome, KDE, etc.) are now converting to
|
|
||||||
use fontconfig (see www.fontconfig.org) to handle font configuration,
|
|
||||||
selection and substitution; it has provisions for overriding font
|
|
||||||
names and subsituting alternatives. An example is provided by the
|
|
||||||
supplied local.conf file, which chooses the family Bitstream Vera for
|
|
||||||
"sans", "serif" and "monospace". Other software (e.g., the XFree86
|
|
||||||
core server) has other mechanisms for font substitution.
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,10 +0,0 @@
|
||||||
size
|
|
||||||
7 7
|
|
||||||
map
|
|
||||||
2 2 2 2 2 2 2
|
|
||||||
2 0 0 0 0 0 2
|
|
||||||
2 0 0 1 0 0 2
|
|
||||||
2 0 0 1 1 0 2
|
|
||||||
2 1 1 2 2 2 2
|
|
||||||
2 0 0 0 0 0 2
|
|
||||||
2 2 2 2 2 2 2
|
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef AUDIO_H
|
#pragma once
|
||||||
#define AUDIO_H
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -23,11 +22,8 @@ private:
|
||||||
sf::Sound sound;
|
sf::Sound sound;
|
||||||
};
|
};
|
||||||
|
|
||||||
using SfMusicPtr = std::unique_ptr<sf::Music>;
|
std::array<std::unique_ptr<SoundEffect>, N_SOUNDS> array_sounds;
|
||||||
using SoundEffectPtr = std::unique_ptr<SoundEffect>;
|
std::unique_ptr<sf::Music> background_music;
|
||||||
|
|
||||||
std::array<SoundEffectPtr, N_SOUNDS> array_sounds;
|
|
||||||
SfMusicPtr background_music;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Audio(const std::string &background_file_name, std::array<std::string, N_SOUNDS> &&sounds_paths);
|
Audio(const std::string &background_file_name, std::array<std::string, N_SOUNDS> &&sounds_paths);
|
||||||
|
@ -41,7 +37,3 @@ public:
|
||||||
void pauseBackground();
|
void pauseBackground();
|
||||||
void setBackgroundVolume(const float &volume);
|
void setBackgroundVolume(const float &volume);
|
||||||
};
|
};
|
||||||
|
|
||||||
using AudioPtr = std::unique_ptr<Audio>;
|
|
||||||
|
|
||||||
#endif // AUDIO_H
|
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef CELL_H
|
#pragma once
|
||||||
#define CELL_H
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -39,10 +38,6 @@ class Hero;
|
||||||
class Level;
|
class Level;
|
||||||
class Cell;
|
class Cell;
|
||||||
|
|
||||||
using HeroPtr = std::unique_ptr<Hero>;
|
|
||||||
using LevelPtr = std::unique_ptr<Level>;
|
|
||||||
using CellPtr = std::unique_ptr<Cell>;
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
/// Represents interface for all level cells
|
/// Represents interface for all level cells
|
||||||
|
@ -67,9 +62,9 @@ public:
|
||||||
coordinate heightShift() const;
|
coordinate heightShift() const;
|
||||||
|
|
||||||
/// Determine if Hero can move onto this cell or not
|
/// Determine if Hero can move onto this cell or not
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) = 0;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) = 0;
|
||||||
|
|
||||||
virtual CellPtr clone() const = 0;
|
virtual std::unique_ptr<Cell> clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -84,9 +79,9 @@ public:
|
||||||
|
|
||||||
virtual ~PassableCell() override;
|
virtual ~PassableCell() override;
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -101,9 +96,9 @@ public:
|
||||||
|
|
||||||
virtual ~WaterCell() override;
|
virtual ~WaterCell() override;
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -118,9 +113,9 @@ public:
|
||||||
|
|
||||||
virtual ~WallCell() override;
|
virtual ~WallCell() override;
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -142,9 +137,9 @@ public:
|
||||||
|
|
||||||
virtual ~ChargeCell() override;
|
virtual ~ChargeCell() override;
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -159,9 +154,9 @@ public:
|
||||||
|
|
||||||
virtual ~ExitCell() override;
|
virtual ~ExitCell() override;
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -184,9 +179,9 @@ public:
|
||||||
/// Set the coordinates of this teleport destination
|
/// Set the coordinates of this teleport destination
|
||||||
void setDestination(coordinate new_cell_row, coordinate new_cell_col);
|
void setDestination(coordinate new_cell_row, coordinate new_cell_col);
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
@ -196,7 +191,7 @@ class TriggerCell final : public Cell
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Vector of cells to place on map
|
// Vector of cells to place on map
|
||||||
std::vector<CellPtr> vector_cells;
|
std::vector<std::unique_ptr<Cell>> vector_cells;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TriggerCell(coordinate cell_row = 0,
|
TriggerCell(coordinate cell_row = 0,
|
||||||
|
@ -206,11 +201,9 @@ public:
|
||||||
virtual ~TriggerCell() override;
|
virtual ~TriggerCell() override;
|
||||||
|
|
||||||
/// Add a cell which has to be placed to map when the trigger gets activated
|
/// Add a cell which has to be placed to map when the trigger gets activated
|
||||||
void addTarget(CellPtr &&cell);
|
void addTarget(std::unique_ptr<Cell> &&cell);
|
||||||
|
|
||||||
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
|
virtual bool onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level) override;
|
||||||
|
|
||||||
virtual CellPtr clone() const override;
|
virtual std::unique_ptr<Cell> clone() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CELL_H
|
|
|
@ -15,9 +15,9 @@ class Game
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Game entities
|
// Game entities
|
||||||
HeroPtr hero;
|
std::unique_ptr<Hero> hero;
|
||||||
LevelPtr level;
|
std::unique_ptr<Level> level;
|
||||||
AudioPtr audio;
|
std::unique_ptr<Audio> audio;
|
||||||
std::unique_ptr<Renderer> renderer; // wer is `using RendererPrt = ...` A?A?A?
|
std::unique_ptr<Renderer> renderer; // wer is `using RendererPrt = ...` A?A?A?
|
||||||
|
|
||||||
int current_level;
|
int current_level;
|
|
@ -18,7 +18,7 @@ class Level
|
||||||
private:
|
private:
|
||||||
struct Map
|
struct Map
|
||||||
{
|
{
|
||||||
using Row = std::vector<CellPtr>;
|
using Row = std::vector<std::unique_ptr<Cell>>;
|
||||||
using Matrix = std::vector<Row>;
|
using Matrix = std::vector<Row>;
|
||||||
|
|
||||||
enum class SECTION
|
enum class SECTION
|
||||||
|
@ -43,7 +43,7 @@ private:
|
||||||
|
|
||||||
Matrix data;
|
Matrix data;
|
||||||
size_t rows, cols;
|
size_t rows, cols;
|
||||||
std::array<CellPtr, N_CELLS> default_cells;
|
std::array<std::unique_ptr<Cell>, N_CELLS> default_cells;
|
||||||
|
|
||||||
void init(const std::string &path = default_file_path);
|
void init(const std::string &path = default_file_path);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
size_t cols() const;
|
size_t cols() const;
|
||||||
|
|
||||||
/// Get cell at position row, col
|
/// Get cell at position row, col
|
||||||
CellPtr &getCellAt(coordinate row, coordinate col);
|
std::unique_ptr<Cell> &getCellAt(coordinate row, coordinate col);
|
||||||
|
|
||||||
/// Place a bridge cell
|
/// Place a bridge cell
|
||||||
void placeBridge(coordinate x, coordinate y);
|
void placeBridge(coordinate x, coordinate y);
|
|
@ -7,6 +7,8 @@
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Level;
|
class Level;
|
||||||
class Cell;
|
class Cell;
|
||||||
class Hero;
|
class Hero;
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Audio::Audio(const std::string &background_path, std::array<std::string, N_SOUNDS> &&sounds_paths)
|
Audio::Audio(const std::string &background_path, std::array<std::string, N_SOUNDS> &&sounds_paths)
|
||||||
{
|
{
|
||||||
SfMusicPtr music = std::make_unique<sf::Music>();
|
std::unique_ptr<sf::Music> music = std::make_unique<sf::Music>();
|
||||||
if (music->openFromFile(background_path))
|
if (music->openFromFile(background_path))
|
||||||
music->setLoop(true);
|
music->setLoop(true);
|
||||||
else
|
else
|
||||||
|
@ -10,7 +10,7 @@ Audio::Audio(const std::string &background_path, std::array<std::string, N_SOUND
|
||||||
|
|
||||||
background_music = std::move(music);
|
background_music = std::move(music);
|
||||||
|
|
||||||
SoundEffectPtr effect;
|
std::unique_ptr<SoundEffect> effect;
|
||||||
for (int i = 0; i < N_SOUNDS; ++i)
|
for (int i = 0; i < N_SOUNDS; ++i)
|
||||||
{
|
{
|
||||||
effect = std::make_unique<SoundEffect>();
|
effect = std::make_unique<SoundEffect>();
|
||||||
|
@ -28,7 +28,7 @@ Audio::Audio(const std::string &background_path, std::array<std::string, N_SOUND
|
||||||
|
|
||||||
bool Audio::setSound(const SOUND_TYPE &type, const std::string &sound_file_path)
|
bool Audio::setSound(const SOUND_TYPE &type, const std::string &sound_file_path)
|
||||||
{
|
{
|
||||||
SoundEffectPtr effect = std::make_unique<SoundEffect>();
|
std::unique_ptr<SoundEffect> effect = std::make_unique<SoundEffect>();
|
||||||
|
|
||||||
if (!effect->buffer.loadFromFile(sound_file_path))
|
if (!effect->buffer.loadFromFile(sound_file_path))
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,12 +41,13 @@ bool Audio::setSound(const SOUND_TYPE &type, const std::string &sound_file_path)
|
||||||
|
|
||||||
void Audio::playSound(const SOUND_TYPE &type)
|
void Audio::playSound(const SOUND_TYPE &type)
|
||||||
{
|
{
|
||||||
|
if (array_sounds[type])
|
||||||
array_sounds[type]->sound.play();
|
array_sounds[type]->sound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Audio::setBackground(const std::string &music_file_path)
|
bool Audio::setBackground(const std::string &music_file_path)
|
||||||
{
|
{
|
||||||
SfMusicPtr music = std::make_unique<sf::Music>();
|
std::unique_ptr<sf::Music> music = std::make_unique<sf::Music>();
|
||||||
|
|
||||||
if (!music->openFromFile(music_file_path))
|
if (!music->openFromFile(music_file_path))
|
||||||
return false;
|
return false;
|
||||||
|
@ -57,20 +58,24 @@ bool Audio::setBackground(const std::string &music_file_path)
|
||||||
|
|
||||||
void Audio::playBackground()
|
void Audio::playBackground()
|
||||||
{
|
{
|
||||||
|
if (background_music)
|
||||||
background_music->play();
|
background_music->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::stopBackground()
|
void Audio::stopBackground()
|
||||||
{
|
{
|
||||||
|
if (background_music)
|
||||||
background_music->stop();
|
background_music->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::pauseBackground()
|
void Audio::pauseBackground()
|
||||||
{
|
{
|
||||||
|
if (background_music)
|
||||||
background_music->pause();
|
background_music->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::setBackgroundVolume(const float &volume)
|
void Audio::setBackgroundVolume(const float &volume)
|
||||||
{
|
{
|
||||||
|
if (background_music)
|
||||||
background_music->setVolume(volume);
|
background_music->setVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
32
src/cell.cpp
32
src/cell.cpp
|
@ -38,7 +38,7 @@ PassableCell::PassableCell(coordinate cell_row, coordinate cell_col, const sf::C
|
||||||
PassableCell::~PassableCell()
|
PassableCell::~PassableCell()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool PassableCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool PassableCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
UNUSED(hero), UNUSED(level);
|
UNUSED(hero), UNUSED(level);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ bool PassableCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr PassableCell::clone() const
|
std::unique_ptr<Cell> PassableCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<PassableCell>();
|
return std::make_unique<PassableCell>();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ WaterCell::WaterCell(coordinate cell_row, coordinate cell_col, const sf::Color &
|
||||||
WaterCell::~WaterCell()
|
WaterCell::~WaterCell()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool WaterCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool WaterCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
// Try to use one charge to place a bridge
|
// Try to use one charge to place a bridge
|
||||||
if (hero->useCharge())
|
if (hero->useCharge())
|
||||||
|
@ -69,7 +69,7 @@ bool WaterCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr WaterCell::clone() const
|
std::unique_ptr<Cell> WaterCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<WaterCell>();
|
return std::make_unique<WaterCell>();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ WallCell::WallCell(coordinate cell_row, coordinate cell_col, const sf::Color &co
|
||||||
WallCell::~WallCell()
|
WallCell::~WallCell()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool WallCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool WallCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
UNUSED(hero), UNUSED(level);
|
UNUSED(hero), UNUSED(level);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ bool WallCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr WallCell::clone() const
|
std::unique_ptr<Cell> WallCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<WallCell>();
|
return std::make_unique<WallCell>();
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ void ChargeCell::setCharges(const int &num_charges)
|
||||||
cell_charges = num_charges;
|
cell_charges = num_charges;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChargeCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool ChargeCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
// Hero picks up the charge; remove it from the map
|
// Hero picks up the charge; remove it from the map
|
||||||
hero->refillCharges(cell_charges);
|
hero->refillCharges(cell_charges);
|
||||||
|
@ -125,7 +125,7 @@ bool ChargeCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr ChargeCell::clone() const
|
std::unique_ptr<Cell> ChargeCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<ChargeCell>();
|
return std::make_unique<ChargeCell>();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ ExitCell::ExitCell(coordinate cell_row, coordinate cell_col, const sf::Color &co
|
||||||
ExitCell::~ExitCell()
|
ExitCell::~ExitCell()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool ExitCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool ExitCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
UNUSED(level);
|
UNUSED(level);
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ bool ExitCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr ExitCell::clone() const
|
std::unique_ptr<Cell> ExitCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<ExitCell>();
|
return std::make_unique<ExitCell>();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void TeleportCell::setDestination(coordinate new_cell_row, coordinate new_cell_c
|
||||||
new_col = new_cell_col;
|
new_col = new_cell_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TeleportCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool TeleportCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
UNUSED(level);
|
UNUSED(level);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ bool TeleportCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr TeleportCell::clone() const
|
std::unique_ptr<Cell> TeleportCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<TeleportCell>();
|
return std::make_unique<TeleportCell>();
|
||||||
}
|
}
|
||||||
|
@ -196,17 +196,17 @@ TriggerCell::TriggerCell(coordinate cell_row, coordinate cell_col, const sf::Col
|
||||||
TriggerCell::~TriggerCell()
|
TriggerCell::~TriggerCell()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void TriggerCell::addTarget(CellPtr &&cell)
|
void TriggerCell::addTarget(std::unique_ptr<Cell> &&cell)
|
||||||
{
|
{
|
||||||
vector_cells.emplace_back(std::move(cell));
|
vector_cells.emplace_back(std::move(cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TriggerCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
bool TriggerCell::onMovingTo(std::unique_ptr<Hero> &hero, std::unique_ptr<Level> &level)
|
||||||
{
|
{
|
||||||
UNUSED(hero);
|
UNUSED(hero);
|
||||||
|
|
||||||
// We replace needed cells with the ones that the trigger provides.
|
// We replace needed cells with the ones that the trigger provides.
|
||||||
for (CellPtr &cell : vector_cells)
|
for (std::unique_ptr<Cell> &cell : vector_cells)
|
||||||
{
|
{
|
||||||
const coordinate &row = cell->row();
|
const coordinate &row = cell->row();
|
||||||
const coordinate &col = cell->col();
|
const coordinate &col = cell->col();
|
||||||
|
@ -221,7 +221,7 @@ bool TriggerCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr TriggerCell::clone() const
|
std::unique_ptr<Cell> TriggerCell::clone() const
|
||||||
{
|
{
|
||||||
return std::make_unique<TriggerCell>();
|
return std::make_unique<TriggerCell>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,123 +0,0 @@
|
||||||
Bitstream Vera Fonts Copyright
|
|
||||||
|
|
||||||
The fonts have a generous copyright, allowing derivative works (as
|
|
||||||
long as "Bitstream" or "Vera" are not in the names), and full
|
|
||||||
redistribution (so long as they are not *sold* by themselves). They
|
|
||||||
can be be bundled, redistributed and sold with any software.
|
|
||||||
|
|
||||||
The fonts are distributed under the following copyright:
|
|
||||||
|
|
||||||
Copyright
|
|
||||||
=========
|
|
||||||
|
|
||||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream
|
|
||||||
Vera is a trademark of Bitstream, Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of the fonts accompanying this license ("Fonts") and associated
|
|
||||||
documentation files (the "Font Software"), to reproduce and distribute
|
|
||||||
the Font Software, including without limitation the rights to use,
|
|
||||||
copy, merge, publish, distribute, and/or sell copies of the Font
|
|
||||||
Software, and to permit persons to whom the Font Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright and trademark notices and this permission notice
|
|
||||||
shall be included in all copies of one or more of the Font Software
|
|
||||||
typefaces.
|
|
||||||
|
|
||||||
The Font Software may be modified, altered, or added to, and in
|
|
||||||
particular the designs of glyphs or characters in the Fonts may be
|
|
||||||
modified and additional glyphs or characters may be added to the
|
|
||||||
Fonts, only if the fonts are renamed to names not containing either
|
|
||||||
the words "Bitstream" or the word "Vera".
|
|
||||||
|
|
||||||
This License becomes null and void to the extent applicable to Fonts
|
|
||||||
or Font Software that has been modified and is distributed under the
|
|
||||||
"Bitstream Vera" names.
|
|
||||||
|
|
||||||
The Font Software may be sold as part of a larger software package but
|
|
||||||
no copy of one or more of the Font Software typefaces may be sold by
|
|
||||||
itself.
|
|
||||||
|
|
||||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
||||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
|
||||||
BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
||||||
OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL,
|
|
||||||
OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
|
|
||||||
SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
||||||
|
|
||||||
Except as contained in this notice, the names of Gnome, the Gnome
|
|
||||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
|
||||||
otherwise to promote the sale, use or other dealings in this Font
|
|
||||||
Software without prior written authorization from the Gnome Foundation
|
|
||||||
or Bitstream Inc., respectively. For further information, contact:
|
|
||||||
fonts at gnome dot org.
|
|
||||||
|
|
||||||
Copyright FAQ
|
|
||||||
=============
|
|
||||||
|
|
||||||
1. I don't understand the resale restriction... What gives?
|
|
||||||
|
|
||||||
Bitstream is giving away these fonts, but wishes to ensure its
|
|
||||||
competitors can't just drop the fonts as is into a font sale system
|
|
||||||
and sell them as is. It seems fair that if Bitstream can't make money
|
|
||||||
from the Bitstream Vera fonts, their competitors should not be able to
|
|
||||||
do so either. You can sell the fonts as part of any software package,
|
|
||||||
however.
|
|
||||||
|
|
||||||
2. I want to package these fonts separately for distribution and
|
|
||||||
sale as part of a larger software package or system. Can I do so?
|
|
||||||
|
|
||||||
Yes. A RPM or Debian package is a "larger software package" to begin
|
|
||||||
with, and you aren't selling them independently by themselves.
|
|
||||||
See 1. above.
|
|
||||||
|
|
||||||
3. Are derivative works allowed?
|
|
||||||
Yes!
|
|
||||||
|
|
||||||
4. Can I change or add to the font(s)?
|
|
||||||
Yes, but you must change the name(s) of the font(s).
|
|
||||||
|
|
||||||
5. Under what terms are derivative works allowed?
|
|
||||||
|
|
||||||
You must change the name(s) of the fonts. This is to ensure the
|
|
||||||
quality of the fonts, both to protect Bitstream and Gnome. We want to
|
|
||||||
ensure that if an application has opened a font specifically of these
|
|
||||||
names, it gets what it expects (though of course, using fontconfig,
|
|
||||||
substitutions could still could have occurred during font
|
|
||||||
opening). You must include the Bitstream copyright. Additional
|
|
||||||
copyrights can be added, as per copyright law. Happy Font Hacking!
|
|
||||||
|
|
||||||
6. If I have improvements for Bitstream Vera, is it possible they might get
|
|
||||||
adopted in future versions?
|
|
||||||
|
|
||||||
Yes. The contract between the Gnome Foundation and Bitstream has
|
|
||||||
provisions for working with Bitstream to ensure quality additions to
|
|
||||||
the Bitstream Vera font family. Please contact us if you have such
|
|
||||||
additions. Note, that in general, we will want such additions for the
|
|
||||||
entire family, not just a single font, and that you'll have to keep
|
|
||||||
both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add
|
|
||||||
glyphs to the font, they must be stylistically in keeping with Vera's
|
|
||||||
design. Vera cannot become a "ransom note" font. Jim Lyles will be
|
|
||||||
providing a document describing the design elements used in Vera, as a
|
|
||||||
guide and aid for people interested in contributing to Vera.
|
|
||||||
|
|
||||||
7. I want to sell a software package that uses these fonts: Can I do so?
|
|
||||||
|
|
||||||
Sure. Bundle the fonts with your software and sell your software
|
|
||||||
with the fonts. That is the intent of the copyright.
|
|
||||||
|
|
||||||
8. If applications have built the names "Bitstream Vera" into them,
|
|
||||||
can I override this somehow to use fonts of my choosing?
|
|
||||||
|
|
||||||
This depends on exact details of the software. Most open source
|
|
||||||
systems and software (e.g., Gnome, KDE, etc.) are now converting to
|
|
||||||
use fontconfig (see www.fontconfig.org) to handle font configuration,
|
|
||||||
selection and substitution; it has provisions for overriding font
|
|
||||||
names and subsituting alternatives. An example is provided by the
|
|
||||||
supplied local.conf file, which chooses the family Bitstream Vera for
|
|
||||||
"sans", "serif" and "monospace". Other software (e.g., the XFree86
|
|
||||||
core server) has other mechanisms for font substitution.
|
|
Binary file not shown.
|
@ -169,7 +169,7 @@ size_t Level::cols() const
|
||||||
return map.cols;
|
return map.cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPtr &Level::getCellAt(coordinate row, coordinate col)
|
std::unique_ptr<Cell> &Level::getCellAt(coordinate row, coordinate col)
|
||||||
{
|
{
|
||||||
return map.data[row][col];
|
return map.data[row][col];
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ Renderer::Renderer() :
|
||||||
vertical_shift(0),
|
vertical_shift(0),
|
||||||
horizontal_shift(0)
|
horizontal_shift(0)
|
||||||
{
|
{
|
||||||
font.loadFromFile("font/VeraMono.ttf");
|
font.loadFromFile("resources/font/VeraMono.ttf");
|
||||||
text_charges.setFont(font);
|
text_charges.setFont(font);
|
||||||
text_charges.setFillColor(palette::White);
|
text_charges.setFillColor(palette::White);
|
||||||
text_charges.setCharacterSize(25);
|
text_charges.setCharacterSize(25);
|
||||||
|
@ -43,7 +43,7 @@ Renderer::Renderer() :
|
||||||
brush_wall.setOutlineThickness(0);
|
brush_wall.setOutlineThickness(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::drawCell(const CellPtr &cell, sf::RenderWindow &main_window)
|
bool Renderer::drawCell(const std::unique_ptr<Cell> &cell, sf::RenderWindow &main_window)
|
||||||
{
|
{
|
||||||
vertical_shift = static_cast<float>(cell->heightShift());
|
vertical_shift = static_cast<float>(cell->heightShift());
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ bool Renderer::drawCell(const CellPtr &cell, sf::RenderWindow &main_window)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::render(const LevelPtr &level, const HeroPtr &hero, sf::RenderWindow &main_window)
|
bool Renderer::render(const std::unique_ptr<Level> &level, const std::unique_ptr<Hero> &hero, sf::RenderWindow &main_window)
|
||||||
{
|
{
|
||||||
if (!hero || !level)
|
if (!hero || !level)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
TEMPLATE = app
|
|
||||||
CONFIG += c++17
|
|
||||||
CONFIG -= console app_bundle
|
|
||||||
CONFIG -= qt
|
|
||||||
|
|
||||||
QMAKE_CXXFLAGS = -Wall -Werror -Wextra -Wpedantic -Wconversion -std=c++17 -O0 -g
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
audio.cpp \
|
|
||||||
cell.cpp \
|
|
||||||
entity.cpp \
|
|
||||||
game.cpp \
|
|
||||||
hero.cpp \
|
|
||||||
level.cpp \
|
|
||||||
main.cpp \
|
|
||||||
renderer.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
audio.h \
|
|
||||||
cell.h \
|
|
||||||
entity.h \
|
|
||||||
game.h \
|
|
||||||
hero.h \
|
|
||||||
level.h \
|
|
||||||
renderer.h
|
|
||||||
|
|
||||||
# Only to highlight syntax when I am on Windows
|
|
||||||
win32:INCLUDEPATH += d:\SFML-2.5.1\include
|
|
||||||
|
|
||||||
LIBS += -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system
|
|
Loading…
Reference in New Issue