Code: Select all
#ifndef _InputControl
#define _InputControl
#include "includes.h"
namespace InputControl{
class Pressed{
public:
static bool R, L;
static bool Up, Down, Left, Right;
static bool Menu, Attack, Dash, Jump;
};
class Hold{
public:
static bool R, L;
static bool Up, Down, Left, Right;
static bool Menu, Attack, Dash, Jump;
};
class Released{
public:
static bool R, L;
static bool Up, Down, Left, Right;
static bool Menu, Attack, Dash, Jump;
};
class Control{
public:
void KeyStatus(bool Key, bool &Pressed, bool &Hold, bool &Released);
void ReadKeys(sf::Event TheEvent);
};
}
Code: Select all
#include "InputControl.h"
using namespace InputControl;
void Control::ReadKeys(sf::Event TheEvent){
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Right, Pressed::Right, Hold::Right, Released::Right);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Left, Pressed::Left, Hold::Left, Released::Left);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Up, Pressed::Up, Hold::Up, Released::Up);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Down, Pressed::Down, Hold::Down, Released::Down);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::K, Pressed::R, Hold::R, Released::R);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::L, Pressed::L, Hold::L, Released::L);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Space, Pressed::Jump, Hold::Jump, Released::Jump);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::X, Pressed::Menu, Hold::Menu, Released::Menu);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::C, Pressed::Attack, Hold::Attack, Released::Attack);
KeyStatus(sf::Event::KeyPressed && TheEvent.Key.Code == sf::Key::Z, Pressed::Dash, Hold::Dash, Released::Dash);
}
void Control::KeyStatus(bool Key, bool &Pressed, bool &Hold, bool &Released){ //Get key as reference and modify it
if(Key == true && Pressed == true){Hold = true; Pressed = true; Released = false;} //Held
else if(Key == true && Pressed == false){Hold = false; Pressed = true; Released = false;} //Pressed
else if(Key == false && Pressed == true){Hold = false; Pressed = false; Released = true;} // Released
}
Code: Select all
"InputControl::Pressed::Left", referenced from:
__ZN12InputControl7Pressed4LeftE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed4LeftE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed4LeftE$non_lazy_ptr)
"InputControl::Pressed::Right", referenced from:
__ZN12InputControl7Pressed5RightE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed5RightE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed5RightE$non_lazy_ptr)
"InputControl::Hold::Right", referenced from:
__ZN12InputControl4Hold5RightE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold5RightE$non_lazy_ptr)
"InputControl::Pressed::Menu", referenced from:
__ZN12InputControl7Pressed4MenuE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed4MenuE$non_lazy_ptr)
"InputControl::Pressed::Up", referenced from:
__ZN12InputControl7Pressed2UpE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed2UpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed2UpE$non_lazy_ptr)
"InputControl::Pressed::Jump", referenced from:
__ZN12InputControl7Pressed4JumpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed4JumpE$non_lazy_ptr)
"InputControl::Released::Left", referenced from:
__ZN12InputControl8Released4LeftE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released4LeftE$non_lazy_ptr)
"InputControl::Hold::L", referenced from:
__ZN12InputControl4Hold1LE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold1LE$non_lazy_ptr)
"InputControl::Pressed::Dash", referenced from:
__ZN12InputControl7Pressed4DashE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed4DashE$non_lazy_ptr)
"InputControl::Hold::R", referenced from:
__ZN12InputControl4Hold1RE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold1RE$non_lazy_ptr)
"InputControl::Hold::Up", referenced from:
__ZN12InputControl4Hold2UpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold2UpE$non_lazy_ptr)
"InputControl::Released::Menu", referenced from:
__ZN12InputControl8Released4MenuE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released4MenuE$non_lazy_ptr)
"InputControl::Hold::Attack", referenced from:
__ZN12InputControl4Hold6AttackE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold6AttackE$non_lazy_ptr)
"InputControl::Hold::Down", referenced from:
__ZN12InputControl4Hold4DownE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold4DownE$non_lazy_ptr)
"InputControl::Pressed::L", referenced from:
__ZN12InputControl7Pressed1LE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed1LE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed1LE$non_lazy_ptr)
"InputControl::Released::Jump", referenced from:
__ZN12InputControl8Released4JumpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released4JumpE$non_lazy_ptr)
"InputControl::Released::Dash", referenced from:
__ZN12InputControl8Released4DashE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released4DashE$non_lazy_ptr)
"InputControl::Released::L", referenced from:
__ZN12InputControl8Released1LE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released1LE$non_lazy_ptr)
"InputControl::Pressed::R", referenced from:
__ZN12InputControl7Pressed1RE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed1RE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed1RE$non_lazy_ptr)
"InputControl::Released::R", referenced from:
__ZN12InputControl8Released1RE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released1RE$non_lazy_ptr)
"InputControl::Released::Right", referenced from:
__ZN12InputControl8Released5RightE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released5RightE$non_lazy_ptr)
"InputControl::Pressed::Down", referenced from:
__ZN12InputControl7Pressed4DownE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed4DownE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed4DownE$non_lazy_ptr)
"InputControl::Hold::Left", referenced from:
__ZN12InputControl4Hold4LeftE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold4LeftE$non_lazy_ptr)
"InputControl::Pressed::Attack", referenced from:
__ZN12InputControl7Pressed6AttackE$non_lazy_ptr in WorldMenu.o
__ZN12InputControl7Pressed6AttackE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl7Pressed6AttackE$non_lazy_ptr)
"InputControl::Released::Up", referenced from:
__ZN12InputControl8Released2UpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released2UpE$non_lazy_ptr)
"InputControl::Hold::Menu", referenced from:
__ZN12InputControl4Hold4MenuE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold4MenuE$non_lazy_ptr)
"InputControl::Released::Attack", referenced from:
__ZN12InputControl8Released6AttackE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released6AttackE$non_lazy_ptr)
"InputControl::Released::Down", referenced from:
__ZN12InputControl8Released4DownE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl8Released4DownE$non_lazy_ptr)
"InputControl::Hold::Jump", referenced from:
__ZN12InputControl4Hold4JumpE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold4JumpE$non_lazy_ptr)
"InputControl::Hold::Dash", referenced from:
__ZN12InputControl4Hold4DashE$non_lazy_ptr in InputControl.o
(maybe you meant: __ZN12InputControl4Hold4DashE$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status