Temporary mouse pos add + other stuff
This commit is contained in:
parent
78f47cd3ae
commit
6f9483041b
|
@ -56,7 +56,6 @@ namespace DanBias
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
|
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
|
||||||
{
|
{
|
||||||
|
|
||||||
WindowShell::CreateConsoleWindow();
|
WindowShell::CreateConsoleWindow();
|
||||||
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
||||||
if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
|
if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
|
||||||
|
@ -151,7 +150,21 @@ namespace DanBias
|
||||||
|
|
||||||
DanBiasGame::Result DanBiasGame::Update(float deltaTime)
|
DanBiasGame::Result DanBiasGame::Update(float deltaTime)
|
||||||
{
|
{
|
||||||
data.inputObj->Update();
|
{ // updating mouse input
|
||||||
|
POINT mousePos;
|
||||||
|
GetCursorPos( &mousePos );
|
||||||
|
|
||||||
|
RECT windowVertex;
|
||||||
|
GetWindowRect( data.window->GetHWND(), &windowVertex );
|
||||||
|
|
||||||
|
float mouseNormalisedX = (float)(mousePos.x - windowVertex.left);
|
||||||
|
mouseNormalisedX /= (float)(windowVertex.right - windowVertex.left);
|
||||||
|
|
||||||
|
float mouseNormalisedY = (float)(mousePos.y - windowVertex.top);
|
||||||
|
mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top);
|
||||||
|
|
||||||
|
data.inputObj->Update( mouseNormalisedX, mouseNormalisedY );
|
||||||
|
}
|
||||||
|
|
||||||
if( data.serverOwner )
|
if( data.serverOwner )
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
|
||||||
|
|
||||||
// create guiElements
|
// create guiElements
|
||||||
ButtonRectangle<LanMenuState*> *guiElements;
|
ButtonRectangle<LanMenuState*> *guiElements;
|
||||||
//0.5f, 0.2f, 0.3f, 0.1f,
|
|
||||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
||||||
this->privData->guiElements.AddButton( guiElements );
|
this->privData->guiElements.AddButton( guiElements );
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,7 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI
|
||||||
{
|
{
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
mouseState.x = KeyInput->GetPitch();
|
KeyInput->GetMousePos( mouseState.x, mouseState.y );
|
||||||
mouseState.y = KeyInput->GetYaw();
|
|
||||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ InputClass::InputClass()
|
||||||
m_directInput = NULL;
|
m_directInput = NULL;
|
||||||
m_keyboard = NULL;
|
m_keyboard = NULL;
|
||||||
m_mouse = NULL;
|
m_mouse = NULL;
|
||||||
|
mousePosX = 0.0f;
|
||||||
|
mousePosY = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputClass::~InputClass()
|
InputClass::~InputClass()
|
||||||
|
@ -128,6 +130,13 @@ bool InputClass::Update()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputClass::Update( float mousePosX, float mousePosY )
|
||||||
|
{
|
||||||
|
this->mousePosX = mousePosX;
|
||||||
|
this->mousePosY = mousePosY;
|
||||||
|
return this->Update();
|
||||||
|
}
|
||||||
|
|
||||||
bool InputClass::ReadKeyboard()
|
bool InputClass::ReadKeyboard()
|
||||||
{
|
{
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
@ -198,3 +207,15 @@ bool InputClass::IsKeyPressed(int key)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputClass::SetMousePos( float x, float y )
|
||||||
|
{
|
||||||
|
this->mousePosX = y;
|
||||||
|
this->mousePosY = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputClass::GetMousePos( float &x, float &y )
|
||||||
|
{
|
||||||
|
x = this->mousePosX;
|
||||||
|
y = this->mousePosY;
|
||||||
|
}
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class InputClass
|
class InputClass
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -26,6 +24,8 @@ private:
|
||||||
unsigned char m_keyboardState[256];
|
unsigned char m_keyboardState[256];
|
||||||
DIMOUSESTATE m_mouseState;
|
DIMOUSESTATE m_mouseState;
|
||||||
|
|
||||||
|
float mousePosX, mousePosY;
|
||||||
|
|
||||||
bool ReadKeyboard();
|
bool ReadKeyboard();
|
||||||
bool ReadMouse();
|
bool ReadMouse();
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ public:
|
||||||
//read the mouse and keyboard and send back
|
//read the mouse and keyboard and send back
|
||||||
// delta mouse pos and if any button is pressed
|
// delta mouse pos and if any button is pressed
|
||||||
bool Update();
|
bool Update();
|
||||||
|
bool Update( float mousePosX, float mousePosY );
|
||||||
|
|
||||||
bool IsKeyPressed(int key);
|
bool IsKeyPressed(int key);
|
||||||
bool IsMousePressed();
|
bool IsMousePressed();
|
||||||
|
@ -48,6 +49,8 @@ public:
|
||||||
float GetYaw();
|
float GetYaw();
|
||||||
float GetPitch();
|
float GetPitch();
|
||||||
|
|
||||||
|
void SetMousePos( float x, float y );
|
||||||
|
void GetMousePos( float &x, float &y );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue