WHEEEEEEEEEeeeeeeeeeee

main
Johannes Hendrik Gerard van der Weide 2023-10-18 12:57:40 +02:00
parent b67521e698
commit 711a97cded
2 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,7 @@
const float Game::PlayerMoveSpeed = 100.f;
const sf::Time Game::TimePerFrame = sf::seconds(1.f/60.f);
float Game::PlayerTurnSpeed = 200.f;
sf::Vector2f Game::PlayerMovement = sf::Vector2f(10.f, 0.f);
Game::Game()
: mWindow(sf::VideoMode(1000, 1000), "Hertog Game")
, mTexture()
@ -68,18 +69,17 @@ void Game::handleScrollwheel(float delta) {
}
void Game::update(sf::Time deltaTime) {
sf::Vector2f movement(0.f, 0.f);
if (mIsMovingUp)
movement.y -= Game::PlayerMoveSpeed;
Game::PlayerMovement += Game::PlayerMovement * 0.1f;
if (mIsMovingDown)
movement.y += Game::PlayerMoveSpeed;
Game::PlayerMovement -= Game::PlayerMovement * 0.1f;
if (mIsMovingLeft)
movement.x -= Game::PlayerMoveSpeed;
Game::PlayerMovement = sf::Vector2f(Game::PlayerMovement.x - Game::PlayerMovement.y, Game::PlayerMovement.y + Game::PlayerMovement.x);
if (mIsMovingRight)
movement.x += Game::PlayerMoveSpeed;
Game::PlayerMovement = sf::Vector2f(Game::PlayerMovement.x + Game::PlayerMovement.y, Game::PlayerMovement.y - Game::PlayerMovement.x);
mPlayer.setRotation(mPlayerRotation * Game::PlayerTurnSpeed * deltaTime.asSeconds());
mPlayer.move(movement * deltaTime.asSeconds());
mPlayer.move(Game::PlayerMovement * deltaTime.asSeconds());
}
void Game::render() {

View File

@ -4,6 +4,7 @@ class Game
void run();
static const float PlayerMoveSpeed;
static float PlayerTurnSpeed;
static sf::Vector2f PlayerMovement;
static const sf::Time TimePerFrame;
private:
void processEvents();