From 23e4c7df54fda7a6e32ea595ac69583e27f4508b Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Fri, 21 Apr 2023 19:51:00 -0700 Subject: [PATCH 01/31] Fixed png error made png accessible to import for v5 graphics --- .../goalie.png => goalie.png | Bin .../soccer_ball.png => soccer_ball.png | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename Intro to Pygame Graphics/major league soccer animation/goalie.png => goalie.png (100%) rename Intro to Pygame Graphics/major league soccer animation/soccer_ball.png => soccer_ball.png (100%) diff --git a/Intro to Pygame Graphics/major league soccer animation/goalie.png b/goalie.png similarity index 100% rename from Intro to Pygame Graphics/major league soccer animation/goalie.png rename to goalie.png diff --git a/Intro to Pygame Graphics/major league soccer animation/soccer_ball.png b/soccer_ball.png similarity index 100% rename from Intro to Pygame Graphics/major league soccer animation/soccer_ball.png rename to soccer_ball.png From bf71c444b8198e2abc77e27d6cdd5bb0254f3ebc Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Mon, 24 Apr 2023 17:17:33 -0700 Subject: [PATCH 02/31] added a function to the draw_cloud --- .../major league soccer animation/README.md | 27 +++ .../graphics_v4.py | 214 +++++++++++++----- 2 files changed, 182 insertions(+), 59 deletions(-) create mode 100644 Intro to Pygame Graphics/major league soccer animation/README.md diff --git a/Intro to Pygame Graphics/major league soccer animation/README.md b/Intro to Pygame Graphics/major league soccer animation/README.md new file mode 100644 index 0000000..d5d07b6 --- /dev/null +++ b/Intro to Pygame Graphics/major league soccer animation/README.md @@ -0,0 +1,27 @@ +# Assignment 6 Read me [2520.02] +##graphics_v5.py + +Code Documentation: + +Program Objective lines 1-245: + Make the program easy to adapt to other programs and for modularity. + +Modification to clouds (lines 51-86): + + +Refresh rate (line 19) : + Allowed the user to choose the refresh rate + +Lights-on(line 92-103): + Allowed the user to use a True or False value for lights + +The modifications made to the code to allow for user input to control the day/night cycle and toggle the lights on/off: + +Added two boolean variables, day and lights_on, to represent the current state of the day/night cycle and lights status respectively. +Wrapped the event processing logic inside a for loop that iterates over all events in the event queue using pygame.event.get(). +Added event handling for two keys: 'l' to toggle the lights on/off, and 'd' to toggle between day and night mode. +Modified the game logic to use the day and lights_on variables to determine the appropriate colors for the sky, field, stripe, cloud, and fence based on the current state. +Added a function draw_cloud(x, y) to encapsulate the drawing logic for the cloud, which takes in the cloud's coordinates (x, y) as input parameters. +Moved the cloud drawing logic from the main game loop to the draw_cloud() function, and replaced the previously hard-coded color values with the cloud_color variable that is determined based on the day variable. +Removed the unused STAR_COLOR variable, as it was not used in the code. +These modifications allow the user to control the day/night cycle and toggle the lights on/off by pressing the 'd' and 'l' keys respectively during the game loop. diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index a05c6d8..c49ecb5 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -16,7 +16,7 @@ # Timer clock = pygame.time.Clock() -refresh_rate = 60 +refresh_rate = int(input("What do you want the refresh rate to be: ")) # Colors @@ -46,37 +46,108 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) -def draw_cloud(x, y): - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x, y + 8, 10, 10]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 6, y + 4, 8, 8]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 10, y, 16, 16]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 20, y + 8, 10, 10]) - pygame.draw.rect(SEE_THROUGH, cloud_color, [x + 6, y + 8, 18, 10]) +import pygame + +# Get user input for x_cloud, y_cloud, cloud_color, and cloud_size +x_cloud = int(input("Enter the x-coordinate of the cloud's top-left corner: ")) +y_cloud = int(input("Enter the y-coordinate of the cloud's top-left corner: ")) +cloud_color = tuple(map(int, input("Enter the color of the cloud in RGB format (comma-separated values): ").split(','))) +cloud_size = int(input("Enter the size of the cloud: ")) + +def draw_cloud(x_cloud, y_cloud, cloud_color, cloud_size): + """ + Draw a cloud at the given x, y coordinates with the specified color and size. + + Args: + x_cloud (int): The x-coordinate of the cloud's top-left corner. + y_cloud (int): The y-coordinate of the cloud's top-left corner. + cloud_color (tuple): The color of the cloud in RGB format, e.g. (255, 255, 255) for white. + cloud_size (int): The size of the cloud, which determines the size of the ellipses and rectangle. + + Returns: + None + """ + # Define the sizes of the ellipses and rectangle based on cloud_size + ellipse1_size = int(10 * cloud_size / 30) + ellipse2_size = int(8 * cloud_size / 30) + ellipse3_size = int(16 * cloud_size / 30) + ellipse4_size = int(10 * cloud_size / 30) + rect_width = int(18 * cloud_size / 30) + rect_height = int(10 * cloud_size / 30) + + # Draw the ellipses and rectangle with the specified color and sizes + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud, y_cloud + ellipse1_size, ellipse1_size, ellipse1_size]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(6 * cloud_size / 30), y_cloud + ellipse2_size, ellipse2_size, ellipse2_size]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(10 * cloud_size / 30), y_cloud, ellipse3_size, ellipse3_size]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(20 * cloud_size / 30), y_cloud + ellipse4_size, ellipse4_size, ellipse4_size]) + pygame.draw.rect(SEE_THROUGH, cloud_color, [x_cloud + int(6 * cloud_size / 30), y_cloud + ellipse1_size, rect_width, rect_height]) + +# Call the function with user input values +draw_cloud(x_cloud, y_cloud, cloud_color, cloud_size) + # Config -lights_on = True -day = True - -stars = [] -for n in range(200): - x = random.randrange(0, 800) - y = random.randrange(0, 200) - r = random.randrange(1, 2) - stars.append([x, y, r, r]) - -clouds = [] -for i in range(20): - x = random.randrange(-100, 1600) - y = random.randrange(0, 150) - clouds.append([x, y]) - -# Game loop -done = False +#True or False values +def are_lights_on(): + """ + Check if the lights are on. + + Returns: + bool: True if the lights are on, False otherwise. + """ + lights_on = input("Are the lights on:(yes/no) ") + if lights_on.lower() == "yes" or lights_on.lower() == "y": + return True + else: + return False -while not done: - # Event processing (React to key presses, mouse clicks, etc.) - ''' for now, we'll just check to see if the X is clicked ''' + +def is_day(): + """ + Check if it is day. + + Returns: + bool: True if it is day, False otherwise. + """ + day = input("Is it day?(yes/no) ") + if day.lower() == "yes" or day.lower() == "y": + return True + else: + return False + + +def generate_stars_and_clouds(): + """ + Generate stars and clouds for the animation, taking user input for the number of stars and clouds. + + Returns: + tuple: A tuple containing two lists: stars and clouds. + """ + num_stars = int(input("Enter the number of stars to generate: ")) + num_clouds = int(input("Enter the number of clouds to generate: ")) + + stars = [] + for n in range(num_stars): + x = random.randrange(0, 800) + y = random.randrange(0, 200) + r = random.randrange(1, 2) + stars.append([x, y, r, r]) + + clouds = [] + for i in range(num_clouds): + x = random.randrange(-100, 1600) + y = random.randrange(0, 150) + clouds.append([x, y]) + + return stars, clouds + + +stars, clouds = generate_stars_and_clouds() + + +def event_processing(): + global done, lights_on, day for event in pygame.event.get(): if event.type == pygame.QUIT: done = True @@ -86,8 +157,8 @@ def draw_cloud(x, y): elif event.key == pygame.K_d: day = not day - # Game logic (Check for collisions, update points, etc.) - ''' leave this section alone for now ''' +def game_logic(): + global light_color, sky_color, field_color, stripe_color, cloud_color if lights_on: light_color = YELLOW else: @@ -110,28 +181,25 @@ def draw_cloud(x, y): if c[0] < -100: c[0] = random.randrange(800, 1600) c[1] = random.randrange(0, 150) - - # Drawing code (Describe the picture. It isn't actually drawn yet.) + +def drawing_code(): + global screen screen.fill(sky_color) SEE_THROUGH.fill(ck) SEE_THROUGH.set_colorkey(ck) - + if not day: - #stars + # stars for s in stars: pygame.draw.ellipse(screen, WHITE, s) - - - pygame.draw.rect(screen, field_color, [0, 180, 800 , 420]) pygame.draw.rect(screen, stripe_color, [0, 180, 800, 42]) pygame.draw.rect(screen, stripe_color, [0, 264, 800, 52]) pygame.draw.rect(screen, stripe_color, [0, 368, 800, 62]) pygame.draw.rect(screen, stripe_color, [0, 492, 800, 82]) - - '''fence''' + # fence y = 170 for x in range(5, 800, 30): pygame.draw.polygon(screen, NIGHT_GRAY, [[x + 2, y], [x + 2, y + 15], [x, y + 15], [x, y]]) @@ -147,34 +215,62 @@ def draw_cloud(x, y): if day: pygame.draw.ellipse(screen, BRIGHT_YELLOW, [520, 50, 40, 40]) else: - pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) + pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) pygame.draw.ellipse(screen, sky_color, [530, 45, 40, 40]) - - for c in clouds: draw_cloud(c[0], c[1]) - screen.blit(SEE_THROUGH, (0, 0)) - + screen.blit(SEE_THROUGH, (0, 0)) - #out of bounds lines - pygame.draw.line(screen, WHITE, [0, 580], [800, 580], 5) - #left - pygame.draw.line(screen, WHITE, [0, 360], [140, 220], 5) - pygame.draw.line(screen, WHITE, [140, 220], [660, 220], 3) - #right - pygame.draw.line(screen, WHITE, [660, 220], [800, 360], 5) +done = False - #safety circle - pygame.draw.ellipse(screen, WHITE, [240, 500, 320, 160], 5) +while not done: + event_processing() + game_logic() + drawing_code() - #18 yard line goal box - pygame.draw.line(screen, WHITE, [260, 220], [180, 300], 5) - pygame.draw.line(screen, WHITE, [180, 300], [620, 300], 3) - pygame.draw.line(screen, WHITE, [620, 300], [540, 220], 5) + +def draw_soccer_field(): + """ + Draw the soccer field lines and arcs with user-input parameters. + """ + # Get user input for colors and thicknesses + out_of_bounds_color = tuple(map(int, input("Enter RGB values for out of bounds lines (comma-separated): ").split(','))) + left_color = tuple(map(int, input("Enter RGB values for left line (comma-separated): ").split(','))) + right_color = tuple(map(int, input("Enter RGB values for right line (comma-separated): ").split(','))) + safety_circle_color = tuple(map(int, input("Enter RGB values for safety circle (comma-separated): ").split(','))) + yard_line_color = tuple(map(int, input("Enter RGB values for 18 yard line (comma-separated): ").split(','))) + arc_color = tuple(map(int, input("Enter RGB values for arc (comma-separated): ").split(','))) + + # Get user input for thicknesses + out_of_bounds_thickness = int(input("Enter thickness for out of bounds lines: ")) + left_thickness = int(input("Enter thickness for left line: ")) + right_thickness = int(input("Enter thickness for right line: ")) + safety_circle_thickness = int(input("Enter thickness for safety circle: ")) + yard_line_thickness = int(input("Enter thickness for 18 yard line: ")) + arc_thickness = int(input("Enter thickness for arc: ")) + + # Define lines with same colors and thicknesses + lines = [ + {'start': [0, 580], 'end': [800, 580], 'color': out_of_bounds_color, 'thickness': out_of_bounds_thickness}, + {'start': [0, 360], 'end': [140, 220], 'color': left_color, 'thickness': left_thickness}, + {'start': [140, 220], 'end': [660, 220], 'color': left_color, 'thickness': left_thickness // 2}, + {'start': [660, 220], 'end': [800, 360], 'color': right_color, 'thickness': right_thickness}, + {'start': [260, 220], 'end': [180, 300], 'color': yard_line_color, 'thickness': yard_line_thickness}, + {'start': [180, 300], 'end': [620, 300], 'color': yard_line_color, 'thickness': yard_line_thickness // 2}, + {'start': [620, 300], 'end': [540, 220], 'color': yard_line_color, 'thickness': yard_line_thickness} + ] + + # Draw lines with same colors and thicknesses + for line in lines: + pygame.draw.line(screen, line['color'], line['start'], line['end'], line['thickness']) + + # Draw safety circle + pygame.draw.ellipse(screen, safety_circle_color, [240, 500, 320, 160], safety_circle_thickness) + + # Draw arc at the top of the goal box + pygame.draw.arc(screen, arc_color, [330, 280, 140, 40], math.pi, 2 * math.pi, arc_thickness) - #arc at the top of the goal box - pygame.draw.arc(screen, WHITE, [330, 280, 140, 40], math.pi, 2 * math.pi, 5) #score board pole pygame.draw.rect(screen, GRAY, [390, 120, 20, 70]) From 7e1909db6925042aac98ebb48bd447f35c16cdb4 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:08:20 -0700 Subject: [PATCH 03/31] Update README.md update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b681a2..f526e26 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# stuff \ No newline at end of file +# CS2520 Assignment 6 +refactoring functions From 8d93ce32ea18bd4591f9a07c7244d2a66472f973 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:09:22 -0700 Subject: [PATCH 04/31] Update graphics_v4.py --- .../graphics_v4.py | 366 ++++++------------ 1 file changed, 115 insertions(+), 251 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index c49ecb5..b06f286 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -16,7 +16,7 @@ # Timer clock = pygame.time.Clock() -refresh_rate = int(input("What do you want the refresh rate to be: ")) +refresh_rate = 60 # Colors @@ -46,108 +46,36 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) -import pygame - -# Get user input for x_cloud, y_cloud, cloud_color, and cloud_size -x_cloud = int(input("Enter the x-coordinate of the cloud's top-left corner: ")) -y_cloud = int(input("Enter the y-coordinate of the cloud's top-left corner: ")) -cloud_color = tuple(map(int, input("Enter the color of the cloud in RGB format (comma-separated values): ").split(','))) -cloud_size = int(input("Enter the size of the cloud: ")) - -def draw_cloud(x_cloud, y_cloud, cloud_color, cloud_size): - """ - Draw a cloud at the given x, y coordinates with the specified color and size. - - Args: - x_cloud (int): The x-coordinate of the cloud's top-left corner. - y_cloud (int): The y-coordinate of the cloud's top-left corner. - cloud_color (tuple): The color of the cloud in RGB format, e.g. (255, 255, 255) for white. - cloud_size (int): The size of the cloud, which determines the size of the ellipses and rectangle. - - Returns: - None - """ - # Define the sizes of the ellipses and rectangle based on cloud_size - ellipse1_size = int(10 * cloud_size / 30) - ellipse2_size = int(8 * cloud_size / 30) - ellipse3_size = int(16 * cloud_size / 30) - ellipse4_size = int(10 * cloud_size / 30) - rect_width = int(18 * cloud_size / 30) - rect_height = int(10 * cloud_size / 30) - - # Draw the ellipses and rectangle with the specified color and sizes - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud, y_cloud + ellipse1_size, ellipse1_size, ellipse1_size]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(6 * cloud_size / 30), y_cloud + ellipse2_size, ellipse2_size, ellipse2_size]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(10 * cloud_size / 30), y_cloud, ellipse3_size, ellipse3_size]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x_cloud + int(20 * cloud_size / 30), y_cloud + ellipse4_size, ellipse4_size, ellipse4_size]) - pygame.draw.rect(SEE_THROUGH, cloud_color, [x_cloud + int(6 * cloud_size / 30), y_cloud + ellipse1_size, rect_width, rect_height]) - -# Call the function with user input values -draw_cloud(x_cloud, y_cloud, cloud_color, cloud_size) - - +def draw_cloud(x, y): + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x, y + 8, 10, 10]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 6, y + 4, 8, 8]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 10, y, 16, 16]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 20, y + 8, 10, 10]) + pygame.draw.rect(SEE_THROUGH, cloud_color, [x + 6, y + 8, 18, 10]) # Config -#True or False values -def are_lights_on(): - """ - Check if the lights are on. - - Returns: - bool: True if the lights are on, False otherwise. - """ - lights_on = input("Are the lights on:(yes/no) ") - if lights_on.lower() == "yes" or lights_on.lower() == "y": - return True - else: - return False - - -def is_day(): - """ - Check if it is day. - - Returns: - bool: True if it is day, False otherwise. - """ - day = input("Is it day?(yes/no) ") - if day.lower() == "yes" or day.lower() == "y": - return True - else: - return False - - -def generate_stars_and_clouds(): - """ - Generate stars and clouds for the animation, taking user input for the number of stars and clouds. - - Returns: - tuple: A tuple containing two lists: stars and clouds. - """ - num_stars = int(input("Enter the number of stars to generate: ")) - num_clouds = int(input("Enter the number of clouds to generate: ")) - - stars = [] - for n in range(num_stars): - x = random.randrange(0, 800) - y = random.randrange(0, 200) - r = random.randrange(1, 2) - stars.append([x, y, r, r]) - - clouds = [] - for i in range(num_clouds): - x = random.randrange(-100, 1600) - y = random.randrange(0, 150) - clouds.append([x, y]) - - return stars, clouds - - -stars, clouds = generate_stars_and_clouds() - +lights_on = True +day = True + +stars = [] +for n in range(200): + x = random.randrange(0, 800) + y = random.randrange(0, 200) + r = random.randrange(1, 2) + stars.append([x, y, r, r]) + +clouds = [] +for i in range(20): + x = random.randrange(-100, 1600) + y = random.randrange(0, 150) + clouds.append([x, y]) -def event_processing(): - global done, lights_on, day +# Game loop +done = False + +while not done: + # Event processing (React to key presses, mouse clicks, etc.) + ''' for now, we'll just check to see if the X is clicked ''' for event in pygame.event.get(): if event.type == pygame.QUIT: done = True @@ -157,8 +85,8 @@ def event_processing(): elif event.key == pygame.K_d: day = not day -def game_logic(): - global light_color, sky_color, field_color, stripe_color, cloud_color + # Game logic (Check for collisions, update points, etc.) + ''' leave this section alone for now ''' if lights_on: light_color = YELLOW else: @@ -181,25 +109,28 @@ def game_logic(): if c[0] < -100: c[0] = random.randrange(800, 1600) c[1] = random.randrange(0, 150) - -def drawing_code(): - global screen + + # Drawing code (Describe the picture. It isn't actually drawn yet.) screen.fill(sky_color) SEE_THROUGH.fill(ck) SEE_THROUGH.set_colorkey(ck) - + if not day: - # stars + #stars for s in stars: pygame.draw.ellipse(screen, WHITE, s) + + + pygame.draw.rect(screen, field_color, [0, 180, 800 , 420]) pygame.draw.rect(screen, stripe_color, [0, 180, 800, 42]) pygame.draw.rect(screen, stripe_color, [0, 264, 800, 52]) pygame.draw.rect(screen, stripe_color, [0, 368, 800, 62]) pygame.draw.rect(screen, stripe_color, [0, 492, 800, 82]) - # fence + + '''fence''' y = 170 for x in range(5, 800, 30): pygame.draw.polygon(screen, NIGHT_GRAY, [[x + 2, y], [x + 2, y + 15], [x, y + 15], [x, y]]) @@ -215,78 +146,74 @@ def drawing_code(): if day: pygame.draw.ellipse(screen, BRIGHT_YELLOW, [520, 50, 40, 40]) else: - pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) + pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) pygame.draw.ellipse(screen, sky_color, [530, 45, 40, 40]) + + for c in clouds: draw_cloud(c[0], c[1]) - screen.blit(SEE_THROUGH, (0, 0)) - -done = False - -while not done: - event_processing() - game_logic() - drawing_code() - + screen.blit(SEE_THROUGH, (0, 0)) -def draw_soccer_field(): - """ - Draw the soccer field lines and arcs with user-input parameters. - """ - # Get user input for colors and thicknesses - out_of_bounds_color = tuple(map(int, input("Enter RGB values for out of bounds lines (comma-separated): ").split(','))) - left_color = tuple(map(int, input("Enter RGB values for left line (comma-separated): ").split(','))) - right_color = tuple(map(int, input("Enter RGB values for right line (comma-separated): ").split(','))) - safety_circle_color = tuple(map(int, input("Enter RGB values for safety circle (comma-separated): ").split(','))) - yard_line_color = tuple(map(int, input("Enter RGB values for 18 yard line (comma-separated): ").split(','))) - arc_color = tuple(map(int, input("Enter RGB values for arc (comma-separated): ").split(','))) - - # Get user input for thicknesses - out_of_bounds_thickness = int(input("Enter thickness for out of bounds lines: ")) - left_thickness = int(input("Enter thickness for left line: ")) - right_thickness = int(input("Enter thickness for right line: ")) - safety_circle_thickness = int(input("Enter thickness for safety circle: ")) - yard_line_thickness = int(input("Enter thickness for 18 yard line: ")) - arc_thickness = int(input("Enter thickness for arc: ")) - - # Define lines with same colors and thicknesses - lines = [ - {'start': [0, 580], 'end': [800, 580], 'color': out_of_bounds_color, 'thickness': out_of_bounds_thickness}, - {'start': [0, 360], 'end': [140, 220], 'color': left_color, 'thickness': left_thickness}, - {'start': [140, 220], 'end': [660, 220], 'color': left_color, 'thickness': left_thickness // 2}, - {'start': [660, 220], 'end': [800, 360], 'color': right_color, 'thickness': right_thickness}, - {'start': [260, 220], 'end': [180, 300], 'color': yard_line_color, 'thickness': yard_line_thickness}, - {'start': [180, 300], 'end': [620, 300], 'color': yard_line_color, 'thickness': yard_line_thickness // 2}, - {'start': [620, 300], 'end': [540, 220], 'color': yard_line_color, 'thickness': yard_line_thickness} - ] - - # Draw lines with same colors and thicknesses - for line in lines: - pygame.draw.line(screen, line['color'], line['start'], line['end'], line['thickness']) - - # Draw safety circle - pygame.draw.ellipse(screen, safety_circle_color, [240, 500, 320, 160], safety_circle_thickness) - - # Draw arc at the top of the goal box - pygame.draw.arc(screen, arc_color, [330, 280, 140, 40], math.pi, 2 * math.pi, arc_thickness) - - #score board pole - pygame.draw.rect(screen, GRAY, [390, 120, 20, 70]) + #out of bounds lines + pygame.draw.line(screen, WHITE, [0, 580], [800, 580], 5) + #left + pygame.draw.line(screen, WHITE, [0, 360], [140, 220], 5) + pygame.draw.line(screen, WHITE, [140, 220], [660, 220], 3) + #right + pygame.draw.line(screen, WHITE, [660, 220], [800, 360], 5) - #score board - pygame.draw.rect(screen, BLACK, [300, 40, 200, 90]) - pygame.draw.rect(screen, WHITE, [302, 42, 198, 88], 2) + #safety circle + pygame.draw.ellipse(screen, WHITE, [240, 500, 320, 160], 5) + #18 yard line goal box + pygame.draw.line(screen, WHITE, [260, 220], [180, 300], 5) + pygame.draw.line(screen, WHITE, [180, 300], [620, 300], 3) + pygame.draw.line(screen, WHITE, [620, 300], [540, 220], 5) - #goal - pygame.draw.rect(screen, WHITE, [320, 140, 160, 80], 5) - pygame.draw.line(screen, WHITE, [340, 200], [460, 200], 3) - pygame.draw.line(screen, WHITE, [320, 220], [340, 200], 3) - pygame.draw.line(screen, WHITE, [480, 220], [460, 200], 3) - pygame.draw.line(screen, WHITE, [320, 140], [340, 200], 3) - pygame.draw.line(screen, WHITE, [480, 140], [460, 200], 3) + #arc at the top of the goal box + pygame.draw.arc(screen, WHITE, [330, 280, 140, 40], math.pi, 2 * math.pi, 5) + + # function to draw score board in the center of the screen behind goal net + def score_board(pole_thick,board_length,board_height): + pygame.draw.rect(screen, GRAY, [390, 120, pole_thick, 70]) + pygame.draw.rect(screen, BLACK, [400- board_length//2, 40, board_length, board_height]) + pygame.draw.rect(screen, WHITE, [402 - board_length//2, 42, board_length-2, board_height-2], 2) + + #drawing the score baord + score_board(20, 200, 90) + + #goal is always in the center just like the board + #drawing a goal with net in the center of the screen + def goal(length,height,color): + left_index = 400 - length // 2 + pygame.draw.rect(screen, color, [left_index, 140, length, height], 5) + lowerlength = length - 40 + lowerIndex = 400 - lowerlength // 2 + pygame.draw.line(screen, color, [lowerIndex, 200], [400 + lowerlength // 2 , 200], 3) + + pygame.draw.line(screen, color, [left_index, 220], [420 - length // 2, 200], 3) + pygame.draw.line(screen, color, [400 + length // 2, 220], [380 + length // 2, 200], 3) + + pygame.draw.line(screen, WHITE, [left_index, 140], [420 - length // 2, 200], 3) + pygame.draw.line(screen, WHITE, [400 + length // 2, 140], [380 + length // 2, 200], 3) + + #goal net vertical + for i in range(1, length // 3 + 1): + slice = lowerlength // ( length / 3 ) + pygame.draw.line(screen,color,[left_index + i * 3 ,140],[lowerIndex + i * slice + 1, 200],1) + #goal net horizontal + for i in range(1,height // 4 ): + pygame.draw.line(screen, color, [left_index , 140 + 4 * i], [400 + length // 2 , 140 + 4 * i], 1) + + #goal net left triagle + for i in range(1,9): + pygame.draw.line(screen, color, [320, 140], [322 + 2 * i, 218 - 2 * i], 1) + pygame.draw.line(screen, color, [480, 140], [478 - 2 * i, 218 - 2 * i], 1) + + #drawing goal and its net + goal(160,80,WHITE) #6 yard line goal box pygame.draw.line(screen, WHITE, [310, 220], [270, 270], 3) @@ -316,9 +243,7 @@ def draw_soccer_field(): pygame.draw.rect(screen, GRAY, [630, 60, 20, 140]) pygame.draw.ellipse(screen, GRAY, [630, 195, 20, 10]) - #lights - - + #lights pygame.draw.line(screen, GRAY, [590, 60], [690, 60], 2) pygame.draw.ellipse(screen, light_color, [590, 40, 20, 20]) pygame.draw.ellipse(screen, light_color, [610, 40, 20, 20]) @@ -333,89 +258,28 @@ def draw_soccer_field(): pygame.draw.ellipse(screen, light_color, [670, 20, 20, 20]) pygame.draw.line(screen, GRAY, [590, 20], [690, 20], 2) - #net - pygame.draw.line(screen, WHITE, [325, 140], [341, 200], 1) - pygame.draw.line(screen, WHITE, [330, 140], [344, 200], 1) - pygame.draw.line(screen, WHITE, [335, 140], [347, 200], 1) - pygame.draw.line(screen, WHITE, [340, 140], [350, 200], 1) - pygame.draw.line(screen, WHITE, [345, 140], [353, 200], 1) - pygame.draw.line(screen, WHITE, [350, 140], [356, 200], 1) - pygame.draw.line(screen, WHITE, [355, 140], [359, 200], 1) - pygame.draw.line(screen, WHITE, [360, 140], [362, 200], 1) - pygame.draw.line(screen, WHITE, [364, 140], [365, 200], 1) - pygame.draw.line(screen, WHITE, [368, 140], [369, 200], 1) - pygame.draw.line(screen, WHITE, [372, 140], [373, 200], 1) - pygame.draw.line(screen, WHITE, [376, 140], [377, 200], 1) - pygame.draw.line(screen, WHITE, [380, 140], [380, 200], 1) - pygame.draw.line(screen, WHITE, [384, 140], [384, 200], 1) - pygame.draw.line(screen, WHITE, [388, 140], [388, 200], 1) - pygame.draw.line(screen, WHITE, [392, 140], [392, 200], 1) - pygame.draw.line(screen, WHITE, [396, 140], [396, 200], 1) - pygame.draw.line(screen, WHITE, [400, 140], [400, 200], 1) - pygame.draw.line(screen, WHITE, [404, 140], [404, 200], 1) - pygame.draw.line(screen, WHITE, [408, 140], [408, 200], 1) - pygame.draw.line(screen, WHITE, [412, 140], [412, 200], 1) - pygame.draw.line(screen, WHITE, [416, 140], [416, 200], 1) - pygame.draw.line(screen, WHITE, [420, 140], [420, 200], 1) - pygame.draw.line(screen, WHITE, [424, 140], [423, 200], 1) - pygame.draw.line(screen, WHITE, [428, 140], [427, 200], 1) - pygame.draw.line(screen, WHITE, [432, 140], [431, 200], 1) - pygame.draw.line(screen, WHITE, [436, 140], [435, 200], 1) - pygame.draw.line(screen, WHITE, [440, 140], [438, 200], 1) - pygame.draw.line(screen, WHITE, [445, 140], [441, 200], 1) - pygame.draw.line(screen, WHITE, [450, 140], [444, 200], 1) - pygame.draw.line(screen, WHITE, [455, 140], [447, 200], 1) - pygame.draw.line(screen, WHITE, [460, 140], [450, 200], 1) - pygame.draw.line(screen, WHITE, [465, 140], [453, 200], 1) - pygame.draw.line(screen, WHITE, [470, 140], [456, 200], 1) - pygame.draw.line(screen, WHITE, [475, 140], [459, 200], 1) - - #net part 2 - pygame.draw.line(screen, WHITE, [320, 140], [324, 216], 1) - pygame.draw.line(screen, WHITE, [320, 140], [326, 214], 1) - pygame.draw.line(screen, WHITE, [320, 140], [328, 212], 1) - pygame.draw.line(screen, WHITE, [320, 140], [330, 210], 1) - pygame.draw.line(screen, WHITE, [320, 140], [332, 208], 1) - pygame.draw.line(screen, WHITE, [320, 140], [334, 206], 1) - pygame.draw.line(screen, WHITE, [320, 140], [336, 204], 1) - pygame.draw.line(screen, WHITE, [320, 140], [338, 202], 1) - - #net part 3 - pygame.draw.line(screen, WHITE, [480, 140], [476, 216], 1) - pygame.draw.line(screen, WHITE, [480, 140], [474, 214], 1) - pygame.draw.line(screen, WHITE, [480, 140], [472, 212], 1) - pygame.draw.line(screen, WHITE, [480, 140], [470, 210], 1) - pygame.draw.line(screen, WHITE, [480, 140], [468, 208], 1) - pygame.draw.line(screen, WHITE, [480, 140], [466, 206], 1) - pygame.draw.line(screen, WHITE, [480, 140], [464, 204], 1) - pygame.draw.line(screen, WHITE, [480, 140], [462, 202], 1) - - #net part 4 - pygame.draw.line(screen, WHITE, [324, 144], [476, 144], 1) - pygame.draw.line(screen, WHITE, [324, 148], [476, 148], 1) - pygame.draw.line(screen, WHITE, [324, 152], [476, 152], 1) - pygame.draw.line(screen, WHITE, [324, 156], [476, 156], 1) - pygame.draw.line(screen, WHITE, [324, 160], [476, 160], 1) - pygame.draw.line(screen, WHITE, [324, 164], [476, 164], 1) - pygame.draw.line(screen, WHITE, [324, 168], [476, 168], 1) - pygame.draw.line(screen, WHITE, [324, 172], [476, 172], 1) - pygame.draw.line(screen, WHITE, [324, 176], [476, 176], 1) - pygame.draw.line(screen, WHITE, [335, 180], [470, 180], 1) - pygame.draw.line(screen, WHITE, [335, 184], [465, 184], 1) - pygame.draw.line(screen, WHITE, [335, 188], [465, 188], 1) - pygame.draw.line(screen, WHITE, [335, 192], [465, 192], 1) - pygame.draw.line(screen, WHITE, [335, 196], [465, 196], 1) + #function to draw left and right stands + def draw_stand(front_color,back_color): + pygame.draw.polygon(screen, front_color, [[680, 220], [800, 340], [800, 290], [680, 180]]) + pygame.draw.polygon(screen, back_color, [[680, 180], [800, 100], [800, 290]]) + pygame.draw.polygon(screen, front_color, [[120, 220], [0, 340], [0, 290], [120, 180]]) + pygame.draw.polygon(screen, back_color, [[120, 180], [0, 100], [0, 290]]) + + #draw left and right stands + draw_stand(RED,GREEN) #stands right - pygame.draw.polygon(screen, RED, [[680, 220], [800, 340], [800, 290], [680, 180]]) - pygame.draw.polygon(screen, WHITE, [[680, 180], [800, 100], [800, 290]]) + #pygame.draw.polygon(screen, RED, [[680, 220], [800, 340], [800, 290], [680, 180]]) + #pygame.draw.polygon(screen, WHITE, [[680, 180], [800, 100], [800, 290]]) - #stands left - pygame.draw.polygon(screen, RED, [[120, 220], [0, 340], [0, 290], [120, 180]]) - pygame.draw.polygon(screen, WHITE, [[120, 180], [0, 100], [0, 290]]) + #pygame.draw.polygon(screen, RED, [[120, 220], [0, 340], [0, 290], [120, 180]]) + #pygame.draw.polygon(screen, WHITE, [[120, 180], [0, 100], [0, 290]]) #people + def draw_flag(stick_color, flag_color, x,y): + pygame.draw.line(screen, stick_color [x, 220], [x, y], 3) + pygame.draw.polygon(screen, flag_color, [[132, 190], [125, 196], [135, 205]]) #corner flag right pygame.draw.line(screen, BRIGHT_YELLOW, [140, 220], [135, 190], 3) From f50f3d063681b9a517c5f80c74eee115995408fa Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:09:33 -0700 Subject: [PATCH 05/31] Add files via upload update functions for draw net --- .../graphics_v4.py | 160 ++++++++++-------- 1 file changed, 89 insertions(+), 71 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index b06f286..32b1f8b 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -187,6 +187,13 @@ def score_board(pole_thick,board_length,board_height): #goal is always in the center just like the board #drawing a goal with net in the center of the screen def goal(length,height,color): + """ + goal draws a goal net based on its length, height, and color + + :length: length of the rectangle shape goal net + :height: height of the rectangle shape goal net + :color: color of the goal net + """ left_index = 400 - length // 2 pygame.draw.rect(screen, color, [left_index, 140, length, height], 5) lowerlength = length - 40 @@ -201,65 +208,68 @@ def goal(length,height,color): #goal net vertical for i in range(1, length // 3 + 1): - slice = lowerlength // ( length / 3 ) - pygame.draw.line(screen,color,[left_index + i * 3 ,140],[lowerIndex + i * slice + 1, 200],1) + slice = lowerlength / ( length / 3 ) + pygame.draw.line(screen,color,[left_index + i * 3 ,140],[lowerIndex + i * slice , 200],1) #goal net horizontal for i in range(1,height // 4 ): pygame.draw.line(screen, color, [left_index , 140 + 4 * i], [400 + length // 2 , 140 + 4 * i], 1) - #goal net left triagle + #goal net left and right triagle for i in range(1,9): - pygame.draw.line(screen, color, [320, 140], [322 + 2 * i, 218 - 2 * i], 1) - pygame.draw.line(screen, color, [480, 140], [478 - 2 * i, 218 - 2 * i], 1) - - #drawing goal and its net - goal(160,80,WHITE) - - #6 yard line goal box - pygame.draw.line(screen, WHITE, [310, 220], [270, 270], 3) - pygame.draw.line(screen, WHITE, [270, 270], [530, 270], 2) - pygame.draw.line(screen, WHITE, [530, 270], [490, 220], 3) - - #light pole 1 - pygame.draw.rect(screen, GRAY, [150, 60, 20, 140]) - pygame.draw.ellipse(screen, GRAY, [150, 195, 20, 10]) - - #lights - pygame.draw.line(screen, GRAY, [110, 60], [210, 60], 2) - pygame.draw.ellipse(screen, light_color, [110, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [130, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [150, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [170, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [190, 40, 20, 20]) - pygame.draw.line(screen, GRAY, [110, 40], [210, 40], 2) - pygame.draw.ellipse(screen, light_color, [110, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [130, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [150, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [170, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [190, 20, 20, 20]) - pygame.draw.line(screen, GRAY, [110, 20], [210, 20], 2) - - #light pole 2 - pygame.draw.rect(screen, GRAY, [630, 60, 20, 140]) - pygame.draw.ellipse(screen, GRAY, [630, 195, 20, 10]) - - #lights - pygame.draw.line(screen, GRAY, [590, 60], [690, 60], 2) - pygame.draw.ellipse(screen, light_color, [590, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [610, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [630, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [650, 40, 20, 20]) - pygame.draw.ellipse(screen, light_color, [670, 40, 20, 20]) - pygame.draw.line(screen, GRAY, [590, 40], [690, 40], 2) - pygame.draw.ellipse(screen, light_color, [590, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [610, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [630, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [650, 20, 20, 20]) - pygame.draw.ellipse(screen, light_color, [670, 20, 20, 20]) - pygame.draw.line(screen, GRAY, [590, 20], [690, 20], 2) + pygame.draw.line(screen, color, [left_index, 140], [left_index + 2 + 2 * i, 218 - 2 * i], 1) + pygame.draw.line(screen, color, [400 + length // 2, 140], [398 + length // 2 - 2 * i, 218 - 2 * i], 1) + + #drawing goal and its net based on its length, height, and color + goal(260,80,WHITE) + + #function to draw line goal box based on color + def draw_line_goal_box(color): + """ + draw_line_goal_box draws the line in front of the goal net based on the provided color + + :color: color of the boal box line + """ + pygame.draw.line(screen, color, [310, 220], [270, 270], 3) + pygame.draw.line(screen, color, [270, 270], [530, 270], 2) + pygame.draw.line(screen, color, [530, 270], [490, 220], 3) + + draw_line_goal_box(WHITE) + + #function to draw light based on its x index + def draw_light(x_index): + """ + draw_light draws the light of the court based on the provided x index + + :x_index: x index of the light pole bottom + """ + pygame.draw.rect(screen, GRAY, [x_index, 60, 20, 140]) + pygame.draw.ellipse(screen, GRAY, [x_index, 195, 20, 10]) + + pygame.draw.line(screen, GRAY, [x_index - 40, 60], [x_index + 60, 60], 2) + pygame.draw.ellipse(screen, light_color, [x_index - 40, 40, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index - 20, 40, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index , 40, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index + 20, 40, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index + 40, 40, 20, 20]) + pygame.draw.line(screen, GRAY, [x_index - 40, 40], [x_index + 60, 40], 2) + pygame.draw.ellipse(screen, light_color, [x_index - 40, 20, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index - 20, 20, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index, 20, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index + 20, 20, 20, 20]) + pygame.draw.ellipse(screen, light_color, [x_index + 40, 20, 20, 20]) + pygame.draw.line(screen, GRAY, [x_index - 40, 20], [x_index + 60, 20], 2) + + #drawing left and right light + draw_light(150) + draw_light(590) #function to draw left and right stands def draw_stand(front_color,back_color): + """ + draw_stand draws the left and right viewer stands based on the provided color + :front_color: front color of the stand + :back_color: back color of the stand + """ pygame.draw.polygon(screen, front_color, [[680, 220], [800, 340], [800, 290], [680, 180]]) pygame.draw.polygon(screen, back_color, [[680, 180], [800, 100], [800, 290]]) pygame.draw.polygon(screen, front_color, [[120, 220], [0, 340], [0, 290], [120, 180]]) @@ -268,26 +278,34 @@ def draw_stand(front_color,back_color): #draw left and right stands draw_stand(RED,GREEN) - #stands right - #pygame.draw.polygon(screen, RED, [[680, 220], [800, 340], [800, 290], [680, 180]]) - #pygame.draw.polygon(screen, WHITE, [[680, 180], [800, 100], [800, 290]]) - - #stands left - #pygame.draw.polygon(screen, RED, [[120, 220], [0, 340], [0, 290], [120, 180]]) - #pygame.draw.polygon(screen, WHITE, [[120, 180], [0, 100], [0, 290]]) - #people - - def draw_flag(stick_color, flag_color, x,y): - pygame.draw.line(screen, stick_color [x, 220], [x, y], 3) - pygame.draw.polygon(screen, flag_color, [[132, 190], [125, 196], [135, 205]]) - - #corner flag right - pygame.draw.line(screen, BRIGHT_YELLOW, [140, 220], [135, 190], 3) - pygame.draw.polygon(screen, RED, [[132, 190], [125, 196], [135, 205]]) - - #corner flag left - pygame.draw.line(screen, BRIGHT_YELLOW, [660, 220], [665, 190], 3) - pygame.draw.polygon(screen, RED, [[668, 190], [675, 196], [665, 205]]) + #draw flag that is tilted left based on xy index and its color + def draw_left_flag(stick_color, flag_color, x, y): + """ + draw_left_flag draws a small flag t that tilted left based on xy index and its color + + :stick_color: stick color + :flag_color: flag color + :x: x index + :y: y index + """ + pygame.draw.line(screen, stick_color, [x + 5, y + 30], [x, y], 3) + pygame.draw.polygon(screen, flag_color, [[x - 3, y], [x - 10, y + 6], [ x, y + 15]]) + + #draw flag that is tilted right based on xy index and its color + def draw_right_flag(stick_color, flag_color, x, y): + """ + draw_left_flag draws a small flag t that tilted right based on xy index and its color + + :stick_color: stick color + :flag_color: flag color + :x: x index + :y: y index + """ + pygame.draw.line(screen, stick_color, [x - 5, y + 30], [x, y], 3) + pygame.draw.polygon(screen, flag_color, [[x + 3, y], [x + 10, y + 6], [x, y + 15]]) + + draw_left_flag(YELLOW, RED, 135, 190) + draw_right_flag(BRIGHT_YELLOW, RED, 665, 190) # DARKNESS if not day and not lights_on: From a8aa890b78455e22b2647acee5d99f738a5e27d7 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:18:48 -0700 Subject: [PATCH 06/31] Add files via upload fixing some bug on draw net From b88f94aaabfbd5423de5d337190209f216ee5774 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:23:11 -0700 Subject: [PATCH 07/31] updates to draw_cloud --- .../major league soccer animation/graphics_v4.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 32b1f8b..3101e90 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -46,13 +46,14 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) +#simplier function that uses loops to draw clouds def draw_cloud(x, y): - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x, y + 8, 10, 10]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 6, y + 4, 8, 8]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 10, y, 16, 16]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 20, y + 8, 10, 10]) + ellipses = [[x, y + 8, 10, 10], [x + 6, y + 4, 8, 8], [x + 10, y, 16, 16], [x + 20, y + 8, 10, 10]] + for ellipse in ellipses: + pygame.draw.ellipse(SEE_THROUGH, cloud_color, ellipse) pygame.draw.rect(SEE_THROUGH, cloud_color, [x + 6, y + 8, 18, 10]) + # Config lights_on = True day = True From 48de9855f2b6ba2b3bb5a2229660528475f61383 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:25:13 -0700 Subject: [PATCH 08/31] Update README.md Specify changes on README.md --- .../major league soccer animation/README.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Intro to Pygame Graphics/major league soccer animation/README.md b/Intro to Pygame Graphics/major league soccer animation/README.md index d5d07b6..712ccd5 100644 --- a/Intro to Pygame Graphics/major league soccer animation/README.md +++ b/Intro to Pygame Graphics/major league soccer animation/README.md @@ -25,3 +25,45 @@ Added a function draw_cloud(x, y) to encapsulate the drawing logic for the cloud Moved the cloud drawing logic from the main game loop to the draw_cloud() function, and replaced the previously hard-coded color values with the cloud_color variable that is determined based on the day variable. Removed the unused STAR_COLOR variable, as it was not used in the code. These modifications allow the user to control the day/night cycle and toggle the lights on/off by pressing the 'd' and 'l' keys respectively during the game loop. + +goal(length,height,color): + goal draws a goal net based on its length, height, and color +Parameter: + :length: length of the rectangle shape goal net + :height: height of the rectangle shape goal net + :color: color of the goal net + +draw_line_goal_box(color): + draw_line_goal_box draws the line in front of the goal net based on the provided color +Parameter: + :color: color of the boal box line + + +draw_light(x_index): + draw_light draws the light of the court based on the provided x index +Parameter: + :x_index: x index of the light pole bottom + + +def draw_stand(front_color,back_color): + draw_stand draws the left and right viewer stands based on the provided color +Parameter: + :front_color: front color of the stand + :back_color: back color of the stand + +def draw_left_flag(stick_color, flag_color, x, y): + draw_left_flag draws a small flag t that tilted left based on xy index and its color +Parameter: + :stick_color: stick color + :flag_color: flag color + :x: x index + :y: y index + + draw_right_flag(stick_color, flag_color, x, y): + draw_left_flag draws a small flag t that tilted right based on xy index and its color +Parameter: + :stick_color: stick color + :flag_color: flag color + :x: x index + :y: y index + From 4a244aab8936989ef500841a465a6f788de83b4d Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:25:48 -0700 Subject: [PATCH 09/31] Update README.md edit readme --- .../major league soccer animation/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/README.md b/Intro to Pygame Graphics/major league soccer animation/README.md index 712ccd5..7700a48 100644 --- a/Intro to Pygame Graphics/major league soccer animation/README.md +++ b/Intro to Pygame Graphics/major league soccer animation/README.md @@ -52,7 +52,7 @@ Parameter: :back_color: back color of the stand def draw_left_flag(stick_color, flag_color, x, y): - draw_left_flag draws a small flag t that tilted left based on xy index and its color + draw_left_flag draws a small flag t that tilted left based on x and y index and its color Parameter: :stick_color: stick color :flag_color: flag color @@ -60,7 +60,7 @@ Parameter: :y: y index draw_right_flag(stick_color, flag_color, x, y): - draw_left_flag draws a small flag t that tilted right based on xy index and its color + draw_left_flag draws a small flag t that tilted right based on x and y index and its color Parameter: :stick_color: stick color :flag_color: flag color From 8dc59043896e66f3abac81429473eb83c8f6790e Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:25:49 -0700 Subject: [PATCH 10/31] simplified star and cloud --- .../major league soccer animation/graphics_v4.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 3101e90..7c81e29 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -58,18 +58,10 @@ def draw_cloud(x, y): lights_on = True day = True -stars = [] -for n in range(200): - x = random.randrange(0, 800) - y = random.randrange(0, 200) - r = random.randrange(1, 2) - stars.append([x, y, r, r]) - -clouds = [] -for i in range(20): - x = random.randrange(-100, 1600) - y = random.randrange(0, 150) - clouds.append([x, y]) +#simplied the star and cloud loops +stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] +clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] + # Game loop done = False From 3f370d18ed843a072cef01ebe114e1dd18d5de91 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:28:40 -0700 Subject: [PATCH 11/31] update current changes --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f526e26..837b5d1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # CS2520 Assignment 6 refactoring functions + +updated star and cloud loops: + This code uses list comprehension to create the stars and clouds lists in a more concise way. It also eliminates the need for temporary variables x, y, and r. + +simplied draw_cloud: + This code stores the ellipse coordinates and dimensions in a list and then iterates over the list to draw each ellipse using a loop. This reduces the number of lines of code from 5 to 2. From f786c0a3e2fe16943c160d0b8a52535d99f2a3af Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:29:16 -0700 Subject: [PATCH 12/31] added member --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 837b5d1..5e4e5ff 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,7 @@ updated star and cloud loops: simplied draw_cloud: This code stores the ellipse coordinates and dimensions in a list and then iterates over the list to draw each ellipse using a loop. This reduces the number of lines of code from 5 to 2. + + +Members: +Natalia Jauregui From 03673175375f4cbe0eaefba6cb1e635b9db67fc4 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:30:23 -0700 Subject: [PATCH 13/31] added the location of project --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4e5ff..9f9b6b8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CS2520 Assignment 6 -refactoring functions +project is located under Intro to Pygame Graphics > major league soccer animation > graphics_v4.py updated star and cloud loops: This code uses list comprehension to create the stars and clouds lists in a more concise way. It also eliminates the need for temporary variables x, y, and r. From dbd2a9916aadfe7b57ec26db4c362c2fbe86a721 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:32:55 -0700 Subject: [PATCH 14/31] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9f9b6b8..4454b0e 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,4 @@ simplied draw_cloud: Members: Natalia Jauregui +Haosi Lin From b6f98036d0966b4002c83d6078075a1c92966977 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:35:00 -0700 Subject: [PATCH 15/31] Update README.md --- .../major league soccer animation/README.md | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/README.md b/Intro to Pygame Graphics/major league soccer animation/README.md index 7700a48..a8eac3f 100644 --- a/Intro to Pygame Graphics/major league soccer animation/README.md +++ b/Intro to Pygame Graphics/major league soccer animation/README.md @@ -26,44 +26,15 @@ Moved the cloud drawing logic from the main game loop to the draw_cloud() functi Removed the unused STAR_COLOR variable, as it was not used in the code. These modifications allow the user to control the day/night cycle and toggle the lights on/off by pressing the 'd' and 'l' keys respectively during the game loop. -goal(length,height,color): - goal draws a goal net based on its length, height, and color -Parameter: - :length: length of the rectangle shape goal net - :height: height of the rectangle shape goal net - :color: color of the goal net - -draw_line_goal_box(color): - draw_line_goal_box draws the line in front of the goal net based on the provided color -Parameter: - :color: color of the boal box line +goal(length,height,color): draws a goal net based on its length, height, and color +draw_line_goal_box(color): draws the line in front of the goal net based on the provided color -draw_light(x_index): - draw_light draws the light of the court based on the provided x index -Parameter: - :x_index: x index of the light pole bottom +draw_light(x_index): draws the light of the court based on the provided x index -def draw_stand(front_color,back_color): - draw_stand draws the left and right viewer stands based on the provided color -Parameter: - :front_color: front color of the stand - :back_color: back color of the stand +draw_stand(front_color,back_color): draws the left and right viewer stands based on the provided color -def draw_left_flag(stick_color, flag_color, x, y): - draw_left_flag draws a small flag t that tilted left based on x and y index and its color -Parameter: - :stick_color: stick color - :flag_color: flag color - :x: x index - :y: y index +draw_left_flag(stick_color, flag_color, x, y): draws a small flag t that tilted left based on x and y index and its color - draw_right_flag(stick_color, flag_color, x, y): - draw_left_flag draws a small flag t that tilted right based on x and y index and its color -Parameter: - :stick_color: stick color - :flag_color: flag color - :x: x index - :y: y index - +draw_right_flag(stick_color, flag_color, x, y): draws a small flag t that tilted right based on x and y index and its color From 92329b0b0eff612f2c763cbfc70a771e69ed13b1 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:35:48 -0700 Subject: [PATCH 16/31] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 4454b0e..6c4fa2f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,19 @@ updated star and cloud loops: simplied draw_cloud: This code stores the ellipse coordinates and dimensions in a list and then iterates over the list to draw each ellipse using a loop. This reduces the number of lines of code from 5 to 2. + +goal(length,height,color): draws a goal net based on its length, height, and color + +draw_line_goal_box(color): draws the line in front of the goal net based on the provided color + +draw_light(x_index): draws the light of the court based on the provided x index + + +draw_stand(front_color,back_color): draws the left and right viewer stands based on the provided color + +draw_left_flag(stick_color, flag_color, x, y): draws a small flag t that tilted left based on x and y index and its color + +draw_right_flag(stick_color, flag_color, x, y): draws a small flag t that tilted right based on x and y index and its color Members: From 8d6d2e3cfd070b2772d2f1d1a4fe37796c7a2494 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:35:55 -0700 Subject: [PATCH 17/31] Delete README.md --- .../major league soccer animation/README.md | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 Intro to Pygame Graphics/major league soccer animation/README.md diff --git a/Intro to Pygame Graphics/major league soccer animation/README.md b/Intro to Pygame Graphics/major league soccer animation/README.md deleted file mode 100644 index a8eac3f..0000000 --- a/Intro to Pygame Graphics/major league soccer animation/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Assignment 6 Read me [2520.02] -##graphics_v5.py - -Code Documentation: - -Program Objective lines 1-245: - Make the program easy to adapt to other programs and for modularity. - -Modification to clouds (lines 51-86): - - -Refresh rate (line 19) : - Allowed the user to choose the refresh rate - -Lights-on(line 92-103): - Allowed the user to use a True or False value for lights - -The modifications made to the code to allow for user input to control the day/night cycle and toggle the lights on/off: - -Added two boolean variables, day and lights_on, to represent the current state of the day/night cycle and lights status respectively. -Wrapped the event processing logic inside a for loop that iterates over all events in the event queue using pygame.event.get(). -Added event handling for two keys: 'l' to toggle the lights on/off, and 'd' to toggle between day and night mode. -Modified the game logic to use the day and lights_on variables to determine the appropriate colors for the sky, field, stripe, cloud, and fence based on the current state. -Added a function draw_cloud(x, y) to encapsulate the drawing logic for the cloud, which takes in the cloud's coordinates (x, y) as input parameters. -Moved the cloud drawing logic from the main game loop to the draw_cloud() function, and replaced the previously hard-coded color values with the cloud_color variable that is determined based on the day variable. -Removed the unused STAR_COLOR variable, as it was not used in the code. -These modifications allow the user to control the day/night cycle and toggle the lights on/off by pressing the 'd' and 'l' keys respectively during the game loop. - -goal(length,height,color): draws a goal net based on its length, height, and color - -draw_line_goal_box(color): draws the line in front of the goal net based on the provided color - -draw_light(x_index): draws the light of the court based on the provided x index - - -draw_stand(front_color,back_color): draws the left and right viewer stands based on the provided color - -draw_left_flag(stick_color, flag_color, x, y): draws a small flag t that tilted left based on x and y index and its color - -draw_right_flag(stick_color, flag_color, x, y): draws a small flag t that tilted right based on x and y index and its color From 0404d9bb9da85f13ede7f4490a8a1588c87b7abd Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:36:28 -0700 Subject: [PATCH 18/31] Delete JSON directory --- JSON/data1.json | 1 - JSON/data2.json | 20 -------- JSON/data3.json | 32 ------------- JSON/json_demo.py | 118 ---------------------------------------------- 4 files changed, 171 deletions(-) delete mode 100644 JSON/data1.json delete mode 100644 JSON/data2.json delete mode 100644 JSON/data3.json delete mode 100644 JSON/json_demo.py diff --git a/JSON/data1.json b/JSON/data1.json deleted file mode 100644 index fc8965a..0000000 --- a/JSON/data1.json +++ /dev/null @@ -1 +0,0 @@ -[{"two": "dos", "lang": "spanish", "three": "tres", "one": "uno"}, {"two": "deux", "lang": "french", "three": "trios", "one": "un"}, {"two": "duo", "lang": "latin", "three": "tres", "one": "unus"}] \ No newline at end of file diff --git a/JSON/data2.json b/JSON/data2.json deleted file mode 100644 index 07f798b..0000000 --- a/JSON/data2.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "two": "dos", - "lang": "spanish", - "three": "tres", - "one": "uno" - }, - { - "two": "deux", - "lang": "french", - "three": "trios", - "one": "un" - }, - { - "two": "duo", - "lang": "latin", - "three": "tres", - "one": "unus" - } -] \ No newline at end of file diff --git a/JSON/data3.json b/JSON/data3.json deleted file mode 100644 index a6dbf3a..0000000 --- a/JSON/data3.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "lang": "spanish", - "one": "uno", - "two": "dos", - "three": "tres" - }, - { - "lang": "french", - "one": "un", - "two": "deux", - "three": "trios" - }, - { - "lang": "latin", - "one": "unus", - "two": "duo", - "three": "tres" - }, - { - "lang": "german", - "one": "eins", - "two": "swei", - "three": "drei" - }, - { - "lang": "italian", - "one": "uno", - "two": "due", - "three": "tre" - } -] \ No newline at end of file diff --git a/JSON/json_demo.py b/JSON/json_demo.py deleted file mode 100644 index 73a70b8..0000000 --- a/JSON/json_demo.py +++ /dev/null @@ -1,118 +0,0 @@ -# Computer Programming 1 -# JSON Demo -# -# by Jon Cooper -# January 28, 2014 - - -# What is JSON? -# -# JSON, or JavaScript Object Notation, is an open standard format that -# uses human-readable text to transmit data objects consisting of -# attribute–value pairs. It is used primarily to transmit data between -# a server and web application, as an alternative to XML. -# -# Although originally derived from the JavaScript scripting language, -# JSON is a language-independent data format, and code for parsing and -# generating JSON data is readily available in a large variety of -# programming languages. -# -# source: http://en.wikipedia.org/wiki/JSON - - -# Import json module (We'll use this later.) -import json - - -# Make some dictionaries -a = {'lang': 'spanish', 'one': 'uno', 'two': 'dos', 'three': 'tres'} -b = {'lang': 'french', 'one': 'un', 'two': 'deux', 'three': 'trios'} -c = {'lang': 'latin', 'one': 'unus', 'two': 'duo', 'three': 'tres'} - - -# Now the dictionaries in a list -languages = [a, b, c] - - -# Check the contents of the list. -print(languages) - - -# Check the types of our data to confirm that we do have a list of -# dictionaries. -print(type(languages)) -print(type(languages[0])) - - -# Python's built-in json module is designed to handle exactly this -# kind of data represented as a string. - -json_string = json.dumps(languages) -print(json_string) # The data looks the same, but -print(type(json_string)) # it's not a list of dicts anymore. - - -# Let's write the json_string to a text file. Then open the newly- -# created file to confirm that it contains our language data. - -file_name = 'data1.json' # use the .json extension - -with open(file_name, 'w') as f: - f.write(json_string) - - -# Even though it is fairly easy to see that our data file contains -# a list of strings, it is still not easily 'human-readable' which -# is one of the main reasons for using JSON. Fortunately, Python's -# json library supports 'pretty printing'. - -pretty_json_string = json.dumps(languages, indent=4) -print(pretty_json_string) # much better - - -# The nicer output is much better for putting in a data file. -# (Python dicts aren't ordered, so the terms are a little jumbled. -# At least it's neat.) - -file_name = 'data2.json' - -with open(file_name, 'w') as f: - f.write(pretty_json_string) - - -# We can also read JSON files. - -file_name = 'data3.json' - -with open(file_name, 'r') as f: - raw_data = f.read() - -print(type(raw_data)) - - -# Convert the data to a JSON format (list of dicts). -json_data = json.loads(raw_data) - - -# Test the types. -print(type(json_data)) -print(type(json_data[1])) - - -# So now we have our file loaded into a program as a list of -# dict items again. What this means is that we can now write -# applications that keep the data and code separate. This -# will allow us to write much cleaner and more maintainable -# code. - - -# Note: -# -# We could have accomplished everything in this program without -# ever using the json module. We already know how to read files -# as strings. We could split the strings on commas and colons -# and loop through the data to create dicts and lists. However, -# the json module already has the code that does this for us. -# Why not just use the json module and make it easy! - - From 6eac20c6a5afaba2af4e190c921774d529e48d25 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:36:32 -0700 Subject: [PATCH 19/31] Add files via upload new modification to funciton draw_pole --- .../graphics_v4.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 7c81e29..32b1f8b 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -46,22 +46,29 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) -#simplier function that uses loops to draw clouds def draw_cloud(x, y): - ellipses = [[x, y + 8, 10, 10], [x + 6, y + 4, 8, 8], [x + 10, y, 16, 16], [x + 20, y + 8, 10, 10]] - for ellipse in ellipses: - pygame.draw.ellipse(SEE_THROUGH, cloud_color, ellipse) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x, y + 8, 10, 10]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 6, y + 4, 8, 8]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 10, y, 16, 16]) + pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 20, y + 8, 10, 10]) pygame.draw.rect(SEE_THROUGH, cloud_color, [x + 6, y + 8, 18, 10]) - # Config lights_on = True day = True -#simplied the star and cloud loops -stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] -clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] - +stars = [] +for n in range(200): + x = random.randrange(0, 800) + y = random.randrange(0, 200) + r = random.randrange(1, 2) + stars.append([x, y, r, r]) + +clouds = [] +for i in range(20): + x = random.randrange(-100, 1600) + y = random.randrange(0, 150) + clouds.append([x, y]) # Game loop done = False From e86f692e75503c47f8529f63b3794e693e59d4f5 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:42:11 -0700 Subject: [PATCH 20/31] updated little parts of program --- .../graphics_v4.py | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 32b1f8b..1889666 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -46,30 +46,21 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) +#simplier function that uses loops to draw clouds def draw_cloud(x, y): - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x, y + 8, 10, 10]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 6, y + 4, 8, 8]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 10, y, 16, 16]) - pygame.draw.ellipse(SEE_THROUGH, cloud_color, [x + 20, y + 8, 10, 10]) + ellipses = [[x, y + 8, 10, 10], [x + 6, y + 4, 8, 8], [x + 10, y, 16, 16], [x + 20, y + 8, 10, 10]] + for ellipse in ellipses: + pygame.draw.ellipse(SEE_THROUGH, cloud_color, ellipse) pygame.draw.rect(SEE_THROUGH, cloud_color, [x + 6, y + 8, 18, 10]) # Config lights_on = True day = True -stars = [] -for n in range(200): - x = random.randrange(0, 800) - y = random.randrange(0, 200) - r = random.randrange(1, 2) - stars.append([x, y, r, r]) - -clouds = [] -for i in range(20): - x = random.randrange(-100, 1600) - y = random.randrange(0, 150) - clouds.append([x, y]) - +#simplied the star and cloud loops +stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] +clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] + # Game loop done = False From 4c46c6b2de69cbf9056deaad622c4ca2306ce4d9 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:54:36 -0700 Subject: [PATCH 21/31] made lights and shades/color loops simplier --- .../graphics_v4.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 1889666..1fb5a95 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -77,22 +77,13 @@ def draw_cloud(x, y): day = not day # Game logic (Check for collisions, update points, etc.) - ''' leave this section alone for now ''' - if lights_on: - light_color = YELLOW - else: - light_color = SILVER + ''' made the lights and shades of things simplier ''' + light_color = YELLOW if lights_on else SILVER if day: - sky_color = BLUE - field_color = GREEN - stripe_color = DAY_GREEN - cloud_color = WHITE + sky_color, field_color, stripe_color, cloud_color = BLUE, GREEN, DAY_GREEN, WHITE else: - sky_color = DARK_BLUE - field_color = DARK_GREEN - stripe_color = NIGHT_GREEN - cloud_color = NIGHT_GRAY + sky_color, field_color, stripe_color, cloud_color = DARK_BLUE, DARK_GREEN, NIGHT_GREEN, NIGHT_GRAY for c in clouds: c[0] -= 0.5 @@ -100,6 +91,7 @@ def draw_cloud(x, y): if c[0] < -100: c[0] = random.randrange(800, 1600) c[1] = random.randrange(0, 150) + # Drawing code (Describe the picture. It isn't actually drawn yet.) screen.fill(sky_color) From 9e7f156bef471700a158de683fca77c6dc024d0e Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 12:12:23 -0700 Subject: [PATCH 22/31] function for fence --- .../graphics_v4.py | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 1fb5a95..78d5dbc 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -114,24 +114,19 @@ def draw_cloud(x, y): '''fence''' - y = 170 - for x in range(5, 800, 30): - pygame.draw.polygon(screen, NIGHT_GRAY, [[x + 2, y], [x + 2, y + 15], [x, y + 15], [x, y]]) - - y = 170 - for x in range(5, 800, 3): - pygame.draw.line(screen, NIGHT_GRAY, [x, y], [x, y + 15], 1) - - x = 0 - for y in range(170, 185, 4): - pygame.draw.line(screen, NIGHT_GRAY, [x, y], [x + 800, y], 1) - - if day: - pygame.draw.ellipse(screen, BRIGHT_YELLOW, [520, 50, 40, 40]) - else: - pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) - pygame.draw.ellipse(screen, sky_color, [530, 45, 40, 40]) - + def draw_fence(screen, color): + y = 170 + for x in range(5, 800, 30): + pygame.draw.polygon(screen, color, [[x + 2, y], [x + 2, y + 15], [x, y + 15], [x, y]]) + y = 170 + for x in range(5, 800, 3): + pygame.draw.line(screen, color, [x, y], [x, y + 15], 1) + x= 0 + for y in range(170, 185, 4): + pygame.draw.line(screen, NIGHT_GRAY, [x, y], [x + 800, y], 1) + + draw_fence(screen, NIGHT_GRAY) + for c in clouds: From 414c32d9fff01291544ad5d1bedf45a789bbb29f Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:27:01 -0700 Subject: [PATCH 23/31] updated and found clouds the cloud part of the program went missing but it was accidentally deleted --- .../graphics_v4.py | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 78d5dbc..d8934c2 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -57,10 +57,16 @@ def draw_cloud(x, y): lights_on = True day = True -#simplied the star and cloud loops -stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] -clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] + + +def generate_stars_and_clouds(): + stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] + clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] + return stars, clouds +#usage +stars, clouds = generate_stars_and_clouds() + # Game loop done = False @@ -80,10 +86,15 @@ def draw_cloud(x, y): ''' made the lights and shades of things simplier ''' light_color = YELLOW if lights_on else SILVER - if day: - sky_color, field_color, stripe_color, cloud_color = BLUE, GREEN, DAY_GREEN, WHITE - else: - sky_color, field_color, stripe_color, cloud_color = DARK_BLUE, DARK_GREEN, NIGHT_GREEN, NIGHT_GRAY + def get_colors(day): + if day: + sky_color, field_color, stripe_color, cloud_color = BLUE, GREEN, DAY_GREEN, WHITE + else: + sky_color, field_color, stripe_color, cloud_color = DARK_BLUE, DARK_GREEN, NIGHT_GREEN, NIGHT_GRAY + return sky_color, field_color, stripe_color, cloud_color + + sky_color, field_color, stripe_color, cloud_color = get_colors(day) + for c in clouds: c[0] -= 0.5 @@ -92,6 +103,7 @@ def draw_cloud(x, y): c[0] = random.randrange(800, 1600) c[1] = random.randrange(0, 150) + # Drawing code (Describe the picture. It isn't actually drawn yet.) screen.fill(sky_color) @@ -103,15 +115,15 @@ def draw_cloud(x, y): for s in stars: pygame.draw.ellipse(screen, WHITE, s) + def draw_field_and_stripes(screen, field_color, stripe_color): + pygame.draw.rect(screen, field_color, [0, 180, 800 , 420]) + pygame.draw.rect(screen, stripe_color, [0, 180, 800, 42]) + pygame.draw.rect(screen, stripe_color, [0, 264, 800, 52]) + pygame.draw.rect(screen, stripe_color, [0, 368, 800, 62]) + pygame.draw.rect(screen, stripe_color, [0, 492, 800, 82]) - - - pygame.draw.rect(screen, field_color, [0, 180, 800 , 420]) - pygame.draw.rect(screen, stripe_color, [0, 180, 800, 42]) - pygame.draw.rect(screen, stripe_color, [0, 264, 800, 52]) - pygame.draw.rect(screen, stripe_color, [0, 368, 800, 62]) - pygame.draw.rect(screen, stripe_color, [0, 492, 800, 82]) - + draw_field_and_stripes(screen, field_color, stripe_color) + '''fence''' def draw_fence(screen, color): @@ -127,7 +139,14 @@ def draw_fence(screen, color): draw_fence(screen, NIGHT_GRAY) - + def draw_sun_or_moon(screen, day, sky_color): + if day: + pygame.draw.ellipse(screen, BRIGHT_YELLOW, [520, 50, 40, 40]) + else: + pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) + pygame.draw.ellipse(screen, sky_color, [530, 45, 40, 40]) + + draw_sun_or_moon(screen, day, sky_color) for c in clouds: draw_cloud(c[0], c[1]) @@ -167,7 +186,6 @@ def score_board(pole_thick,board_length,board_height): def goal(length,height,color): """ goal draws a goal net based on its length, height, and color - :length: length of the rectangle shape goal net :height: height of the rectangle shape goal net :color: color of the goal net @@ -204,7 +222,6 @@ def goal(length,height,color): def draw_line_goal_box(color): """ draw_line_goal_box draws the line in front of the goal net based on the provided color - :color: color of the boal box line """ pygame.draw.line(screen, color, [310, 220], [270, 270], 3) @@ -217,7 +234,6 @@ def draw_line_goal_box(color): def draw_light(x_index): """ draw_light draws the light of the court based on the provided x index - :x_index: x index of the light pole bottom """ pygame.draw.rect(screen, GRAY, [x_index, 60, 20, 140]) @@ -260,7 +276,6 @@ def draw_stand(front_color,back_color): def draw_left_flag(stick_color, flag_color, x, y): """ draw_left_flag draws a small flag t that tilted left based on xy index and its color - :stick_color: stick color :flag_color: flag color :x: x index @@ -273,7 +288,6 @@ def draw_left_flag(stick_color, flag_color, x, y): def draw_right_flag(stick_color, flag_color, x, y): """ draw_left_flag draws a small flag t that tilted right based on xy index and its color - :stick_color: stick color :flag_color: flag color :x: x index From 377dbe0fbccccbc3a4fa7c39d1c80b59a4ee0519 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:38:18 -0700 Subject: [PATCH 24/31] added comments --- .../graphics_v4.py | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index d8934c2..68f35b9 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -46,7 +46,7 @@ SEE_THROUGH.set_alpha(150) SEE_THROUGH.fill((124, 118, 135)) -#simplier function that uses loops to draw clouds +#function that uses loops to draw clouds def draw_cloud(x, y): ellipses = [[x, y + 8, 10, 10], [x + 6, y + 4, 8, 8], [x + 10, y, 16, 16], [x + 20, y + 8, 10, 10]] for ellipse in ellipses: @@ -58,7 +58,7 @@ def draw_cloud(x, y): day = True - +#function that generates a list of star and clouds at a random size and position def generate_stars_and_clouds(): stars = [[random.randrange(0, 800), random.randrange(0, 200), random.randrange(1, 2), random.randrange(1, 2)] for n in range(200)] clouds = [[random.randrange(-100, 1600), random.randrange(0, 150)] for i in range(20)] @@ -83,9 +83,11 @@ def generate_stars_and_clouds(): day = not day # Game logic (Check for collisions, update points, etc.) - ''' made the lights and shades of things simplier ''' + ''' made the lights and shades of things simplier ''' + #makes the light conditional easier without so many if statements or lines light_color = YELLOW if lights_on else SILVER + #gets the color of the enviroment depending on the the time of day def get_colors(day): if day: sky_color, field_color, stripe_color, cloud_color = BLUE, GREEN, DAY_GREEN, WHITE @@ -95,7 +97,7 @@ def get_colors(day): sky_color, field_color, stripe_color, cloud_color = get_colors(day) - + #populates the clouds for c in clouds: c[0] -= 0.5 @@ -114,18 +116,21 @@ def get_colors(day): #stars for s in stars: pygame.draw.ellipse(screen, WHITE, s) - + + #used to draws the stripes on the field def draw_field_and_stripes(screen, field_color, stripe_color): pygame.draw.rect(screen, field_color, [0, 180, 800 , 420]) pygame.draw.rect(screen, stripe_color, [0, 180, 800, 42]) pygame.draw.rect(screen, stripe_color, [0, 264, 800, 52]) pygame.draw.rect(screen, stripe_color, [0, 368, 800, 62]) pygame.draw.rect(screen, stripe_color, [0, 492, 800, 82]) - + + #usage draw_field_and_stripes(screen, field_color, stripe_color) '''fence''' + #used to draw the fence in the background def draw_fence(screen, color): y = 170 for x in range(5, 800, 30): @@ -136,18 +141,21 @@ def draw_fence(screen, color): x= 0 for y in range(170, 185, 4): pygame.draw.line(screen, NIGHT_GRAY, [x, y], [x + 800, y], 1) - + #usage draw_fence(screen, NIGHT_GRAY) + + #draws the shape of the sun and moon depending if it is day or night def draw_sun_or_moon(screen, day, sky_color): if day: pygame.draw.ellipse(screen, BRIGHT_YELLOW, [520, 50, 40, 40]) else: pygame.draw.ellipse(screen, WHITE, [520, 50, 40, 40]) pygame.draw.ellipse(screen, sky_color, [530, 45, 40, 40]) - + #usage draw_sun_or_moon(screen, day, sky_color) + #draws the clouds for c in clouds: draw_cloud(c[0], c[1]) screen.blit(SEE_THROUGH, (0, 0)) From cecd40b2c397436b0148ac7dfff61b98665e411c Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:54:08 -0700 Subject: [PATCH 25/31] more documentation --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c4fa2f..c5ffbd9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,26 @@ # CS2520 Assignment 6 project is located under Intro to Pygame Graphics > major league soccer animation > graphics_v4.py -updated star and cloud loops: +def generate_stars_and_clouds(): This code uses list comprehension to create the stars and clouds lists in a more concise way. It also eliminates the need for temporary variables x, y, and r. -simplied draw_cloud: +def draw_cloud(x, y): This code stores the ellipse coordinates and dimensions in a list and then iterates over the list to draw each ellipse using a loop. This reduces the number of lines of code from 5 to 2. + def get_colors(day): + This code defines a function called "get_colors" that takes a parameter "day". Inside the function, it checks if the "day" parameter is truthy (i.e., evaluates to True in a boolean context), and if so, it sets four variables "sky_color", "field_color", "stripe_color", and "cloud_color" to the values of "BLUE", "GREEN", "DAY_GREEN", and "WHITE", respectively. Otherwise, it sets these variables to the values of "DARK_BLUE", "DARK_GREEN", "NIGHT_GREEN", and "NIGHT_GRAY", respectively. + + The function then returns a tuple containing these four color values. Finally, the code assigns the values returned by the function to four variables "sky_color", "field_color", "stripe_color", and "cloud_color" using tuple unpacking. + +def draw_field_and_stripes(screen, field_color, stripe_color): + This code defines a function called "draw_field_and_stripes" that takes three parameters: "screen", "field_color", and "stripe_color". The function uses the Pygame library to draw a series of rectangles on the "screen" object that represent a field with stripes. + +def draw_fence(screen, color): + This code defines a function that draws a fence on a Pygame screen using polygons and lines. The function takes in two parameters: the screen to draw on and the color of the fence. The first loop draws rectangular polygons for the fence, while the second loop draws vertical lines. The third loop draws horizontal lines to complete the fence. + +def draw_sun_or_moon(screen, day, sky_color): + This code defines a function called "draw_sun_or_moon" that takes three parameters: "screen", "day", and "sky_color". The function uses the Pygame library to draw a sun or moon on the "screen" object depending on the value of the "day" parameter. If day is true then it returns a sun, if it is false it returns a moon. + goal(length,height,color): draws a goal net based on its length, height, and color draw_line_goal_box(color): draws the line in front of the goal net based on the provided color @@ -21,6 +35,9 @@ draw_left_flag(stick_color, flag_color, x, y): draws a small flag t that tilted draw_right_flag(stick_color, flag_color, x, y): draws a small flag t that tilted right based on x and y index and its color + + + Members: Natalia Jauregui Haosi Lin From b1330fb1cdc1ab096c51c8c8ce994407c4f590fc Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:54:42 -0700 Subject: [PATCH 26/31] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c5ffbd9..e065cc8 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ def draw_cloud(x, y): def get_colors(day): This code defines a function called "get_colors" that takes a parameter "day". Inside the function, it checks if the "day" parameter is truthy (i.e., evaluates to True in a boolean context), and if so, it sets four variables "sky_color", "field_color", "stripe_color", and "cloud_color" to the values of "BLUE", "GREEN", "DAY_GREEN", and "WHITE", respectively. Otherwise, it sets these variables to the values of "DARK_BLUE", "DARK_GREEN", "NIGHT_GREEN", and "NIGHT_GRAY", respectively. - - The function then returns a tuple containing these four color values. Finally, the code assigns the values returned by the function to four variables "sky_color", "field_color", "stripe_color", and "cloud_color" using tuple unpacking. +The function then returns a tuple containing these four color values. Finally, the code assigns the values returned by the function to four variables "sky_color", "field_color", "stripe_color", and "cloud_color" using tuple unpacking. def draw_field_and_stripes(screen, field_color, stripe_color): This code defines a function called "draw_field_and_stripes" that takes three parameters: "screen", "field_color", and "stripe_color". The function uses the Pygame library to draw a series of rectangles on the "screen" object that represent a field with stripes. From 405db102de01f4eb0ea4f523f487bced50cb5c6d Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:58:53 -0700 Subject: [PATCH 27/31] added bold and indentation for uniformity --- README.md | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e065cc8..63dd053 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,43 @@ # CS2520 Assignment 6 -project is located under Intro to Pygame Graphics > major league soccer animation > graphics_v4.py +Project is located under ---->>>>> Intro to Pygame Graphics > major league soccer animation > graphics_v4.py -def generate_stars_and_clouds(): +__def generate_stars_and_clouds():__ This code uses list comprehension to create the stars and clouds lists in a more concise way. It also eliminates the need for temporary variables x, y, and r. -def draw_cloud(x, y): +__def draw_cloud(x, y):__ This code stores the ellipse coordinates and dimensions in a list and then iterates over the list to draw each ellipse using a loop. This reduces the number of lines of code from 5 to 2. - def get_colors(day): + __def get_colors(day):__ This code defines a function called "get_colors" that takes a parameter "day". Inside the function, it checks if the "day" parameter is truthy (i.e., evaluates to True in a boolean context), and if so, it sets four variables "sky_color", "field_color", "stripe_color", and "cloud_color" to the values of "BLUE", "GREEN", "DAY_GREEN", and "WHITE", respectively. Otherwise, it sets these variables to the values of "DARK_BLUE", "DARK_GREEN", "NIGHT_GREEN", and "NIGHT_GRAY", respectively. The function then returns a tuple containing these four color values. Finally, the code assigns the values returned by the function to four variables "sky_color", "field_color", "stripe_color", and "cloud_color" using tuple unpacking. -def draw_field_and_stripes(screen, field_color, stripe_color): +__def draw_field_and_stripes(screen, field_color, stripe_color):__ This code defines a function called "draw_field_and_stripes" that takes three parameters: "screen", "field_color", and "stripe_color". The function uses the Pygame library to draw a series of rectangles on the "screen" object that represent a field with stripes. -def draw_fence(screen, color): +__def draw_fence(screen, color):__ This code defines a function that draws a fence on a Pygame screen using polygons and lines. The function takes in two parameters: the screen to draw on and the color of the fence. The first loop draws rectangular polygons for the fence, while the second loop draws vertical lines. The third loop draws horizontal lines to complete the fence. -def draw_sun_or_moon(screen, day, sky_color): +__def draw_sun_or_moon(screen, day, sky_color):__ This code defines a function called "draw_sun_or_moon" that takes three parameters: "screen", "day", and "sky_color". The function uses the Pygame library to draw a sun or moon on the "screen" object depending on the value of the "day" parameter. If day is true then it returns a sun, if it is false it returns a moon. -goal(length,height,color): draws a goal net based on its length, height, and color +__goal(length,height,color):__ + draws a goal net based on its length, height, and color -draw_line_goal_box(color): draws the line in front of the goal net based on the provided color +__draw_line_goal_box(color):__ + draws the line in front of the goal net based on the provided color -draw_light(x_index): draws the light of the court based on the provided x index +__draw_light(x_index):__ + draws the light of the court based on the provided x index -draw_stand(front_color,back_color): draws the left and right viewer stands based on the provided color +__draw_stand(front_color,back_color):__ + draws the left and right viewer stands based on the provided color -draw_left_flag(stick_color, flag_color, x, y): draws a small flag t that tilted left based on x and y index and its color +__draw_left_flag(stick_color, flag_color, x, y):__ + draws a small flag t that tilted left based on x and y index and its color -draw_right_flag(stick_color, flag_color, x, y): draws a small flag t that tilted right based on x and y index and its color +__draw_right_flag(stick_color, flag_color, x, y):__ + draws a small flag t that tilted right based on x and y index and its color From ff8a3dd45613761cba09a11a03bc483876bc8df1 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:17:45 -0700 Subject: [PATCH 28/31] added more comments --- .../major league soccer animation/graphics_v4.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index 68f35b9..a0f21a6 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -235,7 +235,7 @@ def draw_line_goal_box(color): pygame.draw.line(screen, color, [310, 220], [270, 270], 3) pygame.draw.line(screen, color, [270, 270], [530, 270], 2) pygame.draw.line(screen, color, [530, 270], [490, 220], 3) - + #usage draw_line_goal_box(WHITE) #function to draw light based on its x index @@ -262,6 +262,7 @@ def draw_light(x_index): pygame.draw.line(screen, GRAY, [x_index - 40, 20], [x_index + 60, 20], 2) #drawing left and right light + #usage draw_light(150) draw_light(590) @@ -277,6 +278,7 @@ def draw_stand(front_color,back_color): pygame.draw.polygon(screen, front_color, [[120, 220], [0, 340], [0, 290], [120, 180]]) pygame.draw.polygon(screen, back_color, [[120, 180], [0, 100], [0, 290]]) + #usage #draw left and right stands draw_stand(RED,GREEN) From 6153c42764e29569ad1c77e729361daacd947390 Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:19:52 -0700 Subject: [PATCH 29/31] add space between commas --- .../major league soccer animation/graphics_v4.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index a0f21a6..a97217b 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -181,7 +181,7 @@ def draw_sun_or_moon(screen, day, sky_color): pygame.draw.arc(screen, WHITE, [330, 280, 140, 40], math.pi, 2 * math.pi, 5) # function to draw score board in the center of the screen behind goal net - def score_board(pole_thick,board_length,board_height): + def score_board(pole_thick, board_length, board_height): pygame.draw.rect(screen, GRAY, [390, 120, pole_thick, 70]) pygame.draw.rect(screen, BLACK, [400- board_length//2, 40, board_length, board_height]) pygame.draw.rect(screen, WHITE, [402 - board_length//2, 42, board_length-2, board_height-2], 2) @@ -191,7 +191,7 @@ def score_board(pole_thick,board_length,board_height): #goal is always in the center just like the board #drawing a goal with net in the center of the screen - def goal(length,height,color): + def goal(length, height, color): """ goal draws a goal net based on its length, height, and color :length: length of the rectangle shape goal net @@ -267,7 +267,7 @@ def draw_light(x_index): draw_light(590) #function to draw left and right stands - def draw_stand(front_color,back_color): + def draw_stand(front_color, back_color): """ draw_stand draws the left and right viewer stands based on the provided color :front_color: front color of the stand @@ -327,6 +327,5 @@ def draw_right_flag(stick_color, flag_color, x, y): # Limit refresh rate of game loop clock.tick(refresh_rate) - # Close window and quit pygame.quit() From f5a23d4c1247552b69afa3887ae95a85560812cc Mon Sep 17 00:00:00 2001 From: haosi <89117189+gxxxid@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:21:20 -0700 Subject: [PATCH 30/31] more comment --- .../major league soccer animation/graphics_v4.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py index a97217b..3b14d60 100644 --- a/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py +++ b/Intro to Pygame Graphics/major league soccer animation/graphics_v4.py @@ -305,7 +305,8 @@ def draw_right_flag(stick_color, flag_color, x, y): """ pygame.draw.line(screen, stick_color, [x - 5, y + 30], [x, y], 3) pygame.draw.polygon(screen, flag_color, [[x + 3, y], [x + 10, y + 6], [x, y + 15]]) - + + #drawing two flag draw_left_flag(YELLOW, RED, 135, 190) draw_right_flag(BRIGHT_YELLOW, RED, 665, 190) From 09549d3edd858185ac3c0f5852daa3574ef23aa5 Mon Sep 17 00:00:00 2001 From: chocolateCheerios <130518813+chocolateCheerios@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:40:58 -0700 Subject: [PATCH 31/31] added usernames --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63dd053..9cabfe3 100644 --- a/README.md +++ b/README.md @@ -44,5 +44,5 @@ __draw_right_flag(stick_color, flag_color, x, y):__ Members: -Natalia Jauregui -Haosi Lin +Natalia Jauregui (chocolatecheerios) +Haosi Lin (gxxxid)