I cannot seem to fix it whereby spacebar allows the text to show on screen until spacebar is pressed again to remove it. Currently it shows then gets removed straight away due to SPACE being unpressed.

The only way I can seem to do it is by putting another event_queue in the ShowQuest function, but this seems to cause problems as sometimes I need to press spacebar multiple times for it to be removed.

I'll post my whole code here for ease, so you can see it all. (Sorry if it's terrible)

This performs the same however it will not allow me to press space again to show anything (which in my newbie eyes kinda shows the dialog_open is working, since dialog_open is now true and hence should not display anything).

Edit = I did comment out the ShowQuest() as QuestDialog() is only shown at the same time and is less to edit. (thats only drawing a rectangle on screen).

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin

I did try following your code however, I only have 1 while loop which is the while(!done) game loop. If i enter the code you put (Outside the bracers after my clear_to_color, so it's not in any other code), nothing happens when I press space at the NPC.

I have tried to add the code Under my DrawHuman(In the Render section and state playing section of my code) the text appears and disappears instantly, if I put a while loop here the game freezes when I get to the NPC (The while loop was the Human.x >= NPCQuestOne.x - 40)

I think I had a problem very similar to yours before with Allegro 5, where the logic looked fine, but testing for the keys being false didn't work.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin

If this is done correct from what I read about al_get_keyboard_state and al_key_down then the same thing is happening. I press space dialog appears and instantly goes off screen :-(

I have now managed to take working code, implement it and break it.

EDIT - I think this may have something to do with the way I coded my keys.I thought for now it would be easier just to use F to interact and then press space to close dialog. Although when I press F text appears and disappears the same, even though now I'm not checking any true/false values for F expect the initial press.

In case #1: You have to be careful to pass input to the dialog box while it's open.

In case #2: You have to make sure you events all get handled. You don't want to go to a new function only checking keyboard events, and then end up having all of the joystick/mouse/whatever events fill up like crazy until you return.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin

I'll looking at it now Dizzy, make some changes and I'll see where I'm at from them.

EDIT:- Still no further forward. I tried to add in the while loop Chris posted although my game froze up (if i debug at the loop it looks like it works, although I can't press the required key to cancel the loop, hence the freeze)

So back to editing/testing/reading etc. Something somewhere is gonna slap me in the face and it will work, just need to figure it out.

EDIT:- What I did want to ask is this taking my code(but cut right down)

On the 2nd loop, is it correct to say that the al_wait_for_event(event_queue, &ev); has now registered the F was released and now F = false, so when the code gets back to the state == playing, that since F is now false it will not go onto CheckDialog(Qs) and as such no longer display the rectangle ?

If so then this is what I cannot work out and this could be why even changing the key to a different key still doesn't work

No, I would prefer it if he stands in front of the NPC, presses a key to show Dialog and then presses a key (preferably the same key, as it would help to know how this works) for the dialog to be removed .

I'm glad I actually understand what the code is doing, that's always a start :-)

Exactly because of the risk of the error above, in C, I prefer to use booleans and pointers as such without the unneeded comparison to true, false or NULL. But there's no point in arguing about programming style, so let's not.

That is to say, are there any cases where explicitly testing to true is not the same as implicit true?

And likewise:

if(!x){}//Maybe?if(x ==false){}

That logical negation is the one I'm really wondering about.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin

It will error out on you. In this case you could have written sscanf on the left hand side too, and if you tried to assign to it it would error. With gcc it says "lvalue required as left operand of assignment".

As far as checking non-bool types against true or false, don't do it. true and false are usually defined as 1 and 0. However, implicit bool casts are okay :