--- /dev/null
+#include "Controller.h"
+
+#include "../world/Entity.h"
+#include "../graphics/const.h"
+
+#include <algorithm>
+
+
+namespace orbi {
+
+Controller::Controller(Entity *ent)
+: e(ent)
+, moving(0)
+, moveAcc(3.5)
+, moveTerm(5)
+, jumping(false)
+, jumpVel(-5) {
+
+}
+
+void Controller::Update(float delta) {
+ if (!e) return;
+
+ if (moving) {
+ if (std::abs(e->acc.x) < moveTerm) {
+ e->acc.x = sigma(moving) * moveAcc;
+ } else {
+ e->acc.x = 0;
+ }
+ } else {
+ e->acc.x = sigma(e->vel.x) * -moveAcc;
+ }
+
+ if (jumping && e->onGround) {
+ e->vel.y += jumpVel;
+ jumping = false;
+ }
+}
+
+
+void Controller::MoveLeft() {
+ moving -= 1;
+}
+
+void Controller::StopLeft() {
+ moving += 1;
+}
+
+void Controller::MoveRight() {
+ moving += 1;
+}
+
+void Controller::StopRight() {
+ moving -= 1;
+}
+
+void Controller::StartJump() {
+ jumping = true;
+}
+
+void Controller::StopJump() {
+ jumping = false;
+}
+
+}