Replace float_t by float

This commit is contained in:
Corentin Jabot 2021-05-10 15:14:38 +02:00
parent af03c13a97
commit 335a698226
7 changed files with 10 additions and 10 deletions

View File

@ -48,7 +48,7 @@ Board::Board() {
board_state[row][column] = board[row][column];
}
bool Board::isWalkable(Position point, float_t position_delta, Direction direction) const {
bool Board::isWalkable(Position point, float position_delta, Direction direction) const {
switch (direction) {
case Direction::LEFT:
return board_state[int(point.y)][int(point.x - position_delta)] != 0;

View File

@ -15,7 +15,7 @@ class Board {
public:
Board();
[[nodiscard]] bool isWalkable(Position point, float_t d, Direction direction) const;
[[nodiscard]] bool isWalkable(Position point, float d, Direction direction) const;
[[nodiscard]] std::vector<SDL_Point> initialPelletPositions() const;

View File

@ -38,7 +38,7 @@ void GameWindow::renderSuperPellets(const SuperPellets & superPellets) const {
SDL_Rect sprite_rect = superPellets.currentSprite();
std::vector<SDL_Point> superPelletPositions = superPellets.currentPositions();
for (const auto & pos : superPelletPositions) {
SDL_Rect maze_rect = targetRect({float_t(pos.x), float_t(pos.y)}, 8 * SCALE_FACTOR);
SDL_Rect maze_rect = targetRect({float(pos.x), float(pos.y)}, 8 * SCALE_FACTOR);
renderTexture(sprite_texture.get(), &sprite_rect, &maze_rect);
}
}
@ -47,7 +47,7 @@ void GameWindow::renderPellets(const Pellets & pellets) const {
SDL_Rect sprite_rect = pellets.currentSprite();
std::vector<SDL_Point> pelletPositions = pellets.currentPositions();
for (const auto & pos : pelletPositions) {
SDL_Rect maze_rect = targetRect({float_t(pos.x), float_t(pos.y)}, 8 * SCALE_FACTOR);
SDL_Rect maze_rect = targetRect({float(pos.x), float(pos.y)}, 8 * SCALE_FACTOR);
renderTexture(sprite_texture.get(), &sprite_rect, &maze_rect);
}
}

View File

@ -33,7 +33,7 @@ void PacMan::updateAnimationPosition(std::chrono::milliseconds time_delta) {
}
void PacMan::updateMazePosition(std::chrono::milliseconds time_delta, const Board & board) {
float_t position_delta = (time_delta.count() / 128.0);
float position_delta = (time_delta.count() / 128.0);
if (board.isWalkable(pos, position_delta, desired_direction)) {
direction = desired_direction;

View File

@ -18,7 +18,7 @@ public:
private:
uint8_t animation_position = 0;
float_t animation_position_delta = 0.0;
float animation_position_delta = 0.0;
const SDL_Rect right_wide = {0 * 32, 0 * 32, 32, 32};
const SDL_Rect right_narrow = {1 * 32, 0 * 32, 32, 32};
const SDL_Rect closed = {2 * 32, 0 * 32, 32, 32};

View File

@ -4,8 +4,8 @@
#include <cmath>
struct Position {
float_t x;
float_t y;
float x;
float y;
};
#endif //PACMAN_POSITION_H

View File

@ -3,9 +3,9 @@
## Make Pac-Man go slower
Increase the number you divide the delta with in [PacMan.cpp](../lib/PacMan.cpp)
~~~
float_t position_delta = (time_delta.count() / 128.0);
float position_delta = (time_delta.count() / 128.0);
~~~
Example
~~~
float_t position_delta = (time_delta.count() / 256.0);
float position_delta = (time_delta.count() / 256.0);
~~~