c++ - How to toggle click event using SDL? -


what i'm trying accomplish:

  • when user clicks in game, tile user clicks on display border
  • if user clicks again (anywhere) border goes away

what have far:

  • when user clicks in game, border appears around selected tile

what can't seem figure out (i've tried can think of)

  • how border go away after click

about code:

i have mouseinput class checks if left mouse button pressed. i'm using boolean variables try toggle variable display tile border (if clicked) or not display border (if clicked again). code have allow border display can't go away on click. can't show things tried (been trying 2 days , can't remember did lol). sumary of code far:

bool toggle; // set false in constructor bool justpressed; // set false in constructor bool justreleased; // set false in constructor  void mouse::update() // custom mouse class updating function (updates position, etc) {     input.update(); // mouseinput class updating function.      if (input.left() && !toggle) // input.left() checks if left mouse pressed. true if pressed down, , false if it's not pressed.     {         // have pressed mouse         justpressed = true;         justreleased = false;         printf("ugh fml");     }     else if (!input.left()) // mouse has been released (or hasn't clicked yet)     {         justpressed = false;         justreleased = true;     }      if (justpressed)     {         toggle = true;     } } 

i've tried can think of toggle false. , brain hurting. there's real simple solution can't wrap head around it. suggestions?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -