WHEEEEEEEEEeeeeeeeeeee
parent
b67521e698
commit
711a97cded
12
src/Game.cpp
12
src/Game.cpp
|
@ -4,6 +4,7 @@
|
||||||
const float Game::PlayerMoveSpeed = 100.f;
|
const float Game::PlayerMoveSpeed = 100.f;
|
||||||
const sf::Time Game::TimePerFrame = sf::seconds(1.f/60.f);
|
const sf::Time Game::TimePerFrame = sf::seconds(1.f/60.f);
|
||||||
float Game::PlayerTurnSpeed = 200.f;
|
float Game::PlayerTurnSpeed = 200.f;
|
||||||
|
sf::Vector2f Game::PlayerMovement = sf::Vector2f(10.f, 0.f);
|
||||||
Game::Game()
|
Game::Game()
|
||||||
: mWindow(sf::VideoMode(1000, 1000), "Hertog Game")
|
: mWindow(sf::VideoMode(1000, 1000), "Hertog Game")
|
||||||
, mTexture()
|
, mTexture()
|
||||||
|
@ -68,18 +69,17 @@ void Game::handleScrollwheel(float delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::update(sf::Time deltaTime) {
|
void Game::update(sf::Time deltaTime) {
|
||||||
sf::Vector2f movement(0.f, 0.f);
|
|
||||||
if (mIsMovingUp)
|
if (mIsMovingUp)
|
||||||
movement.y -= Game::PlayerMoveSpeed;
|
Game::PlayerMovement += Game::PlayerMovement * 0.1f;
|
||||||
if (mIsMovingDown)
|
if (mIsMovingDown)
|
||||||
movement.y += Game::PlayerMoveSpeed;
|
Game::PlayerMovement -= Game::PlayerMovement * 0.1f;
|
||||||
if (mIsMovingLeft)
|
if (mIsMovingLeft)
|
||||||
movement.x -= Game::PlayerMoveSpeed;
|
Game::PlayerMovement = sf::Vector2f(Game::PlayerMovement.x - Game::PlayerMovement.y, Game::PlayerMovement.y + Game::PlayerMovement.x);
|
||||||
if (mIsMovingRight)
|
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.setRotation(mPlayerRotation * Game::PlayerTurnSpeed * deltaTime.asSeconds());
|
||||||
mPlayer.move(movement * deltaTime.asSeconds());
|
mPlayer.move(Game::PlayerMovement * deltaTime.asSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::render() {
|
void Game::render() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Game
|
||||||
void run();
|
void run();
|
||||||
static const float PlayerMoveSpeed;
|
static const float PlayerMoveSpeed;
|
||||||
static float PlayerTurnSpeed;
|
static float PlayerTurnSpeed;
|
||||||
|
static sf::Vector2f PlayerMovement;
|
||||||
static const sf::Time TimePerFrame;
|
static const sf::Time TimePerFrame;
|
||||||
private:
|
private:
|
||||||
void processEvents();
|
void processEvents();
|
||||||
|
|
Loading…
Reference in New Issue