Python Forum
quiz game - problem with loading statements from file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
quiz game - problem with loading statements from file
#3
I think you are making this very difficult for yourself.

Instead of canvas and text you should use frames tkinter controls. I would make the score display and question a label and the myth and fact buttons.

Instead of using an event loop to occasionally check for a key press I would bind the key press to call a function.

Instead of looking for click events I would make myth and fact buttons and use button command callbacks.

This makes the logic fairly easy.

loop begin
ask question
wait for key press
wait for myth or fact button press
update score
repeat loop

But this being a GUI program, the waiting and the looping are event driven. There should be no sleep() statements or for or while loops.

When program starts, display the first question.
When a player key is pressed, lock out the keyboard and enable the Myth and Fact buttons
When a myth or fact button is pressed update the score, disable the Myth and Fact buttons, unlock the keyboard and display the next question.

I would use a variable to "lock" the keyboard. I would set the variable to None to indicate that no player has buzzed in. When a player hits their key, it calls a function. The function checks if the variable. If it is None, the function sets the variable to indicate what player buzzed in and enables the Myth and Fact buttons to provide feedback to the players. It might also update a label or some other display to indicate who buzzed in first. If the variable is not None, somebody already buzzed in and the keypress is ignored.
Reply


Messages In This Thread
RE: quiz game - problem with loading statements from file - by deanhystad - Apr-20-2023, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with my Black Jack game... JengaBenga 2 1,316 Sep-27-2022, 01:10 PM
Last Post: JengaBenga
  Using If Statements Instead of While Loop in Simple Game Program new_coder_231013 5 3,217 Dec-14-2021, 12:23 AM
Last Post: supuflounder
  Quoridor game. Problem: inserting player positions and walls in a checkerboard Roidesflammes 1 3,173 Aug-03-2021, 06:52 PM
Last Post: riii
  problem on creating a small game nayo43 5 2,787 Dec-13-2020, 01:03 PM
Last Post: jefsummers
  Running my game file yields a different error on a different computer system Bruizeh 0 1,494 Nov-10-2020, 03:15 AM
Last Post: Bruizeh
  Basic Quiz/Game searching1 10 5,743 Nov-18-2018, 03:58 AM
Last Post: ichabod801
  help setting questions and answers in quiz game? yoyoitsjess 3 3,674 May-10-2018, 07:35 AM
Last Post: buran
  Quiz Game Help (ASAP Please!) beginnercoder04 2 3,224 Apr-15-2018, 04:13 AM
Last Post: beginnercoder04

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020