This commit is contained in:
DarthMooMancer
2025-10-15 22:01:57 -04:00
parent 69b05d6bc5
commit fae17aac92
3 changed files with 9 additions and 26 deletions
+6 -22
View File
@@ -1,28 +1,22 @@
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/System/Angle.hpp>
#include <SFML/System/Vector2.hpp>
#include "globals.hpp"
#include "player.hpp"
int main() {
float floor_height = 2.0f;
bool jumping = false;
sf::RenderWindow window(sf::VideoMode({WIDTH, HEIGHT}), "SFML window", sf::Style::Default);
Player player { { 16.0f, 16.0f}, { 40, 40}, 1.0f, 20.0f, 2.0f, 2.5 };
window.setFramerateLimit(60);
// sf::RectangleShape player({ player_size, player_size });
sf::RectangleShape line({ WIDTH, floor_height });
/* TODO
* Move these functions to the player
*/
Player player { { 16.0f, 16.0f}, { 40, 40}, 1.0f, 20.0f, 2.0f, 2.5 };
player.rect.setFillColor(sf::Color::Black);
player.rect.setOutlineThickness(2); // Needs to be the same as floor height to be properly on the line; else it will just show up above the line or in the line
player.rect.setOutlineColor(sf::Color::White);
player.rect.setPosition({40, 40});
sf::RectangleShape line({ WIDTH, floor_height });
line.setPosition({ 0, HEIGHT - 50});
while (window.isOpen()) {
@@ -35,27 +29,17 @@ int main() {
window.close();
}
player.handle_movment();
/* TODO
* Move these to a player movement handler
*
* */
/* TODO
* Move these to a player update loop to move
*
* */
player.m_velocity.y += player.m_acceleration; // always apply gravity
player.rect.move({0, player.m_velocity.y});
// float groundY = line.getPosition().y - floor_height - player.rect.m_size.x;
float groundY = line.getPosition().y - floor_height - 16;
float groundY = line.getPosition().y - floor_height - player.rect.getSize().x;
if (player.rect.getPosition().y >= groundY) {
player.rect.setPosition({player.rect.getPosition().x, groundY});
player.m_velocity.y = 0;
player.m_jumping = false;
}
window.draw(line);
window.draw(player.rect);
window.draw(line);
window.display();
}
}