diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-03-27 19:22:49 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-03-27 19:22:49 -0400 |
commit | da4bd0b57b1ce5cdb56e6f8d9870998cbdd176f4 (patch) | |
tree | a901b069cdf8a6cf1beb0245ee02d25b898b25b9 | |
parent | 9d53b5e235a991458f9c869fb07cea23ee36a560 (diff) |
gravity?
-rw-r--r-- | include/components.hpp | 4 | ||||
-rw-r--r-- | include/player.hpp | 2 | ||||
-rw-r--r-- | src/attack.cpp | 8 | ||||
-rw-r--r-- | src/components.cpp | 10 | ||||
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/player.cpp | 6 |
6 files changed, 16 insertions, 16 deletions
diff --git a/include/components.hpp b/include/components.hpp index fe56a88..20a1419 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -98,7 +98,7 @@ struct Physics : public Component { * Constructor that sets the gravity constant, if not specified it becomes 0. * @param g The non default gravity constant. */ - Physics(float g = 1.0f): g(g) {} + Physics(float g = 0.2f): g(g) {} Physics(XMLElement* imp, XMLElement* def) { fromXML(imp, def); } @@ -108,7 +108,7 @@ struct Physics : public Component { void fromXML(XMLElement* imp, XMLElement* def) final { if (imp->QueryFloatAttribute("gravity", &g) != XML_NO_ERROR) { if (def->QueryFloatAttribute("value", &g) != XML_NO_ERROR) - g = 1.0f; + g = 0.2f; } } }; diff --git a/include/player.hpp b/include/player.hpp index 2c65717..efac984 100644 --- a/include/player.hpp +++ b/include/player.hpp @@ -15,7 +15,7 @@ /** * The constant velocity the player is given when moved with the arrow keys. */ -constexpr const float PLAYER_SPEED_CONSTANT = 0.15f; +constexpr const float PLAYER_SPEED_CONSTANT = 0.03f; /** * @class PlayerSystem diff --git a/src/attack.cpp b/src/attack.cpp index 550b849..3dc1594 100644 --- a/src/attack.cpp +++ b/src/attack.cpp @@ -3,8 +3,8 @@ #include <engine.hpp> #include <particle.hpp> -constexpr int shortSlashLength = 100; -constexpr int longSlashLength = 200; +constexpr int shortSlashLength = 20; +constexpr int longSlashLength = 40; // math helpers because we don't trust stdlib template<typename T> @@ -41,7 +41,7 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev, if (e.has_component<Player>()) return; - if (inrange(a.pos.x, pos.x, pos.x + dim.width, shortSlashLength)) { + if (inrange(a.pos.x, pos.x, pos.x + dim.width, HLINES(shortSlashLength))) { h.health -= a.power; game::engine.getSystem<ParticleSystem>()->addMultiple(15, ParticleType::DownSlash, [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7); @@ -56,7 +56,7 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev, if (e.has_component<Player>()) return; - if (inrange(a.pos.x, pos.x, pos.x + dim.width, shortSlashLength)) { + if (inrange(a.pos.x, pos.x, pos.x + dim.width, 0)) { h.health -= a.power; game::engine.getSystem<ParticleSystem>()->addMultiple(15, ParticleType::SmallBlast, [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7); diff --git a/src/components.cpp b/src/components.cpp index 732e21f..dee56a6 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -27,8 +27,8 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e (void)ev; en.each<Position, Direction>([&](entityx::Entity entity, Position &position, Direction &direction) { - position.x += direction.x * dt; - position.y += direction.y * dt; + position.x += HLINES(direction.x) * dt; + position.y += HLINES(direction.y) * dt; if (entity.has_component<Animate>() && entity.has_component<Sprite>()) { auto animate = entity.component<Animate>(); @@ -38,7 +38,7 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e animate->updateAnimation(1, sprite->sprite, dt); else animate->firstFrame(1, sprite->sprite); - } + } if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) { direction.x = 0; } else { @@ -60,7 +60,7 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e h = 0; } } else - direction.x = (ppos.x > position.x) ? .05 : -.05; + direction.x = (ppos.x > position.x) ? .01 : -.01; } else if (entity.has_component<Wander>()) { auto& countdown = entity.component<Wander>()->countdown; @@ -68,7 +68,7 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e countdown--; } else { countdown = 5000 + randGet() % 10 * 100; - direction.x = (randGet() % 3 - 1) * 0.02f; + direction.x = (randGet() % 3 - 1) * 0.004f; } } } diff --git a/src/inventory.cpp b/src/inventory.cpp index 3e7104e..664d8a6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -211,7 +211,7 @@ void InventorySystem::receive(const MouseReleaseEvent &mre) auto e = game::entities.create(); e.assign<Position>(mre.position.x, mre.position.y); - e.assign<Direction>(0, 1); + e.assign<Direction>(0, 0.4f); e.assign<ItemDrop>(items[movingItem]); e.assign<Sprite>(); e.component<Sprite>()->addSpriteSegment( diff --git a/src/player.cpp b/src/player.cpp index d9a4a98..711ddae 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -75,7 +75,7 @@ void PlayerSystem::create(void) player.assign<Position>(0.0f, 100.0f); player.assign<Direction>(0.0f, 0.0f); //player.assign<Physics>(-0.001f); - player.assign<Physics>(1); + player.assign<Physics>(); player.assign<Visible>(-0.2f); player.assign<Health>(100); auto sprite = player.assign<Sprite>(); @@ -154,7 +154,7 @@ void PlayerSystem::receive(const KeyDownEvent &kde) if ((kc == SDLK_SPACE) && game::canJump && ((vel.y > -0.01) & (vel.y < 0.01))) { loc.y += HLINES(2); - vel.y = .4; + vel.y = 0.05f; vel.grounded = false; } else if (!ui::dialogBoxExists || ui::dialogPassive) { if (kc == getControl(0)) { @@ -229,7 +229,7 @@ void PlayerSystem::receive(const UseItemEvent& uie) e.assign<Position>(pos.x, pos.y + 10); auto angle = std::atan2(uie.curs.y - pos.y, uie.curs.x - pos.x); - e.assign<Direction>(1 * std::cos(angle), 1 * std::sin(angle)); + e.assign<Direction>(0.25f * std::cos(angle), 0.25f * std::sin(angle)); e.assign<Visible>(-5); e.assign<Physics>(); |