unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2009, 04:42 AM
Alkatraz Alkatraz is offline
Administrator
 
Join Date: Jan 2007
Posts: 72
Default [Coding] - Simple Mouse Source

Credits tally123
Thread discussion
http://www.uc-forum.com/forum/showthread.php?t=55564



My main reason for posting this is the fix I came up with for running your game in a window. Basically, however far off the games window would be from 0,0 on the screen, that is how much your cursor would be offset to the bottom right.


If my window was 100 pixels away from 0, 0 (top left of screen) my cursor would be off by 100 pixels, this is a nice fix and a working code snippet.


For anyone asking about mouse menus/GUI's, have fun


Code:
POINT Pos;
RECT wRect;
bool showMenu = false;
int cursorx, cursory;

__inline void DoMenu()
{
    if(GetAsyncKeyState(VK_DELETE)&1)
    {
        showMenu = !showMenu;
    }
    if(showMenu)
    {
        //Our ghetto menu item
        Renderer.FillRectD3D(60, 60, 20, 20, 0xFFFFFF00);


        /* This is to correct for a problem with getcursorpos and windowed mode */
        GetWindowRect(hWnd, &wRect);

        //Cursor pos (Pos.x/Pos.y)
        GetCursorPos(&Pos);

        //Windowed correction
        cursorx = Pos.x - wRect.left;
        cursory = Pos.y - wRect.top;
        
        //Draw cursor
        Renderer.DrawTextD3D(cursorx, cursory, 0xFFFF0000, "+", DT_CENTER | DT_VCENTER, 0);

        //Mouse 1
        if(GetAsyncKeyState(0x1)&1)
        {
            if(cursorx > 60 && cursory > 60
                && cursorx < 80 && cursory < 80)
            {
                //Toggle/Action here
            }
        }
    }
}
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
coding, mouse, simple, source

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 09:08 AM.