SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
Sage::CMouse Class Reference

The mouse handler. More...

#include <SageMouse.h>

Inheritance diagram for Sage::CMouse:
Collaboration diagram for Sage::CMouse:

Public Member Functions

void GetState ()
 Poll the mouse state.
 
const Vector2 GetMove () const
 Get amount of motion.
 
const Vector2 GetPos () const
 Get position.
 
- Public Member Functions inherited from Sage::CWindow
template<typename t0 , typename t1 , typename t2 >
int WinMain (_In_ HINSTANCE, bool, const t0 &, const t1 &, const t2 &)
 WinMain.
 
- Public Member Functions inherited from Sage::CSettingsManager
void Load ()
 Load game settings.
 

Protected Attributes

Vector2 m_vCurPos
 Current position.
 
Vector2 m_vOldPos
 Previous position.
 

Additional Inherited Members

- Protected Member Functions inherited from Sage::CWindow
HWND CreateGameWindow (HINSTANCE)
 Create default window.
 
bool InitGameWindow (_In_ HINSTANCE)
 Initialize the game window.
 
void OpenDebugConsole ()
 Open debug console window.
 
void CloseDebugConsole ()
 Close debug console window.
 
- Protected Member Functions inherited from Sage::CSettingsManager
void SetWinSize (int, int)
 Set window size information.
 
- Static Protected Member Functions inherited from Sage::CWindow
static LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM)
 The Window Procedure.
 
static void GetBorderSizes (int &w, int &h)
 Get window border width and height.
 
static void EnforceAspectRatio (WPARAM, RECT *)
 Enforce aspect ratio.
 
static void EnforceAspectRatio (MINMAXINFO *)
 Enforce aspect ratio.
 
- Static Protected Attributes inherited from Sage::CWindow
static Vector2 m_vMousePos
 Mouse position.
 
- Static Protected Attributes inherited from Sage::CWindowDesc
static HWND m_Hwnd = 0
 Window handle.
 
static HINSTANCE m_hInst = 0
 Instance handle.
 
static bool m_bExitSizeMove = true
 User just finished moving/resizing window.
 
- Static Protected Attributes inherited from Sage::CSettingsManager
static tinyxml2::XMLElement * m_pXmlSettings = nullptr
 Pointer to the settings tag in the XML settings file.

 
static float m_fAspectRatio = 1.0f
 Aspect ratio, width/ht.
 
- Static Protected Attributes inherited from Sage::CSettings
static char m_szName [MAX_PATH]
 Name of this game.
 
static int m_nWinWidth = 0
 Window width in pixels.
 
static int m_nWinHeight = 0
 Window height in pixels.
 
static Vector2 m_vWinCenter = Vector2::Zero
 Window center.
 

Detailed Description

This is a polled mouse handler. Its GetState() function must be called once per frame. The mouse position from the previous frame is retained so that queries can determine how far the mouse moved in the last frame. Mouse button clicks are handled by the keyboard handler using virtual key codes VK_LBUTTON, VK_MBUTTON, VK_RBUTTON, VK_XBUTTON1, and VK_XBUTTON2.

Member Function Documentation

◆ GetMove()

const Vector2 CMouse::GetMove ( ) const

Get the displacement vector for the mouse since the last time GetState() was called.

Returns
Vector displacement of mouse.

◆ GetPos()

const Vector2 CMouse::GetPos ( ) const

Get the position the mouse in screen coordinates the last time GetState() was called. The Origin is at bottom left of the window, positive x goes to the right, and positive y goes upwards.

Returns
Position of mouse.

◆ GetState()

void CMouse::GetState ( )

Get the current mouse state. This function should be called once per frame.