From b3148d9dfa75a1fdd83b71f57d0dc358df35e24f Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:55:41 +0100 Subject: [PATCH] =?UTF-8?q?Position=20de=20la=20souris=20sur=20l'=C3=A9cra?= =?UTF-8?q?n=20+=20savoir=20si=20on=20appuie=20sur=20clic=20gauche=20ou=20?= =?UTF-8?q?non?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enginecustom/applicationclass.cpp | 19 ++++++++++++++++++- enginecustom/applicationclass.h | 2 ++ enginecustom/inputclass.cpp | 2 -- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 725dbac..06c2289 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -305,6 +305,7 @@ void ApplicationClass::Shutdown() delete[] m_MouseStrings; m_MouseStrings = 0; + } // Release the text object for the fps string. if (m_FpsString) { @@ -472,10 +473,12 @@ bool ApplicationClass::Frame(InputClass* Input) static float x = 6.f; static float y = 3.f; static float z = 0.f; - bool result; // Check if the user pressed escape and wants to exit the application. if (Input->IsEscapePressed()) + { + return false; + } // Update the frames per second each frame. result = UpdateFps(); @@ -507,6 +510,19 @@ bool ApplicationClass::Frame(InputClass* Input) return false; } + // Get the location of the mouse from the input object, + Input->GetMouseLocation(mouseX, mouseY); + + // Check if the mouse has been pressed. + mouseDown = Input->IsMousePressed(); + + // Update the mouse strings each frame. + result = UpdateMouseStrings(mouseX, mouseY, mouseDown); + if (!result) + { + return false; + } + // Update the system stats. m_Timer->Frame(); @@ -736,6 +752,7 @@ bool ApplicationClass::UpdateMouseStrings(int mouseX, int mouseY, bool mouseDown // Update the sentence vertex buffer with the new string information. result = m_MouseStrings[2].UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 60, 1.0f, 1.0f, 1.0f); +} bool ApplicationClass::UpdateFps() { diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 83af995..906c1b5 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -21,6 +21,7 @@ #include "fontclass.h" #include "textclass.h" #include "fpsclass.h" +#include "inputclass.h" ///////////// // GLOBALS // @@ -49,6 +50,7 @@ private: bool Render(float, float, float, float); bool UpdateMouseStrings(int, int, bool); bool UpdateFps(); + private: D3DClass* m_Direct3D; CameraClass* m_Camera; diff --git a/enginecustom/inputclass.cpp b/enginecustom/inputclass.cpp index 81bc72f..c50216a 100644 --- a/enginecustom/inputclass.cpp +++ b/enginecustom/inputclass.cpp @@ -30,8 +30,6 @@ bool InputClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int m_keys[i] = false; } - return; - // Store the screen size which will be used for positioning the mouse cursor. m_screenWidth = screenWidth; m_screenHeight = screenHeight;