•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 403,233 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,062 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 698 | Replies: 6
•
•
Join Date: Mar 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
I'm working on a breakout game and i want the paddle to follow the mouse
It works from the left side of the client area to the far right of the screen but when i go over the left side of the client area, i expected it to return a negative value and the paddle keeps moving left but instead, i get some coordinate like (32070, 32389) and it goes right
i tried adding m.x < 5000 but for some reason, that doesn't work
Heres the function that moves the paddle and the function i use to get the mouse inputs
Set_Mouse is constantly called in the main loop, would it be better practice to only call it from the wndproc?
It works from the left side of the client area to the far right of the screen but when i go over the left side of the client area, i expected it to return a negative value and the paddle keeps moving left but instead, i get some coordinate like (32070, 32389) and it goes right
i tried adding m.x < 5000 but for some reason, that doesn't work
Heres the function that moves the paddle and the function i use to get the mouse inputs
void C_Paddle::Paddle_Movement()
{
POINT m = Input.Get_Mouse();
RECT ClientRect;
GetClientRect(g_hwnd, &ClientRect);
if ((Paddle_Rect.left + Paddle_Size/2) < m.x)
{
Paddle_Rect.left++;
Paddle_Rect.right = Paddle_Rect.left + Paddle_Size;
}
if ((Paddle_Rect.left + Paddle_Size/2) > m.x)
{
Paddle_Rect.left--;
Paddle_Rect.right = Paddle_Rect.left + Paddle_Size;
}
}void C_Input::Set_Mouse()
{
GetCursorPos(&Mouse);
ScreenToClient(g_hwnd, &Mouse);
}
POINT Get_Mouse() { return Mouse; }Set_Mouse is constantly called in the main loop, would it be better practice to only call it from the wndproc?
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Graphics In Pixel: Part II B (C)
- hvving problems displaying after user inters negative number? (C++)
Other Threads in the C Forum
- Previous Thread: Doubt re: interface LED with TMS320F2812 ?? Newbie question
- Next Thread: hi.. SiR/MaAm, Would U pLEase ProviDe me A LinuX WxWidGEts Installer Or DOwnload Site



Threaded Mode