My problem is that I wish to use a single mouse click (or key press) to "turn on" a set of conditions then I will "turn off" the conditions when a different requirement is met. Alas! Every time I release the mouse button the bool reverts to its initialized state. I do not want it to do that and I do not want to set it to "toggle" on and off with each mouse click either. Here are some examples of what has failed:

// first, simple failure

bool start = false;
if (dbMouseClick())
    start = true;

// another unsuccessful attempt

bool start = false;
int click = 0;
if (dbMouseClick ())
    ++click
if (click > 0)
    start = true;

// more pain here

bool start = false;
if (dbMouseClick())
    start = true;
if (start == true)
{
    if (dbMouseClick() == false)
    start = true;
}

// and my desperate, embarrassing last ditch effort

dbSprite (100, 0, 0, 100);
bool start;
if (dbSpriteExist (100))
{
    start = false;
    if (dbMouseClick ())
        dbDeleteSprite (100);
}
if (dbSpriteExist (100) == false)
    start = true;

Even that last and rather cumbersome bit of code failed because the sprite kept redrawing!!! It is obvious that my mind is on the wrong track. Would anyone be willing to help derail it. I have been at this for WAY too long. This is one of the last hang-ups I have left before completing my simple game project and moving onto bigger and more daunting brain twisters.
Thanks for any help.

So, OK, I have kind of solved the problem. All I did was a varient on an already tried bit of code.

bool start = false;
if (dbMouseClick())
    dbSprite (100, 0, 0, 100);
if (dbSpriteExist (100))
    start = true;

That works well enough but I think that it is a sloppy solution and would be open to a far more efficient way to solve this problem. Any takers?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.