def tut3D_final_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("Congratulations!!", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "you have learnt to draw a Mohr Circle", "and find the component of stress at various", "angles.", "Try out the Quiz! or Explore in General Mode" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (120, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) back_to_homeButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): windows[prev_win][1].makeCurrent() tut3D_final_window_check.endCurrent() if back_to_homeButton.isOver(pos): enterWindow_check.makeCurrent() tut3D_final_window_check.endCurrent()
def quiz_end_window(screen, prev_win, windows): global userScore, quiz_question_type Big_font = game_font(80) Small_font = game_font(20) text = Big_font.render("Quiz Over", 1, (0, 0, 0)) screen.blit(text, (70, 250)) text = Small_font.render("Your Score : " + str(userScore), 1, (0, 0, 0)) screen.blit(text, (60, 400)) quiz_question_type = ['concept'] # enterButton.draw(screen, (0,0,0)) back_to_homeButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEMOTION: if back_to_homeButton.isOver(pos): back_to_homeButton.color = (255, 0, 0) else: back_to_homeButton.color = (180, 0, 0) if event.type == pygame.MOUSEBUTTONDOWN: if back_to_homeButton.isOver(pos): quiz_end_window_check.endCurrent() enterWindow_check.makeCurrent()
def tut3D_step3_window(screen, prev_win, windows): global angle_check Big_font = game_font(60) Small_font = game_font(25) extra_small_font = game_font(18) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-3", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) m = tut_Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=float(sigma_zz_tut.text), σxy=float(tau_xy_tut.text), σyz=float(tau_yz_tut.text), σzx=float(tau_zx_tut.text)) m.ndims = 3 Is = m.get_I_values() tut_text = [ "Now, using the center and radius being ", "Therefore, the corresponding values are : ", "I1 = " + str(round(Is[0], 3)), "I2 = " + str(round(Is[1], 3)), "I3 = " + str(round(Is[2], 3)), ] eqn_text = [ "The next step would be to calculate the", "values of lamb from previous slide.", "our equation becomes : ", "lamb^3 - (" + str(round(Is[0], 3)) + ")*lamb^2 + " + str(round(Is[1], 3)) + "*lamb -(" + str(round(Is[2], 3)) + ") = 0", ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 count = 0 for text in eqn_text: text = extra_small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 410 + count)) count += 30 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step2_window_check.makeCurrent() tut3D_step3_window_check.endCurrent() if nextButton.isOver(pos): tut3D_step3_window_check.endCurrent() tut3D_step4_window_check.makeCurrent()
def quizwindow(screen, prev_win, windows): Big_font = game_font(80) Small_font = game_font(20) text = Big_font.render("Quiz Mode", 1, (0, 0, 0)) screen.blit(text, (150, 200)) backButton.draw(screen, (0, 0, 0)) startButton.draw(screen, (0, 0, 0)) global curr_question_type, quiz_question_type, sigma_xx, sigma_yy, sigma_zz, tau_xy, tau_yz, tau_zx, quest_nos, quest_index # print(len(quiz_question_type)) random.shuffle(quiz_question_type) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): enterWindow_check.makeCurrent() quizwindow_check.endCurrent() if startButton.isOver(pos): if quiz_question_type[0] == '2-D': sigma_xx = round(random.randint(-30, 30), 2) sigma_yy = round(random.randint(-30, 30), 2) tau_xy = round(random.randint(-30, 30), 2) sigma_zz = 0 tau_yz = 0 tau_zx = 0 quiz_question_type = quiz_question_type[1:] quizwindow_2d_check.makeCurrent() quizwindow_check.endCurrent() elif quiz_question_type[0] == '3-D': sigma_xx = round(random.randint(-30, 30), 2) sigma_yy = round(random.randint(-30, 30), 2) sigma_zz = round(random.randint(-30, 30), 2) tau_xy = round(random.randint(-30, 30), 2) tau_yz = round(random.randint(-30, 30), 2) tau_zx = round(random.randint(-30, 30), 2) quiz_question_type = quiz_question_type[1:] quizwindow_3d_check.makeCurrent() quizwindow_check.endCurrent() elif quiz_question_type[0] == 'concept': quiz_question_type = quiz_question_type[1:] quest_index = random.randint(0, len(quest_nos) - 1) quizwindow_concept_check.makeCurrent() quizwindow_check.endCurrent() if event.type == pygame.MOUSEMOTION: if startButton.isOver(pos): startButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0) if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0)
def tut3D_step1_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-1", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "The first step to draw a 3-d Mohr circle ", "for the given stress state is to find the", "principle stresses. we find it by first ", "placing the stresses in a stress-tensor", ] tens_init_text = [ "[sig_xx tau_xy tau_xz", " tay_xy sig_yy tau_yz =", " tau_xz tau_yz sig_zz]" ] user_tens_text = [ "[" + str(sigma_xx_tut.text) + " " + str(tau_xy_tut.text) + " " + str(tau_zx_tut.text), " " + str(tau_xy_tut.text) + " " + str(sigma_yy_tut.text) + " " + str(tau_yz_tut.text), " " + str(tau_zx_tut.text) + " " + str(tau_yz_tut.text) + " " + str(sigma_zz_tut.text) + "]" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 30 count = 0 for text in tens_init_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (30, 350 + count)) count += 30 count = 0 for text in user_tens_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (500, 350 + count)) count += 30 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_stress_input_window_check.makeCurrent() tut3D_step1_window_check.endCurrent() if nextButton.isOver(pos): tut3D_step1_window_check.endCurrent() tut3D_step2_window_check.makeCurrent()
def tutorialwindow(screen, prev_win, windows): Small_font = game_font(40) extra_small_font = game_font(18) text = Small_font.render("Tutorial Mode", 1, (0, 0, 0)) screen.blit(text, (220, 100)) twodButton.draw(screen, (0, 0, 0)) threedButton.draw(screen, (0, 0, 0)) backButton.draw(screen, (0, 0, 0)) note_text = [ "NOTE: This is a step-by-step tutorial to", "draw Mohr Circle for Stresses in 2-D and", "3-D only. The entire procedure for strains", "both in 2-D and 3-D are similar, the user", "has to plot (1/2)*(shear values) in 2-D", "and place half of the (1/2)*(shear values)", "in stress tensor for 3-D strain Mohr-Circle." ] count = 0 for text in note_text: text = extra_small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (180, 380 + count)) count += 30 for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if twodButton.isOver(pos): tut2D_stress_input_window_check.makeCurrent() tutorialwindow_check.endCurrent() print("Entering in stress 2-D Mode") if threedButton.isOver(pos): tut3D_stress_input_window_check.makeCurrent() tutorialwindow_check.endCurrent() print("Entering in 3-D Mode") if backButton.isOver(pos): enterWindow_check.makeCurrent() tutorialwindow_check.endCurrent() if event.type == pygame.MOUSEMOTION: if twodButton.isOver(pos): twodButton.color = (255, 0, 0) else: twodButton.color = (180, 0, 0) if threedButton.isOver(pos): threedButton.color = (255, 0, 0) else: threedButton.color = (180, 0, 0) if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0)
def tut3D_step6_window(screen, prev_win, windows): global angle_check Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-6", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Using the centers, and the corresponding ", "principle stresse, draw circles with radii", "being distance between the centers and their", "corresponding principle stresses.", ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) xButton = nextButton if angle_check == 0: xButton = finishButton xButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step5_window_check.makeCurrent() tut3D_step6_window_check.endCurrent() if xButton.isOver(pos): if xButton == nextButton: tut3D_step7_window_check.makeCurrent() tut3D_step6_window_check.endCurrent() else: tut3D_final_window_check.makeCurrent() tut3D_step6_window_check.endCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text), float(sigma_zz_tut.text), float(tau_yz_tut.text), float(tau_zx_tut.text)) req_mohr.ndims = 3 req_mohr.plot_circle_3d()
def quizwindow_2d(screen, prev_win, windows): clock = pygame.time.Clock() Big_font = game_font(40) Small_font = game_font(20) text = Big_font.render("Quiz on 2-D Mohr circle", 1, (0, 0, 0)) screen.blit(text, (100, 70)) text = Small_font.render( "Draw the mohr circle for the following 2-D stress field", 1, (0, 0, 0)) screen.blit(text, (30, 150)) ans_boxes_2d = {C1_gen: "C1"} for box in ans_boxes_2d.keys(): box_text = Small_font.render(ans_boxes_2d[box] + ":", 1, (0, 0, 0)) screen.blit(box_text, (box.x - 80, box.y)) global curr_question_type, quiz_question_type, sigma_xx, sigma_yy, sigma_zz, tau_xy, tau_yz, tau_zx # print(len(quiz_question_type)) curr_question_type = '2-D' text = Small_font.render("sigma_xx = ", 1, (0, 0, 0)) screen.blit(text, (50, 200)) text = Small_font.render("sigma_yy = ", 1, (0, 0, 0)) screen.blit(text, (50, 250)) text = Small_font.render("tau_xy = ", 1, (0, 0, 0)) screen.blit(text, (50, 300)) text = Small_font.render(str(sigma_xx), 1, (0, 0, 0)) screen.blit(text, (180, 200)) text = Small_font.render(str(sigma_yy), 1, (0, 0, 0)) screen.blit(text, (180, 250)) text = Small_font.render(str(tau_xy), 1, (0, 0, 0)) screen.blit(text, (180, 300)) x_button = nextButton if len(quiz_question_type) == 0: x_button = submitButton x_button.draw(screen, (0, 0, 0)) for event in pygame.event.get(): ans_boxes_2d = quiz_button_loop(event, x_button, quizwindow_2d_check, ans_boxes_2d) for box in ans_boxes_2d.keys(): txt_surface = Small_font.render(box.text, True, box.color) width = max(200, txt_surface.get_width() + 10) box.render().w = width screen.blit(txt_surface, (box.x + 5, box.y + 5)) pygame.draw.rect(screen, box.color, box.render(), 2) clock.tick(30)
def tut3D_step4_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-4", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) m = tut_Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=float(sigma_zz_tut.text), σxy=float(tau_xy_tut.text), σyz=float(tau_yz_tut.text), σzx=float(tau_zx_tut.text)) m.ndims = 3 eigen = m.get_princip_values() prin_stress = np.sort(eigen)[::-1] tut_text = [ "Now, using the center and radius being ", "Solving the equation gives us : ", "lamb = " + str(eigen[0]) + ", lamb = " + str(eigen[1]) + ", lamb = " + str(eigen[2]), " ", "Arrange the values such that sig_1", "is the largest and sig_3 is the least", "sig_1, sig_2, sig_3 are principle stresses", "sig_1 = " + str(prin_stress[0]) + ", sig_2 = " + str(prin_stress[1]) + ", sig_3 = " + str(prin_stress[2]), ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (65, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step3_window_check.makeCurrent() tut3D_step4_window_check.endCurrent() if nextButton.isOver(pos): tut3D_step5_window_check.makeCurrent() tut3D_step4_window_check.endCurrent()
def tut2D_step5_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-5", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "Thus the new line has its end-points on", "the circle. These endpoints denote the new", "(sigma_xx, -tau_xy) and (sigma_yy, tau_xy)", " ", "Thus you get the required values of stress", "at the required angle using Mohr's Circle!!!" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) finishButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step4_window_check.makeCurrent() tut2D_step5_window_check.endCurrent() if finishButton.isOver(pos): tut2D_final_window_check.makeCurrent() tut2D_step5_window_check.endCurrent() if graphButton.isOver(pos): req_mohr = Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) # req_mohr.angle = float(angle_tut.text) req_mohr.ndims = 2 # req_mohr.plot_angle2d() req_mohr.isAngle_stress = True req_mohr.reqAngle_stress_2d = float(angle_tut.text) req_mohr.isGraph = True req_mohr.stress_execute()
def enterwindow(screen, prev_win, windows): Small_font = game_font(20) text = Small_font.render("Select Mode", 1, (0, 0, 0)) screen.blit(text, (360, 100)) generalButton.draw(screen, (0, 0, 0)) tutorialButton.draw(screen, (0, 0, 0)) quizButton.draw(screen, (0, 0, 0)) backButton.draw(screen, (0, 0, 0)) docuButton.draw(screen, (0, 0, 0)) aboutButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if generalButton.isOver(pos): gen_stress_strain_window_check.makeCurrent() enterWindow_check.endCurrent() print("Entering in General Mode") if quizButton.isOver(pos): quizwindow_check.makeCurrent() enterWindow_check.endCurrent() print("Entering in Quiz Mode") if tutorialButton.isOver(pos): tutorialwindow_check.makeCurrent() enterWindow_check.endCurrent() if backButton.isOver(pos): startwindow_check.makeCurrent() enterWindow_check.endCurrent() if aboutButton.isOver(pos): aboutwindow_check.makeCurrent() enterWindow_check.endCurrent() if docuButton.isOver(pos): try: os.system('Mohr_Circle_Documentation.pdf') except: pass if event.type == pygame.MOUSEMOTION: if generalButton.isOver(pos): generalButton.color = (255, 0, 0) else: generalButton.color = (180, 0, 0) if tutorialButton.isOver(pos): tutorialButton.color = (255, 0, 0) else: tutorialButton.color = (180, 0, 0) if quizButton.isOver(pos): quizButton.color = (255, 0, 0) else: quizButton.color = (180, 0, 0) if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0) if docuButton.isOver(pos): docuButton.color = (255, 0, 0) else: docuButton.color = (180, 0, 0)
def tut3D_step2_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) extra_small_font = game_font(15) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-2", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "After placing the values appropriately,", "the next step involves solving for eigen", "values. So, the Characteristic Equation is:", "lamb^3 - I1*lamb^2 + I2*lamb -I3 = 0" ] formula_text = [ "where, I1, I2, I3 are given by: ", "I1 = sig_xx + sig_yy + sig_zz", "I2 = sig_xx*sig_yy + sig_xx*sig_zz + sig_yy*sig_zz - tau_xy^2 - tau_xz^2 - tau_yz^2", "I3 = determinant(Tensor)" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 count = 0 for text in formula_text: text = extra_small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (40, 400 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step1_window_check.makeCurrent() tut3D_step2_window_check.endCurrent() if nextButton.isOver(pos): tut3D_step2_window_check.endCurrent() tut3D_step3_window_check.makeCurrent()
def tut2D_step4_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-4", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "To find the values of stress at an angle", "say theta. Rotate the line about the center", "by an angle of 2*theta.", " ", "NOTE: the rotation should be in anticlockwise ", "direction with the angle is positive and", "clockwise if the angle is negative" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step3_window_check.makeCurrent() tut2D_step4_window_check.endCurrent() if nextButton.isOver(pos): tut2D_step5_window_check.makeCurrent() tut2D_step4_window_check.endCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) req_mohr.angle2d = float(angle_tut.text) req_mohr.ndims = 2 req_mohr.plot_angle2d()
def quizwindow_concept(screen, prev_win, windows): global quiz_question_type, sigma_xx, sigma_yy, sigma_zz, tau_xy, tau_yz, tau_zx, quest_nos, quest_index, user_concept_answer, curr_question_type # print(len(quiz_question_type)) Big_font = game_font(40) Small_font = game_font(15) text = Big_font.render("Conceptual:", 1, (0, 0, 0)) screen.blit(text, (30, 70)) count = 0 for conc_text in concept_quest[quest_nos[quest_index]][0]: text = Small_font.render(conc_text, 1, (0, 0, 0)) screen.blit(text, (30, 150 + count)) count += 25 x_button = nextButton if len(quiz_question_type) == 0: x_button = submitButton x_button.draw(screen, (0, 0, 0)) check_boxes = [check1, check2, check3, check4] curr_question_type = 'concept' for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.MOUSEBUTTONDOWN: mcq_index = 0 for check_box in check_boxes: if (check_box.render().collidepoint(event.pos)): check_box.active = not check_box.active if (check_box.active): user_concept_answer = mcq_index else: check_box.active = False mcq_index += 1 quiz_button_loop(event, x_button, quizwindow_concept_check, {}) opt_count = 0 for check_box in check_boxes: text = Small_font.render( concept_quest[quest_nos[quest_index]][1][opt_count], 1, (0, 0, 0)) screen.blit(text, (check_box.x + 30, check_box.y)) pygame.draw.rect(screen, check_box.color, check_box.render(), 2) if (check_box.active == True): color, center, radius = check_box.draw_circ() pygame.draw.circle(screen, color, center, radius) opt_count += 1
def tut3D_step5_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-5", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the principle stresses, ", "Plot the stresses calculated on the X-axis", "Find the midpoint between each of the three", "points", ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step4_window_check.makeCurrent() tut3D_step5_window_check.endCurrent() if nextButton.isOver(pos): tut3D_step6_window_check.makeCurrent() tut3D_step5_window_check.endCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text), float(sigma_zz_tut.text), float(tau_yz_tut.text), float(tau_zx_tut.text)) req_mohr.ndims = 3 req_mohr.plot_cent()
def tut2D_step2_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-2", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "The next step to draw a 2-d Mohr circle ", "for the given stress state is to draw", "is to join the points plotted using a ", "straight line. Mark the point where the ", "line intersects X-axis as the center of ", "the circle", ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step1_window_check.makeCurrent() tut2D_step2_window_check.endCurrent() if nextButton.isOver(pos): tut2D_step2_window_check.endCurrent() tut2D_step3_window_check.makeCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) req_mohr.ndims = 2 req_mohr.plot_cent()
def tut2D_step1_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-1", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "The first step to draw a 2-d Mohr circle ", "for the given stress state is to draw", "the points corresponding to the stresses", "On a graph, Plot: ", "(sigma_xx, -tau_xy) & (sigma_yy, tau_xy)" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_stress_input_window_check.makeCurrent() tut2D_step1_window_check.endCurrent() if nextButton.isOver(pos): tut2D_step1_window_check.endCurrent() tut2D_step2_window_check.makeCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) req_mohr.ndims = 2 req_mohr.plot_init_pts()
def startwindow(screen, prev_win, windows): Big_font = game_font(80) Small_font = game_font(20) text = Big_font.render("Mohr's Circle", 1, (0, 0, 0)) screen.blit(text, (70, 250)) screen.blit(iitgn_logo, (280, 0)) new_text = [ "An interactive app to understand and visualise the concepts", " of Mohr's Circle in 2-Dimeansion and 3-Dimension" ] count = 0 for text_inp in new_text: text = Small_font.render(text_inp, 1, (0, 0, 0)) screen.blit(text, (60, 400 + count)) count += 25 # text = Small_font.render ("An interactive app to understand and visualise the concepts of Mohr's Circle in 2-Dimeansion and 3-Dimension",1, (0,0,0)) # screen.blit(text, (60, 400)) text = Small_font.render( "Rwik Rana| Shreyas Sonawane| Manish Alriya| Yash Meshram ", 1, (0, 0, 0)) screen.blit(text, (60, 550)) enterButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if enterButton.isOver(pos): enterWindow_check.makeCurrent() startwindow_check.endCurrent() print("User entered the Application") if event.type == pygame.MOUSEMOTION: if enterButton.isOver(pos): enterButton.color = (255, 0, 0) else: enterButton.color = (180, 0, 0)
def draw(self, win, outline=None): #Call this method to draw the button on the screen if outline: pygame.draw.rect( win, outline, (self.x - 2, self.y - 2, self.width + 4, self.height + 4), 0) pygame.draw.rect(win, self.color, (self.x, self.y, self.width, self.height), 0) if self.text != '': font = game_font(15) text = font.render(self.text, 1, (255, 255, 255)) win.blit(text, (self.x + 15, self.y + int(self.height / 5)))
def aboutwindow(screen, prev_win, windows): Small_font = game_font(20) Big_font = game_font(40) text = Big_font.render("ABOUT US", 1, (0, 0, 0)) screen.blit(text, (330, 100)) texts = [ "We are a group of 4 students from IITGn.", "This is a term project for the course ", "ME-321 Mechanics of Deformable Bodies.", "The app is targeted towards students", "encountering the topicsof Stress, Strain", "Mohr's Circle. This app helps user to learn,", "to draw Mohr Circle and evaluate his/her", "learnings using Quiz mode." ] count = 0 for text in texts: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (150, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): enterWindow_check.makeCurrent() aboutwindow_check.endCurrent() if event.type == pygame.MOUSEMOTION: if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0)
def incompatible_input_window(screen, prev_win, windows): backButton.draw(screen, (0, 0, 0)) Big_font = game_font(55) Small_font = game_font(20) text = Big_font.render("Incompatible input!!!!", 1, (0, 0, 0)) screen.blit(text, (70, 250)) text = Small_font.render("Please fill all the fields", 1, (0, 0, 0)) screen.blit(text, (200, 400)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): windows[prev_win][1].makeCurrent() incompatible_input_window_check.endCurrent() if event.type == pygame.MOUSEMOTION: if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0)
def quiz_button_loop(event, x_button, current_window_check, ans_box): Small_font = game_font(20) global correct_answer, curr_question_type, quiz_question_type, sigma_xx, sigma_yy, sigma_zz, tau_xy, tau_yz, tau_zx pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if x_button.isOver(pos): current_window_check.endCurrent() eval_window_check.makeCurrent() for box in ans_box.keys(): if box.render().collidepoint(event.pos): box.active = True else: box.active = False if event.type == pygame.KEYDOWN: for box in ans_box.keys(): if box.active: if event.key == pygame.K_RETURN: box.text = '' elif event.key == pygame.K_BACKSPACE: box.text = box.text[:-1] else: try: _ = float(event.unicode) box.text += event.unicode except: if event.unicode == "." or event.unicode == "-": temp_text = box.text temp_text += event.unicode try: float(temp_text) box.text += event.unicode except: if len(box.text) == 0: if event.unicode == "-" or event.unicode == '.': box.text += event.unicode if event.type == pygame.MOUSEMOTION: if x_button.isOver(pos): x_button.color = (255, 0, 0) else: x_button.color = (180, 0, 0) return ans_box
def tut2D_step3_window(screen, prev_win, windows): global angle_check global sigma1, sigma2, curr_angle Big_font = game_font(60) Small_font = game_font(25) extra_small_font = game_font(15) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 2-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-3", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) tut_text = [ "Now, using the center and radius being ", "the distance between the center and one ", "of the plotted points, draw a circle.", "Thus you get your Mohr's Circle", "The points where the circle cuts the X-axis", "are the principal stresses." ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 backButton.draw(screen, (0, 0, 0)) xButton = nextButton if angle_check == 0: xButton = finishButton xButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) try: mohr_2d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=0, σxy=float(tau_xy_tut.text), σyz=0, σzx=0) mohr_2d.ndims = 2 mohr_2d.isGraph = False if (angle_gen.text != ''): mohr_2d.isAngle_stress = True mohr_2d.reqAngle_stress_2d = float(angle_gen.text) _, sig, _, _, _, curr_angle = mohr_2d.stress_execute() sigma1, sigma2 = sig[0][0], sig[1][0] curr_angle = round(np.rad2deg(curr_angle), 2) answer_txt = "sigma_1 : " + str(sigma1) + ", sigma_2 : " + str( sigma2) + ", phi : " + str(curr_angle) + " deg" answer_txt = extra_small_font.render(answer_txt, 1, (0, 0, 0)) screen.blit(answer_txt, (50, 480)) except ValueError: # print(e) answer_txt = "sigma_1 : sigma_2 : phi" answer_txt = extra_small_font.render(answer_txt, 1, (0, 0, 0)) screen.blit(answer_txt, (50, 480)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut2D_step2_window_check.makeCurrent() tut2D_step3_window_check.endCurrent() if xButton.isOver(pos): if xButton == nextButton: tut2D_step3_window_check.endCurrent() tut2D_step4_window_check.makeCurrent() else: tut2D_step3_window_check.endCurrent() tut2D_final_window_check.makeCurrent() if graphButton.isOver(pos): req_mohr = tut_Stress_MohrCircle(float(sigma_xx_tut.text), float(sigma_yy_tut.text), float(tau_xy_tut.text)) req_mohr.ndims = 2 req_mohr.plot_circle()
def tut2D_stress_input_window(screen, prev_win, windows): global angle_check clock = pygame.time.Clock() input_boxes = { sigma_xx_tut: "sigma_xx", sigma_yy_tut: "sigma_yy", tau_xy_tut: "tau_xy", angle_tut: "angle" } Small_font = game_font(20) head_text = Small_font.render("Tutorial 2- D Mode", 1, (0, 0, 0)) for box in input_boxes.keys(): box_text = Small_font.render(input_boxes[box] + ":", 1, (0, 0, 0)) screen.blit(box_text, (box.x - 120, box.y)) screen.blit(head_text, (360, 100)) backButton.draw(screen, (0, 0, 0)) nextButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tutorialwindow_check.makeCurrent() tut2D_stress_input_window_check.endCurrent() if nextButton.isOver(pos): try: mohr_2d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=0, σxy=float(tau_xy_tut.text), σyz=0, σzx=0) mohr_2d.ndims = 2 mohr_2d.isGraph = False if (angle_tut.text != ''): mohr_2d.isAngle_stress = True angle_check = 1 mohr_2d.reqAngle_stress_2d = float(angle_tut.text) else: angle_check = 0 mohr_2d.stress_execute() tut2D_stress_input_window_check.endCurrent() tut2D_step1_window_check.makeCurrent() except: tut2D_stress_input_window_check.endCurrent() incompatible_input_window_check.makeCurrent() for box in input_boxes.keys(): if box.render().collidepoint(event.pos): print("click") box.active = True else: box.active = False box_text_input(event, input_boxes) if event.type == pygame.MOUSEMOTION: if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0) for box in input_boxes.keys(): txt_surface = Small_font.render(box.text, True, box.color) width = max(200, txt_surface.get_width() + 10) box.render().w = width screen.blit(txt_surface, (box.x + 5, box.y + 5)) pygame.draw.rect(screen, box.color, box.render(), 2) clock.tick(30)
def tut3D_step7_window(screen, prev_win, windows): Big_font = game_font(60) Small_font = game_font(25) extra_small_font = game_font(18) mid_font = game_font(40) # print(sigma_xx_tut.text, sigma_yy_tut.text, tau_xy_tut.text, angle_tut.text) head_text = Big_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) mid_text = mid_font.render("STEP-7", 1, (0, 0, 0)) screen.blit(head_text, (80, 70)) screen.blit(mid_text, (80, 150)) l = np.cos(np.deg2rad(float(angle1_tut.text))) m = np.cos(np.deg2rad(float(angle2_tut.text))) n = np.sqrt(1 - l**2 - m**2) if (n == None): n = 0 tut_text = [ "To find the the value of stresses on plane", "whose normal's direction vector is (l,m,n)", "l = cos(" + str(angle1_tut.text) + ") = " + str(round(l, 3)), "m = cos(" + str(angle2_tut.text) + ") = " + str(round(m, 3)), "n = sqrt(1 - l^2 -m^2) = " + str(round(n, 3)), ] tut2_text = [ "use the following formula to obtain normal", "and shear stress : ", "sig_normal = l^2*sig_1+m^2*sig_2+n^2*sig_3", "sig_shear = l^2*sig_1^2 + m^2*sig_2^2 + n^2*sig_3^2 - sig_normal^2", "PLot the point (sig_normal, sig_shear)" ] count = 0 for text in tut_text: text = Small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (70, 200 + count)) count += 40 count = 0 for text in tut2_text: text = extra_small_font.render(text, 1, (0, 0, 0)) screen.blit(text, (40, 400 + count)) count += 25 backButton.draw(screen, (0, 0, 0)) graphButton.draw(screen, (0, 0, 0)) finishButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tut3D_step6_window_check.makeCurrent() tut3D_step7_window_check.endCurrent() if finishButton.isOver(pos): tut3D_final_window_check.makeCurrent() tut3D_step7_window_check.endCurrent() if graphButton.isOver(pos): mohr_3d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=float(sigma_zz_tut.text), σxy=float(tau_xy_tut.text), σyz=float(tau_yz_tut.text), σzx=float(tau_zx_tut.text)) mohr_3d.ndims = 3 mohr_3d.isGraph = True if (angle1_tut.text != '' and angle2_tut.text != ''): angle_check = 1 mohr_3d.reqAngle_normal_3d = [ round(np.cos(np.deg2rad(float(angle1_tut.text))), 3), round(np.cos(np.deg2rad(float(angle2_tut.text))), 3), 0 ] mohr_3d.isAngle_stress = True mohr_3d.stress_execute()
def tut3D_stress_input_window(screen, prev_win, windows): global angle_check clock = pygame.time.Clock() input_boxes = { sigma_xx_tut: "sigma_xx", sigma_yy_tut: "sigma_yy", tau_xy_tut: "tau_xy", sigma_zz_tut: "sigma_zz", tau_yz_tut: "tau_yz", tau_zx_tut: "tau_zx", angle1_tut: "Angle x", angle2_tut: 'Angle y', angle3_tut: 'Angle z' } Small_font = game_font(20) head_text = Small_font.render("Tutorial 3-D Mode", 1, (0, 0, 0)) for box in input_boxes.keys(): box_text = Small_font.render(input_boxes[box] + ":", 1, (0, 0, 0)) screen.blit(box_text, (box.x - 120, box.y)) screen.blit(head_text, (360, 100)) backButton.draw(screen, (0, 0, 0)) enterButton.draw(screen, (0, 0, 0)) for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEBUTTONDOWN: if backButton.isOver(pos): tutorialwindow_check.makeCurrent() tut3D_stress_input_window_check.endCurrent() if enterButton.isOver(pos): mohrCircle_input = [] try: mohr_3d = Stress_MohrCircle(σxx=float(sigma_xx_tut.text), σyy=float(sigma_yy_tut.text), σzz=float(sigma_zz_tut.text), σxy=float(tau_xy_tut.text), σyz=float(tau_yz_tut.text), σzx=float(tau_zx_tut.text)) mohr_3d.ndims = 3 mohr_3d.isGraph = False if (angle1_tut.text != '' and angle2_tut.text != ''): angle_check = 1 mohr_3d.reqAngle_normal_3d = [ round(np.cos(np.deg2rad(float(angle1_tut.text))), 3), round(np.cos(np.deg2rad(float(angle2_tut.text))), 3), 0 ] mohr_3d.isAngle_stress = True mohr_3d.stress_execute() tut3D_stress_input_window_check.endCurrent() tut3D_step1_window_check.makeCurrent() except Exception as e: print(e) tut3D_stress_input_window_check.endCurrent() incompatible_input_window_check.makeCurrent() for box in input_boxes.keys(): if box.render().collidepoint(event.pos): print("click") box.active = True else: box.active = False box_text_input(event, input_boxes) if event.type == pygame.MOUSEMOTION: if backButton.isOver(pos): backButton.color = (255, 0, 0) else: backButton.color = (180, 0, 0) for box in input_boxes.keys(): txt_surface = Small_font.render(box.text, True, box.color) width = max(200, txt_surface.get_width() + 10) box.render().w = width screen.blit(txt_surface, (box.x + 5, box.y + 5)) pygame.draw.rect(screen, box.color, box.render(), 2) clock.tick(30)
def eval_window(screen, prev_win, windows): global userScore, show_graph, correct_answer, curr_question_type, quiz_question_type, user_concept_answer global sigma_xx, sigma_yy, sigma_zz, tau_xy, tau_yz, tau_zx, quest_nos, quest_index if curr_question_type != 'concept': mohr_2d = Stress_MohrCircle(σxx=sigma_xx, σyy=sigma_yy, σzz=sigma_zz, σxy=tau_xy, σyz=tau_yz, σzx=tau_zx) mohr_2d.ndims = 2 mohr_3d = Stress_MohrCircle(σxx=sigma_xx, σyy=sigma_yy, σzz=sigma_zz, σxy=tau_xy, σyz=tau_yz, σzx=tau_zx) mohr_3d.ndims = 3 x_button = nextButton if len(quiz_question_type) == 0: x_button = submitButton x_button.draw(screen, (0, 0, 0)) Big_font = game_font(40) Small_font = game_font(20) if (curr_question_type != "concept"): graphButton.draw(screen, (0, 0, 0)) isCorrect = False if show_graph == 0: if curr_question_type != 'concept': if curr_question_type == '2-D': mohr_2d.isGraph = False correct_answer = mohr_2d.stress_execute() correct_answer = correct_answer[0] elif curr_question_type == '3-D': mohr_2d.isGraph = False correct_answer = mohr_3d.stress_execute() correct_answer = correct_answer[0] try: if curr_question_type == "2-D": if correct_answer[0][0] < float( C1_gen.text) + 0.5 and correct_answer[0][0] > float( C1_gen.text) - 0.5: isCorrect = True if show_graph == 0: userScore += 5 elif curr_question_type == "3-D": user_answer = [[float(C1_gen.text)], [float(C2_gen.text)], [float(C3_gen.text)]] counter = 0 for k in user_answer: for l in correct_answer: if k[0] < l[0] + 0.5 and k[0] > l[0] - 0.5: counter += 1 break if counter == 3: isCorrect = True if show_graph == 0: userScore += 5 elif curr_question_type == 'concept': if (concept_quest[quest_nos[quest_index]][2] == user_concept_answer ): isCorrect = True if show_graph == 0: userScore += 5 except: pass show_graph += 1 if (isCorrect): text = Big_font.render("CORRECT :)", 1, (0, 0, 0)) screen.blit(text, (70, 250)) else: text = Big_font.render("WRONG :(", 1, (0, 0, 0)) screen.blit(text, (70, 250)) if curr_question_type == 'concept': line_brk = 0 exp_text = concept_quest[quest_nos[quest_index]][3] # print(exp_text) for exp in exp_text: exp = Small_font.render(exp, 1, (0, 0, 0)) screen.blit(exp, (70, 300 + line_brk)) line_brk += 20 for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: global running running = False if event.type == pygame.MOUSEMOTION: if (curr_question_type != "concept"): if graphButton.isOver(pos): graphButton.color = (255, 0, 0) else: graphButton.color = (180, 0, 0) if x_button.isOver(pos): x_button.color = (255, 0, 0) else: x_button.color = (180, 0, 0) if event.type == pygame.MOUSEBUTTONDOWN: if graphButton.isOver(pos): if curr_question_type != 'concept': if curr_question_type == '2-D': mohr_2d.isGraph = True mohr_2d.stress_execute() elif curr_question_type == '3-D': mohr_3d.isGraph = True mohr_3d.stress_execute() if x_button.isOver(pos): if len(quiz_question_type) > 0: # print(quiz_question_type[0]) show_graph = 0 if quiz_question_type[0] == '2-D': sigma_xx = round(random.randint(-30, 30), 2) sigma_yy = round(random.randint(-30, 30), 2) tau_xy = round(random.randint(-30, 30), 2) sigma_zz = 0 tau_yz = 0 tau_zx = 0 quiz_question_type = quiz_question_type[1:] eval_window_check.endCurrent() quizwindow_2d_check.makeCurrent() elif quiz_question_type[0] == '3-D': sigma_xx = round(random.randint(-30, 30), 2) sigma_yy = round(random.randint(-30, 30), 2) sigma_zz = round(random.randint(-30, 30), 2) tau_xy = round(random.randint(-30, 30), 2) tau_yz = round(random.randint(-30, 30), 2) tau_zx = round(random.randint(-30, 30), 2) quiz_question_type = quiz_question_type[1:] eval_window_check.endCurrent() quizwindow_3d_check.makeCurrent() elif quiz_question_type[0] == 'concept': user_concept_answer = -1 quiz_question_type = quiz_question_type[1:] quest_nos.remove(quest_nos[quest_index]) print(quest_nos) quest_index = random.randint(0, len(quest_nos) - 1) eval_window_check.endCurrent() quizwindow_concept_check.makeCurrent() else: eval_window_check.endCurrent() quiz_end_window_check.makeCurrent()