Browse Source

upper case constants

opengl-renderer-broken
Martin Dørum 4 years ago
parent
commit
4df19c2f7a
2 changed files with 14 additions and 14 deletions
  1. 9
    9
      src/Player.cc
  2. 5
    5
      src/Player.h

+ 9
- 9
src/Player.cc View File

@@ -2,10 +2,10 @@

namespace Swan {

const float Player::force = 600;
const float Player::friction = 100;
const float Player::mass = 80;
const Vec2 Player::size = Vec2(1, 2);
const float Player::FORCE = 600;
const float Player::FRICTION = 100;
const float Player::MASS = 80;
const Vec2 Player::SIZE = Vec2(1, 2);

using Keyboard = sf::Keyboard;

@@ -15,15 +15,15 @@ void Player::draw(Win &win) {

void Player::update(float dt) {
if (Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up))
body_.force_ += Vec2(0, -force);
body_.force_ += Vec2(0, -FORCE);
if (Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down))
body_.force_ += Vec2(0, force);
body_.force_ += Vec2(0, FORCE);
if (Keyboard::isKeyPressed(Keyboard::A) || Keyboard::isKeyPressed(Keyboard::Left))
body_.force_ += Vec2(-force, 0);
body_.force_ += Vec2(-FORCE, 0);
if (Keyboard::isKeyPressed(Keyboard::D) || Keyboard::isKeyPressed(Keyboard::Right))
body_.force_ += Vec2(force, 0);
body_.force_ += Vec2(FORCE, 0);

body_.friction(friction);
body_.friction(FRICTION);
body_.gravity();
body_.update(dt);
}

+ 5
- 5
src/Player.h View File

@@ -8,16 +8,16 @@ namespace Swan {
class Player {
public:
Player(Vec2 pos):
body_(pos, size, mass) {}
body_(pos, SIZE, MASS) {}

void draw(Win &win);
void update(float dt);

private:
static const float force;
static const float friction;
static const float mass;
static const Vec2 size;
static const float FORCE;
static const float FRICTION;
static const float MASS;
static const Vec2 SIZE;

Body body_;
};

Loading…
Cancel
Save