Hello all,
At the moment I'm trying to put everything I've learned in a small project, just a point and click game.
It's like duck hunt, a duck flies through the air and you have to "shoot" it by clicking on it.
Here's my problem:
Every loop (1/25sec) I check if the left mouse button is down and if the "cooldown" of the gun is passed.
If that's true I check if the duck is shot etc.
This all works fine.
But when I click outside of my window, my program takes that as a attempt to shoot the duck, this ruins my whole system because I want to keep track of the longest sequence of good shots etc.
What I'm trying to achieve is this:
if ((WindowIsFocussed) && (MouseButtonIsDown) && (CooldownPassed))
//Check if duck is shot etc.
So I'm searching for a function like
bool sf::Window::isFocussed() or getFocus, whatever.
If I search for this function I find a request topic, so I guess the function is not yet implemented.
Is there any workaround for me to do this? I don't like to use the event system because I want to be able to just hold the mouse button.
I can think of using a bool to keep track of every time I get an LostFocus and GainedFocus event, but I was just wondering if there was a more neat way to achieve this.
I also thought of creating my own class derived from sf::RenderWindow, but after a look at the files my head hurt
Thanks in advance!
Steef