moved some things to player

This commit is contained in:
DarthMooMancer
2025-10-15 21:40:33 -04:00
parent 399ccc8617
commit 69b05d6bc5
3 changed files with 25 additions and 24 deletions
+4 -24
View File
@@ -5,15 +5,6 @@
#include "globals.hpp"
#include "player.hpp"
struct Player_Attributes {
sf::Vector2<float> m_size;
const float m_gravity;
const float jump_strength;
float m_thickness;
float m_velocityY;
bool jumping;
};
int main() {
float floor_height = 2.0f;
bool jumping = false;
@@ -40,25 +31,14 @@ int main() {
if (event->is<sf::Event::Closed>())
window.close();
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
window.close();
}
player.handle_movment();
/* TODO
* Move these to a player movement handler
*
* */
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)) {
player.rect.move({2.5f, 0});
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
player.rect.move({-2.5f, 0});
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) {
player.rect.move({0, -2.5});
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)) {
player.rect.move({0, 2.5});
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space) && !player.m_jumping) {
player.m_jumping = true;
player.m_velocity.y = -player.m_jump_strength; // push up
}
/* TODO
* Move these to a player update loop to move