Fix warnings
This commit is contained in:
parent
d4ae224a67
commit
d3cc1d90c7
7 changed files with 15 additions and 17 deletions
|
@ -1 +1 @@
|
|||
Checks: 'modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type,cppcoreguidelines-*,bugprone-*,-cppcoreguidelines-non-private-member-variables-in-classes'
|
||||
Checks: 'modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type,cppcoreguidelines-*,bugprone-*,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-magic-numbers'
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/toolchain.cmake")
|
||||
|
||||
find_package(Git QUIET)
|
||||
if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
# Update submodules as needed
|
||||
|
@ -28,6 +26,8 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/
|
|||
enable_language(CXX)
|
||||
project(pacman)
|
||||
|
||||
include(cmake/toolchain.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
add_subdirectory(scaling-lib)
|
||||
|
|
|
@ -13,9 +13,7 @@ else()
|
|||
add_link_options("$<$<CONFIG:DEBUG>:-fsanitize=address>")
|
||||
endif()
|
||||
|
||||
|
||||
#enable ubsan in debug
|
||||
|
||||
if(NOT MSVC)
|
||||
add_compile_options("$<$<CONFIG:DEBUG>:-fsanitize=undefined>"
|
||||
"$<$<CONFIG:DEBUG>:-fno-omit-frame-pointer>")
|
|
@ -8,10 +8,10 @@
|
|||
namespace pacman {
|
||||
|
||||
Canvas::Canvas()
|
||||
: window(sf::VideoMode((viewDimensions().width / 2.0), (viewDimensions().height / 2.0)),
|
||||
: window(sf::VideoMode((viewDimensions().width / 2), (viewDimensions().height / 2)),
|
||||
"Pacman",
|
||||
sf::Style::Titlebar | sf::Style::Close),
|
||||
view(sf::FloatRect(0, 0, viewDimensions().width, viewDimensions().height)) {
|
||||
view(sf::FloatRect(0, 0, float(viewDimensions().width), float(viewDimensions().height))) {
|
||||
|
||||
window.setView(view);
|
||||
window.setFramerateLimit(60);
|
||||
|
@ -21,9 +21,9 @@ Canvas::Canvas()
|
|||
// Then project it on a scaled window - on some mac we get the
|
||||
// scaling factor of the window to adjust the resolution
|
||||
const auto scale = scaling_factor_for_window(window.getSystemHandle());
|
||||
const auto width = viewDimensions().width / 2.0 * scale;
|
||||
const auto height = viewDimensions().height / 2.0 * scale;
|
||||
window.setSize(sf::Vector2u(width, height));
|
||||
const auto width = (viewDimensions().width / 2) * scale;
|
||||
const auto height = (viewDimensions().height / 2) * scale;
|
||||
window.setSize(sf::Vector2u(unsigned(width), unsigned(height)));
|
||||
|
||||
maze_texture = loadTexture("maze.png");
|
||||
sprites_texture = loadTexture("sprites32.png");
|
||||
|
@ -126,8 +126,8 @@ void Canvas::renderLives(int lives) {
|
|||
|
||||
Sprite pacmanSprite = getSprite(liveSprite);
|
||||
for (int i = 0; i < lives - 1; i++) {
|
||||
size_t life_position = i * SPRITE_WIDTH * 1.5;
|
||||
GridPosition pos{ x + life_position, y };
|
||||
auto life_position = i * SPRITE_WIDTH * 1.5f;
|
||||
sf::Vector2f pos{ x + life_position, y };
|
||||
pacmanSprite.setPosition(pos.x, pos.y);
|
||||
window.draw(pacmanSprite);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ Sprite Canvas::getSprite(GridPosition coordinate) const {
|
|||
void Canvas::renderSprite(Sprite sprite, Position pos) {
|
||||
pos.x = LEFT_MARGIN + (pos.x * SPRITE_WIDTH);
|
||||
pos.y = TOP_MARGIN + (pos.y * SPRITE_HEIGHT);
|
||||
sprite.setPosition(pos.x, pos.y);
|
||||
sprite.setPosition(float(pos.x), float(pos.y));
|
||||
window.draw(sprite);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ Position Inky::target(const GameState & gameState) const {
|
|||
|
||||
// And selects a point on the line crossing blinky and this position that is at twice that distance
|
||||
// away from blinky
|
||||
targetPosition.x += ((targetPosition.x - blinkyPosition.x) / distanceBetweenBlinkyAndTarget) * 2;
|
||||
targetPosition.y += ((targetPosition.y - blinkyPosition.y) / distanceBetweenBlinkyAndTarget) * 2;
|
||||
targetPosition.x += size_t((targetPosition.x - blinkyPosition.x) / distanceBetweenBlinkyAndTarget) * 2;
|
||||
targetPosition.y += size_t((targetPosition.y - blinkyPosition.y) / distanceBetweenBlinkyAndTarget) * 2;
|
||||
|
||||
return gridPositionToPosition(targetPosition);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace pacman {
|
||||
|
||||
class GameState;
|
||||
struct GameState;
|
||||
|
||||
class Ghost {
|
||||
public:
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
void pause();
|
||||
|
||||
private:
|
||||
uint8_t animation_position = 0;
|
||||
size_t animation_position = 0;
|
||||
double animation_position_delta = 0.0;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue