Skip to content

Instantly share code, notes, and snippets.

@N0RT0

N0RT0/main.py Secret

Created May 17, 2025 23:10
Show Gist options
  • Select an option

  • Save N0RT0/cc54c6ff8e9c1963a5c0a29fb8c59443 to your computer and use it in GitHub Desktop.

Select an option

Save N0RT0/cc54c6ff8e9c1963a5c0a29fb8c59443 to your computer and use it in GitHub Desktop.
Main game play logic (includes GUI setup for player 1).
def gameplay():
'''
This is where the gameplay happens.
To avoid repeat questions among players, question pools are shared among players with identical
player settings
'''
questions = 3
j = 0
global BACK_FLAG
match PLAYERS:
case 1:
P1.questions = P1.get_question_pool()
random.shuffle(P1.questions)
for i in range(questions):
next_question_p1 = P1.questions[j]
SCREEN_4_player_1_gameplay(next_question_p1)
j+=1
if BACK_FLAG == True:
return
case 2:
# store all question pools in a list
P1.questions = P1.get_question_pool()
P2.questions = P2.get_question_pool()
random.shuffle(P1.questions)
random.shuffle(P2.questions)
question_pool = (P1.questions,P2.questions)
#player 2 question pool index
if P2.CATEGORY == P1.CATEGORY:
P2.question_pool_index = P1.question_pool_index
for i in range(questions):
next_question_p1 = question_pool[P1.question_pool_index][j]
j+=1
SCREEN_4_player_1_gameplay(next_question_p1)
if BACK_FLAG == True:
return
next_question_p2 = question_pool[P2.question_pool_index][j]
j+=1
SCREEN_5_player_2_gameplay(next_question_p2)
if BACK_FLAG == True:
return
case 3:
# store all question pools in a list
P1.questions = P1.get_question_pool()
P2.questions = P2.get_question_pool()
P3.questions = P3.get_question_pool()
random.shuffle(P1.questions)
random.shuffle(P2.questions)
random.shuffle(P3.questions)
question_pool = (P1.questions,P2.questions,P3.questions)
#player 2 question pool index
if P2.CATEGORY == P1.CATEGORY:
P2.question_pool_index = P1.question_pool_index
#player 3 question pool index
if P3.CATEGORY == P2.CATEGORY:
P3.question_pool_index = P2.question_pool_index
elif P3.CATEGORY == P1.CATEGORY:
P3.question_pool_index = P1.question_pool_index
for i in range(questions):
next_question_p1 = question_pool[P1.question_pool_index][j]
j+=1
SCREEN_4_player_1_gameplay(next_question_p1)
if BACK_FLAG == True:
return
next_question_p2 = question_pool[P2.question_pool_index][j]
j+=1
SCREEN_5_player_2_gameplay(next_question_p2)
if BACK_FLAG == True:
return
next_question_p3 = question_pool[P3.question_pool_index][j]
j+=1
SCREEN_6_player_3_gameplay(next_question_p3)
if BACK_FLAG == True:
return
case 4:
# store all question pools in a list
P1.questions = P1.get_question_pool()
P2.questions = P2.get_question_pool()
P3.questions = P3.get_question_pool()
P4.questions = P4.get_question_pool()
random.shuffle(P1.questions)
random.shuffle(P2.questions)
random.shuffle(P3.questions)
random.shuffle(P4.questions)
question_pool = (P1.questions,P2.questions,P3.questions,P4.questions)
#player 2 question pool index
if P2.CATEGORY == P1.CATEGORY:
P2.question_pool_index = P1.question_pool_index
#player 3 question pool index
if P3.CATEGORY == P2.CATEGORY:
P3.question_pool_index = P2.question_pool_index
elif P3.CATEGORY == P1.CATEGORY:
P3.question_pool_index = P1.question_pool_index
#player 4 question pool index
if P4.CATEGORY == P3.CATEGORY:
P4.question_pool_index = P3.question_pool_index
elif P4.CATEGORY == P2.CATEGORY:
P4.question_pool_index = P2.question_pool_index
elif P4.CATEGORY == P1.CATEGORY:
P4.question_pool_index = P1.question_pool_index
for i in range(questions):
next_question_p1 = question_pool[P1.question_pool_index][j]
j+=1
SCREEN_4_player_1_gameplay(next_question_p1)
if BACK_FLAG == True:
return
next_question_p2 = question_pool[P2.question_pool_index][j]
j+=1
SCREEN_5_player_2_gameplay(next_question_p2)
if BACK_FLAG == True:
return
next_question_p3 = question_pool[P3.question_pool_index][j]
j+=1
SCREEN_6_player_3_gameplay(next_question_p3)
if BACK_FLAG == True:
return
next_question_p4 = question_pool[P4.question_pool_index][j]
j+=1
SCREEN_7_player_4_gameplay(next_question_p4)
if BACK_FLAG == True:
return
############################################################################################################
def SCREEN_4_player_1_gameplay(trivia_question):
'''
Gameplay for Player 1
'''
# Define Local Variables
global BACK_FLAG
escape = False # variable used if user wants to escape from the program
end_turn = False
ball_return_timer_flag = False
servo_timer = 0
i = 0
points = pygame.mixer.Sound('collect-points.mp3')
fail = pygame.mixer.Sound('ough.mp3')
#menu.render
row_index = 'X'
return_timer = 0
A_score = 0
B_score = 0
C_score = 0
D_score = 0
B1_old = False
B2_old = False
B3_old = False
B4_old = False
B5_old = False
hole1_old = False
hole2_old = False
hole3_old = False
hole4_old = False
hole5_old = False
ballReturn_old = False
question_text = trivia_question["question"]
correct_choice_text = trivia_question["correct_answer"]
choices = trivia_question["incorrect_answers"]
choices.extend([trivia_question["correct_answer"]])
shuffled_choices = P1.shuffle_choices(choices)
#Create Pygame Menu
menu = pygame_menu.Menu(f'PLAYER 1 Score: {P1.score}',DISPLAY_WIDTH,DISPLAY_HEIGHT,theme=p1_theme,mouse_visible=False)
_question_text = menu.add.label(question_text,max_char = -1,font_size = 50)
table = menu.add.table(font_size=40)
table.default_cell_padding = 5
table.default_cell_align = pygame_menu.locals.ALIGN_CENTER
table.default_cell_vertical_position = pygame_menu.locals.POSITION_CENTER
table.default_cell_border_width = 0
table.default_cell_padding = 35
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
table_choice_A = table.get_cell(2,1).get_title()
table_choice_B = table.get_cell(2,2).get_title()
table_choice_C = table.get_cell(2,3).get_title()
table_choice_D = table.get_cell(2,4).get_title()
table_choices = (table_choice_A, table_choice_B, table_choice_C, table_choice_D)
menu.force_surface_update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
escape = True
menu.close()
pygame.display.set_mode((800,600))
# Use buttons to check user input
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
running = False
if event.key == pygame.K_s:
running = False
if event.key == pygame.K_d:
running = False
if event.key == pygame.K_f:
running = False
if event.key == pygame.K_g:
running = False
if event.key == pygame.K_ESCAPE:
running = False
escape = True
GAMEPLAY=False
menu.close()
pygame.display.set_mode((800,600))
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if MANUAL_RESET_BTN.is_pressed:
BACK_FLAG = True
return
if MANUAL_SERVO_BTN.is_pressed:
servo.max()
while MANUAL_SERVO_BTN.is_pressed:
pass
i+=1
if i<SERVO_TIME:
servo.max()
else:
servo.min()
ball_return_timer_flag = True
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
B1_new = BUTTONS.is_pressed_button1()
B2_new = BUTTONS.is_pressed_button2()
B3_new = BUTTONS.is_pressed_button3()
B4_new = BUTTONS.is_pressed_button4()
B5_new = BUTTONS.is_pressed_button4()
B6_new = BUTTONS.is_pressed_button4()
if B1_new == True and B1_old == False:
row_index = 'A'
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
BUTTONS.button1_led.on()
BUTTONS.button2_led.off()
BUTTONS.button3_led.off()
BUTTONS.button4_led.off()
if B2_new == True and B2_old == False:
row_index = 'B'
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
BUTTONS.button1_led.off()
BUTTONS.button2_led.on()
BUTTONS.button3_led.off()
BUTTONS.button4_led.off()
if B3_new == True and B3_old == False:
row_index = 'C'
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
BUTTONS.button1_led.off()
BUTTONS.button2_led.off()
BUTTONS.button3_led.on()
BUTTONS.button4_led.off()
if B4_new == True and B4_old == False:
row_index = 'D'
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(P1_SELECTION_COLOR))
BUTTONS.button1_led.off()
BUTTONS.button2_led.off()
BUTTONS.button3_led.off()
BUTTONS.button4_led.on()
if B5_new == True and B5_old == False:
pass
if B6_new == True and B6_old == False:
pass
B1_old = B1_new
B2_old = B2_new
B3_old = B3_new
B4_old = B4_new
B5_old = B5_new
B6_old = B6_new
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
match row_index:
case 'A':
if hole1_new == True :#and hole1_old == False:
A_score += LOW
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole2_new == True :#and hole2_old == False:
A_score += MEDIUM
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole3_new == True:# and hole3_old == False:
A_score += HIGH
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
case 'B':
if hole1_new == True:# and hole1_old == False:
B_score += LOW
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole2_new == True:# and hole2_old == False:
B_score += MEDIUM
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole3_new == True:# and hole3_old == False:
B_score += HIGH
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
case 'C':
if hole1_new == True:# and hole1_old == False:
C_score += LOW
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole2_new == True:# and hole2_old == False:
C_score += MEDIUM
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole3_new == True:# and hole3_old == False:
C_score += HIGH
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(P1_SELECTION_COLOR))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
case 'D':
if hole1_new == True:# and hole1_old == False:
D_score += LOW
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(P1_SELECTION_COLOR))
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole2_new == True:# and hole2_old == False:
D_score += MEDIUM
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(P1_SELECTION_COLOR))
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
if hole3_new == True:# and hole3_old == False:
D_score += HIGH
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(P1_SELECTION_COLOR))
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
hole1_new = BEAMS.hole_1.is_active
hole2_new = BEAMS.hole_2.is_active
hole3_new = BEAMS.hole_3.is_active
case _:
pass
if (BEAMS.ball_received_ball_return()) and (ball_return_timer_flag == True):
return_timer += clock.get_time()
else:
return_timer = 0
# hole1_old = hole1_new
# hole2_old = hole2_new
# hole3_old = hole3_new
if return_timer > BALL_RETURN_TIME:
if correct_choice_text == table_choice_A:
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(GREEN))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
if(A_score == 0):
fail.play()
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(GREEN))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(RED))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(RED))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(RED))
end_turn=True
else:
P1.score += A_score
points.play()
menu.set_title(f'PLAYER 1 Score: {P1.score}')
menu.draw(display_surface)
menu.force_surface_update()
end_turn=True
if correct_choice_text == table_choice_B:
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(GREEN))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
if(B_score == 0):
fail.play()
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(RED))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(GREEN))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(RED))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(RED))
end_turn=True
else:
P1.score += B_score
points.play()
menu.set_title(f'PLAYER 1 Score: {P1.score}')
menu.draw(display_surface)
menu.force_surface_update()
end_turn=True
if correct_choice_text == table_choice_C:
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(GREEN))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)])
if(C_score == 0):
fail.play()
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(RED))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(RED))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(GREEN))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(RED))
end_turn=True
else:
P1.score += C_score
points.play()
menu.set_title(f'PLAYER 1 Score: {P1.score}')
menu.draw(display_surface)
menu.force_surface_update()
end_turn=True
if correct_choice_text == table_choice_D:
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)])
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)])
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)])
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(GREEN))
menu.force_surface_update()
if(D_score == 0):
fail.play()
table.remove_row(row1)
row1 = table.add_row(['A',(shuffled_choices[0]) , str(A_score)],row_background_color=(RED))
table.remove_row(row2)
row2 = table.add_row(['B',(shuffled_choices[1]) , str(B_score)],row_background_color=(RED))
table.remove_row(row3)
row3 = table.add_row(['C',(shuffled_choices[2]) , str(C_score)],row_background_color=(RED))
table.remove_row(row4)
row4 = table.add_row(['D',(shuffled_choices[3]) , str(D_score)],row_background_color=(GREEN))
end_turn=True
else:
P1.score += D_score
points.play()
menu.set_title(f'PLAYER 1 Score: {P1.score}')
menu.draw(display_surface)
menu.force_surface_update()
end_turn=True
###################################################################################################################################################################################
#Fill the display surface to cover old images
display_surface.fill(BLACK)#***************************Change this to whatever background is chosen
if menu.is_enabled():
menu.update(pygame.event.get())
menu.draw(display_surface)
menu.render()
if end_turn == True:
running = False
#Update the display
pygame.display.update()
#Tick the clock
clock.tick(FPS)
# Quit the program if the "esc" key is pressed
if escape:
pygame.quit()
exit()
menu.force_surface_update()
display_surface.fill(BLACK)
menu.draw(display_surface)
pygame.display.update()
BUTTONS.button1_led.off()
BUTTONS.button2_led.off()
BUTTONS.button3_led.off()
BUTTONS.button4_led.off()
sleep(SHOW_ANSWER_TIME)
menu.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment