Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1

Merged
merged 62 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9cec635
Create basic build system using cmake.
Tastyep Mar 3, 2021
1c52b1e
Define a .clang-tidy file.
Tastyep Mar 3, 2021
8931ab5
Add the default generated .clang-format file.
Tastyep Mar 3, 2021
d143d52
Add support for compiling with ccache.
Tastyep Mar 3, 2021
d400fd8
Set compiler flags.
Tastyep Mar 3, 2021
c89d402
Prevent in source builds.
Tastyep Mar 3, 2021
f9dffb0
Add sanitizer support
Tastyep Mar 3, 2021
d9de119
Add doxygen support
Tastyep Mar 3, 2021
bd55232
Add support for static analyzers
Tastyep Mar 3, 2021
fcae42c
Add the formatting target
Tastyep Mar 3, 2021
7eea6bb
Set up dependency management using Conan
Tastyep Mar 4, 2021
0cc35d7
Set a default project configuration (RelWithDebInfo)
Tastyep Mar 4, 2021
f291ace
Fix finding of SFML libraries.
Tastyep Mar 4, 2021
f86667c
Format cmake files using cmake-format
Tastyep Mar 4, 2021
9e0ccf0
Use conan to fetch SFML and Imgui-SFML dependencies
Tastyep Mar 4, 2021
3c56205
Encapsulate the window object.
Tastyep Mar 6, 2021
88063ed
Add a SFML event convertor
Tastyep Mar 6, 2021
24c86b2
Implement a FPS based game loop
Tastyep Mar 6, 2021
39eeeee
Add action definitions
Tastyep Mar 7, 2021
3711206
Convert interface events to actions
Tastyep Mar 7, 2021
018094a
Move Timepoint and Clock concept away from the gamestate
Tastyep Mar 9, 2021
f1926eb
Implement the tile parser
Tastyep Mar 9, 2021
4e01797
Import entt (build system)
Tastyep Mar 9, 2021
88a7aba
Define the entity factory and their components.
Tastyep Mar 9, 2021
493528b
Define the View concept
Tastyep Mar 9, 2021
45d3170
Implement the game view
Tastyep Mar 9, 2021
f666c67
Implement the FPS view
Tastyep Mar 9, 2021
ca31b59
Implement a basic map parser
Tastyep Mar 9, 2021
faadec2
Define a Timer object
Tastyep Mar 10, 2021
552abaf
Add the tmxlite dependency to the build system
Tastyep Mar 11, 2021
37a5828
Improve the interface of the tile loader
Tastyep Mar 11, 2021
daae2a1
Store views with shared instead of unique ptrs
Tastyep Mar 11, 2021
97166e7
Implement the map object
Tastyep Mar 11, 2021
031d9ec
Refactor components into graphical and physical categories
Tastyep Mar 12, 2021
770ac6f
Provide calculus operator overloads for Vector2
Tastyep Mar 12, 2021
1a1f32f
Implement basic motion support
Tastyep Mar 12, 2021
e995437
Provide a ActionCode to Action factory function
Tastyep Mar 13, 2021
1b08163
Add support for key released events
Tastyep Mar 13, 2021
a707f7d
Implement the event controller
Tastyep Mar 13, 2021
7339997
Implement the controller mapper
Tastyep Mar 19, 2021
889b6dc
Provide names for actions and keys
Tastyep Mar 19, 2021
598abe8
Implement the control view
Tastyep Mar 19, 2021
f61a76d
Switch to fixed timestep and unlimited FPS
Tastyep Mar 27, 2021
f7f818b
Add collision shape definitions
Tastyep Mar 28, 2021
9882603
Add PlayRho build dependency
Tastyep Mar 28, 2021
e9d5f2c
Convert the tile ID to entity ID
Tastyep Mar 29, 2021
86ffc47
Use std::holds_alternative when handling a single type
Tastyep Apr 1, 2021
1895ec7
Implement the shape config manager
Tastyep Apr 1, 2021
fdf46d2
Parse bounding boxes from the map
Tastyep Apr 1, 2021
b43bfd1
Add pixel <-> meter convertion functions
Tastyep Apr 1, 2021
a045afd
Rewrite existing components to carry playrho body info
Tastyep Apr 1, 2021
bc30079
Update the gameview following components update
Tastyep Apr 1, 2021
5f98b65
Apply basic transformations on the simulated bodies
Tastyep Apr 1, 2021
7cc3909
Implement a BoudingBox view
Tastyep Apr 1, 2021
61268cf
Update object initializations
Tastyep Apr 1, 2021
dccbce9
Load walls as entities
Tastyep Apr 3, 2021
624b208
Use playrho to apply angular and linear forces
Tastyep Apr 6, 2021
fcf4bc7
Change storage of tiles from sf::Sprite to Tile
Tastyep Apr 6, 2021
bfa5e9f
Draw map tiles using vertex arrays
Tastyep Apr 6, 2021
3743c70
Update style (clang format & tidy files).
Tastyep Jun 2, 2021
8915fa9
Draw sprites in a tile layer
Tastyep Jun 2, 2021
2089304
Define a basic map with the required tile resources.
Tastyep Jun 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the interface of the tile loader
Allow the loader to support multiple tilesets with tiles of different
size
  • Loading branch information
Tastyep committed Mar 11, 2021
commit 37a5828b08159d800285d75779708e4e21685b90
1 change: 1 addition & 0 deletions include/domain/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct Vector2D {
};

using Vector2i = Vector2D<int>;
using Vector2u = Vector2D<unsigned int>;

} // namespace Domain

Expand Down
6 changes: 3 additions & 3 deletions include/interface/Tile.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef INTERFACE_TILE_HPP
#define INTERFACE_TILE_HPP

#include "domain/Shape.hpp"
#include "domain/Sprite.hpp"
#include "domain/Vector.hpp"
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <memory>
Expand All @@ -13,8 +13,8 @@ namespace Interface {

class TileManager {
public:
void load(const std::string &path, const Domain::IntRect &textureRect,
int tileSize);
bool load(const std::string &path, const Domain::Vector2u &tileSize,
unsigned int tileCount, unsigned int columnCount);

const sf::Sprite &get(Domain::Sprite::ID spriteId) const;

Expand Down
24 changes: 16 additions & 8 deletions src/interface/Tile.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
#include "interface/Tile.hpp"
#include "domain/Vector.hpp"
#include <SFML/Graphics/Rect.hpp>

namespace Interface {

void TileManager::load(const std::string & path,
const Domain::IntRect &textureRect, int tileSize) {
bool TileManager::load(const std::string & path,
const Domain::Vector2u &tileSize, unsigned int tileCount,
unsigned int columnCount) {
auto texture = std::make_unique<sf::Texture>();

if (!texture->loadFromFile(path, {textureRect.left, textureRect.top,
textureRect.width, textureRect.height})) {
// Throw exception
if (!texture->loadFromFile(path)) {
return false;
}

for (int y = 0; y < textureRect.height; y += tileSize) {
for (int x = 0; x < textureRect.width; x += tileSize) {
_sprites.emplace_back(*texture, sf::IntRect{x, y, tileSize, tileSize});
const auto rowCount = tileCount / columnCount;
for (unsigned int y = 0; y < rowCount; ++y) {
for (unsigned int x = 0; x < columnCount; ++x) {
_sprites.emplace_back(*texture, sf::IntRect{
static_cast<int>(x * tileSize.x),
static_cast<int>(y * tileSize.y),
static_cast<int>(tileSize.x),
static_cast<int>(tileSize.y),
});
}
}

_textures.push_back(std::move(texture));
return true;
}

const sf::Sprite &TileManager::get(Domain::Sprite::ID spriteId) const {
Expand Down