moved some things to player
This commit is contained in:
+4
-24
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user