# -------------------------------------------------------------- # Analyzes the Results of the Simulation # -------------------------------------------------------------- def analyze_results(): pass # ----------------------------------------------------- # "Main Program" # ----------------------------------------------------- pythonGraph.open_window(WINDOW_WIDTH, WINDOW_HEIGHT) pythonGraph.set_window_title( "CS110Z (S20) Rocket Simulator - YOUR NAME GOES HERE") # Initializes the Simulation At Least Once initialize_simulation(True) # Main "Game Loop" while pythonGraph.window_not_closed(): if is_simulation_over() == False: erase_objects() draw_objects() get_input() update_objects() else: analyze_results() initialize_simulation(False) pythonGraph.update_window()
def analyze_results(): global time_elapsed, rocket_y, score, landings, crashes, max_score, boat_left_side, boat_right_side, rocket_right_side, rocket_left_side, fuel_consumed, AI_run_count rocket_left_side = rocket_x rocket_right_side = rocket_x + rocket_width boat_left_side = boat_x boat_right_side = boat_x + boat_width #End Screen Music pythonGraph.play_music('metroid16.mp3') #Score Calc if boat_left_side <= rocket_left_side and rocket_right_side < boat_right_side: score = 10000 - fuel_consumed - time_elapsed - Vrocket_x - Vrocket_y landings += 1 fuel_consumed = 0 else: score = 5000 - fuel_consumed - time_elapsed - Vrocket_x - Vrocket_y crashes += 1 fuel_consumed = 0 #Passes Score to Ai pex3_helper.score_ai(AI_run_count, score) #New highscore screen if score > max_score: max_score = score #Landing if boat_left_side <= rocket_left_side and rocket_right_side <= boat_right_side: pythonGraph.draw_image('win.png', 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) pythonGraph.draw_text("THE ROCKET HAS LANDED SAFELY!", WINDOW_WIDTH / 8, WINDOW_HEIGHT * 2 / 3 - 50, "WHITE", 100) pythonGraph.draw_text("NEW HIGHSCORE: " + str(round(score, 2)), WINDOW_WIDTH / 4, WINDOW_HEIGHT * 2 / 3 + 100, "WHITE", 100) pythonGraph.update_window() time.sleep(8.6) #Crash else: pythonGraph.draw_image('win.png', 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) pythonGraph.draw_text("THE ROCKET HAS CRASHED!", WINDOW_WIDTH / 5, WINDOW_HEIGHT * 2 / 3 - 50, "WHITE", 100) pythonGraph.draw_text("NEW HIGHSCORE: " + str(round(score, 2)), WINDOW_WIDTH / 4, WINDOW_HEIGHT * 2 / 3 + 100, "WHITE", 100) pythonGraph.update_window() time.sleep(8.6) #Score screen if it is not a new highscore else: #Landing if boat_left_side <= rocket_left_side and rocket_right_side <= boat_right_side: pythonGraph.draw_image('win.png', 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) pythonGraph.draw_text("THE ROCKET HAS LANDED SAFELY!", WINDOW_WIDTH / 8, WINDOW_HEIGHT * 2 / 3 - 50, "WHITE", 100) pythonGraph.draw_text("SCORE: " + str(round(score, 2)), WINDOW_WIDTH / 3, WINDOW_HEIGHT * 2 / 3 + 100, "WHITE", 100) pythonGraph.update_window() time.sleep(8.6) #Crash else: pythonGraph.draw_image('win.png', 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) pythonGraph.draw_text("THE ROCKET HAS CRASHED!", WINDOW_WIDTH / 5, WINDOW_HEIGHT * 2 / 3 - 50, "WHITE", 100) pythonGraph.draw_text("SCORE: " + str(round(score, 2)), WINDOW_WIDTH / 3, WINDOW_HEIGHT * 2 / 3 + 100, "WHITE", 100) pythonGraph.update_window() time.sleep(8.5) score = 0 time_elapsed = 0 rocket_y = rocket_height