def draw_pallet(): # draw color / image pallet pythonGraph.draw_rectangle(0, 0, 29, 29, pythonGraph.colors.BLUE, True) pythonGraph.draw_rectangle(30, 0, 59, 29, pythonGraph.colors.YELLOW, True) pythonGraph.draw_rectangle(60, 0, 89, 29, pythonGraph.colors.GREEN, True) pythonGraph.draw_rectangle(90, 0, 119, 29, pythonGraph.colors.RED, True) pythonGraph.draw_image('lander.jpg', 120, 0, 29, 29)
def draw_on(): """ TODO #1: Complete and test the draw_on function. Functionality is described in the comments below. Test prior to continuing. """ if pythonGraph.mouse_button_down(pythonGraph.mouse_buttons.LEFT): if place_image == True: pythonGraph.draw_image('lander.jpg', mouse_x, mouse_y, 29, 29) else: pythonGraph.draw_circle(mouse_x, mouse_y, 10, color, True)
def draw_on(): # if the mouse is not on the pallet and the left mouse button is down do the following # if an image is to be drawn draw an image at the current mouse location # otherwise draw a circle at the current mouse location # if the mouse is not on the pallet and the left mouse button is down draw the image or the circle based # on global variables place_image if (mouse_y >= 30 or mouse_x >= 150) and pythonGraph.mouse_button_down( pythonGraph.mouse_buttons.LEFT): if not place_image: pythonGraph.draw_circle(mouse_x, mouse_y, radius, color, True) else: pythonGraph.draw_image('lander.jpg', mouse_x, mouse_y, 29, 29) if laser_on: pythonGraph.play_sound_effect('laser.wav')
def draw_rocket(): global rocket_x, rocket_y, rocket_width, rocket_height, rocket_ref pythonGraph.draw_image('rocket.png', rocket_x, rocket_y, rocket_width, rocket_height) #Draws the appropiate thrusters to match input if rocket_boost_up > 0.0: pythonGraph.draw_image('fired.png', rocket_x + rocket_width * .40, rocket_y + rocket_height * .95, rocket_width * .25, rocket_height * .25) if rocket_boost_right > 0.0: pythonGraph.draw_image('firel.png', rocket_x, rocket_y + rocket_height * .85, rocket_width * .25, rocket_height * .25) if rocket_boost_left < 0.0: pythonGraph.draw_image('firer.png', rocket_x + rocket_width * .85, rocket_y + rocket_height * .85, rocket_width * .25, rocket_height * .25)
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
def draw_boat(): global boat_x, boat_y, Vboat_x, boat_height, boat_width pythonGraph.draw_image('boat.png', boat_x, boat_y, boat_width, boat_height)