Hello everyone. Other than a comment on someone else’s game this is my fist post. It seems like a really nice forum with nice people.
I’ve made a few simple games, like tetris and snake, but I always made an input class for each game. (Edit:What I mean is, now I’m trying to write an input class that is a bit more profesional and can be reused) I’ve never really been that sure on the best way to do it. The thing I’m a bit confused about is mouse input and when to reset it in the input class. The game I am making is a simple (although extremely violent and it bad taste) Whack A Mole type game. So the only control is pressing the mouse. The problem was, even on the menu screens, sometimes it would not register that my mouse had been clicked. I worked out the problem.
In sudo code my game loop went a bit like this.
update game
render
reset input (reseted mouseWasPushed variable)
I reallised what was happening was if I pushed the mouse button after update game, but before or during render, the mouse input variable was reset before upate game could read it. The game uses some pretty large image files as backgrounds. I will learn later about image compression and such.
Anyway I switched it round to this.
update game
reset input
render
So I even if I pushed the mouse button during rendering it would still work. It works fine now. I have not noticed one time when the mouse was unresponsive so it solved the bug. But what would happen with games with complex long calcuations in the update? I would have the same problem.
So how am I supposed to handle reseting such varables as mouseWasPushed? Am I not supposed to reset them and there is some other way? Or do I leave it inside the game logic and out of the loop, so I can reset it as soon as it was used. Any advice would be great.