moved velocityInDirection() to util.h/.cpp

This commit is contained in:
Joseph Aquino 2026-04-03 11:39:44 -04:00
parent 1da27bd621
commit e8df8f761c
3 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,8 @@
#pragma once
#include <SFML/Graphics.hpp>
#include <cmath>
sf::Vector2f getOverlap(const sf::FloatRect first, const sf::FloatRect second);
sf::Vector2f velocityInDirection(const float speed_in, const sf::Angle angle_in);

View File

@ -3,14 +3,9 @@
#include <iostream>
#include <thread>
#include <chrono>
#include <cmath>
#include "util.h"
sf::Vector2f velocityInDirection(const float speed_in, const sf::Angle angle_in)
{
return sf::Vector2f{speed_in * std::cos(angle_in.asRadians()), speed_in * std::sin(angle_in.asRadians())};
}
void Game::init()
{

View File

@ -10,3 +10,8 @@ sf::Vector2f getOverlap(const sf::FloatRect first, const sf::FloatRect second)
const float resultY = (first.size.y + second.size.y) - deltaY;
return {resultX, resultY};
}
sf::Vector2f velocityInDirection(const float speed_in, const sf::Angle angle_in)
{
return sf::Vector2f{speed_in * std::cos(angle_in.asRadians()), speed_in * std::sin(angle_in.asRadians())};
}