Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. // This callback function should go in main.cpp
  2. // This should replace the one that's already there.
  3. LRESULT CALLBACK WindowProc(
  4. HWND hwnd,
  5. UINT uMsg,
  6. WPARAM wParam,
  7. LPARAM lParam )
  8. {
  9. if (uMsg == WM_DESTROY)
  10. {
  11. PostQuitMessage(0);
  12. return 0;
  13. }
  14. else if (uMsg == WM_LBUTTONDOWN)
  15. {
  16. // This is how we get the x and y of the current position in the current window.
  17. POINT p;
  18. p.x = LOWORD(lParam);
  19. p.y = HIWORD(lParam);
  20.  
  21. // This line can be changed, this is just how I get the POINT out of main, into my game.
  22. // I created a method in GameController called SetClick() that just stores the point in a private variable.
  23. GameController::SetClick(p);
  24. return 0;
  25. }
  26. return DefWindowProc(hwnd, uMsg, wParam, lParam);
  27. }
  28.  
  29.  
  30. // In Level1 and GameLevel classes, i changed the parameters of the render() method to take
  31. // a POINT param, then when I call currentLevel->Render() I pass in the point.
  32. // This gets the click point into the Level1 object.
  33. // from there you add half of the size of you square to each value.
  34. // So, You'd change the x value to x + (gridSpaceWidth/2) na fht ey to y + (gridSpaceHeight/2)
  35. // That's assuming you have the grid space size in Level1.
  36. // Where ever it is, just add it to the x and y so the centre of the ship goes to where you clicked
  37. void GameController::Render()
  38. {
  39. if (Loading)
  40. {
  41. return;//nice! Do not update or render if the scene is loading.
  42. }
  43. currentLevel->Render(clickPoint);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement