Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This callback function should go in main.cpp
- // This should replace the one that's already there.
- LRESULT CALLBACK WindowProc(
- HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam )
- {
- if (uMsg == WM_DESTROY)
- {
- PostQuitMessage(0);
- return 0;
- }
- else if (uMsg == WM_LBUTTONDOWN)
- {
- // This is how we get the x and y of the current position in the current window.
- POINT p;
- p.x = LOWORD(lParam);
- p.y = HIWORD(lParam);
- // This line can be changed, this is just how I get the POINT out of main, into my game.
- // I created a method in GameController called SetClick() that just stores the point in a private variable.
- GameController::SetClick(p);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- // In Level1 and GameLevel classes, i changed the parameters of the render() method to take
- // a POINT param, then when I call currentLevel->Render() I pass in the point.
- // This gets the click point into the Level1 object.
- // from there you add half of the size of you square to each value.
- // So, You'd change the x value to x + (gridSpaceWidth/2) na fht ey to y + (gridSpaceHeight/2)
- // That's assuming you have the grid space size in Level1.
- // Where ever it is, just add it to the x and y so the centre of the ship goes to where you clicked
- void GameController::Render()
- {
- if (Loading)
- {
- return;//nice! Do not update or render if the scene is loading.
- }
- currentLevel->Render(clickPoint);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement