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
Code: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 && m.x < 5000) { 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; } }Set_Mouse is constantly called in the main loop, would it be better practice to only call it from the wndproc?Code:void C_Input::Set_Mouse() { GetCursorPos(&Mouse); ScreenToClient(g_hwnd, &Mouse); } POINT Get_Mouse() { return Mouse; }
[edit] What brush does the Ellipse function use?
[edit2] Why didn't i get any warnings when trying to access a private member?



LinkBack URL
About LinkBacks


