1
Graphics / View, Viewports and getting mouse location
« on: December 05, 2023, 07:17:13 am »
The common recommendation for making games is to have separate Update() and Render() methods.
In Update(), I get all inputs (including mouse x y coordinates) and do all updates.
Problem is in the Render() method, I end up changing the view/viewport a few times because there is a HUD and game area at least. It means that the mouse coordinates (specifically the world mapped version of them) I grabbed in the Update() function are not correct by the time the Render() function changes the view stuff around.
So now it seems like I'm forced to put some of my Update() code inside the Render() function because this is where I will finally have the right inputs.
I really don't want to mix the update and the render logic like this though. What am I missing?
In Update(), I get all inputs (including mouse x y coordinates) and do all updates.
Problem is in the Render() method, I end up changing the view/viewport a few times because there is a HUD and game area at least. It means that the mouse coordinates (specifically the world mapped version of them) I grabbed in the Update() function are not correct by the time the Render() function changes the view stuff around.
So now it seems like I'm forced to put some of my Update() code inside the Render() function because this is where I will finally have the right inputs.
I really don't want to mix the update and the render logic like this though. What am I missing?