diff --git a/__pycache__/spider.cpython-310.pyc b/__pycache__/spider.cpython-310.pyc index ebb1655..84e4751 100644 Binary files a/__pycache__/spider.cpython-310.pyc and b/__pycache__/spider.cpython-310.pyc differ diff --git a/__pycache__/spider.cpython-312.pyc b/__pycache__/spider.cpython-312.pyc new file mode 100644 index 0000000..6a82bd3 Binary files /dev/null and b/__pycache__/spider.cpython-312.pyc differ diff --git a/__pycache__/spidermov.cpython-310.pyc b/__pycache__/spidermov.cpython-310.pyc new file mode 100644 index 0000000..b490002 Binary files /dev/null and b/__pycache__/spidermov.cpython-310.pyc differ diff --git a/__pycache__/spiderweb.cpython-310.pyc b/__pycache__/spiderweb.cpython-310.pyc index cad5b7e..9122c44 100644 Binary files a/__pycache__/spiderweb.cpython-310.pyc and b/__pycache__/spiderweb.cpython-310.pyc differ diff --git a/__pycache__/spiderweb.cpython-312.pyc b/__pycache__/spiderweb.cpython-312.pyc new file mode 100644 index 0000000..2144b29 Binary files /dev/null and b/__pycache__/spiderweb.cpython-312.pyc differ diff --git a/drawing.py b/drawing.py index 5918e4b..92dd668 100644 --- a/drawing.py +++ b/drawing.py @@ -10,19 +10,26 @@ from superturtle import * from superturtle.movement import * from spider import * from spiderweb import * +from spidermov import * + +# previous codes drawing a spider +# def drawing(side_length): +# draw_web(side_length) +# penup() +# goto(0, 0) +# setheading(0) +# pendown() +# draw_spider(300) +# draw_connection_line(300) +# hideturtle() +# done() + +# drawing(300) -def drawing(side_length): - draw_web(side_length) - penup() - goto(0, 0) - setheading(0) - pendown() - draw_spider() - draw_connection_line() - hideturtle() - done() +# Setup +setup(width=800, height=800) +tracer(0) # Disable automatic screen updates for smooth animation -drawing(300) - - \ No newline at end of file +# Draw the entire scene +draw_scene(300) \ No newline at end of file diff --git a/spider.py b/spider.py index f3a38e9..7c8b9e2 100644 --- a/spider.py +++ b/spider.py @@ -19,16 +19,16 @@ def draw_circle(radius, x, y, color=None): if color: end_fill() # End the filling -def draw_spider(): +def draw_spider(radius): # Step 1: Draw the big circle (spider body) on top of the small circle - draw_circle(60, 30, 60, color="grey") + draw_circle(radius, 30, 60, color="grey") # Step 2: Draw the small circle (spider head) draw_circle(20, 30, 0, color="black") # Step 3: Draw legs on big circle - draw_legs(60, 30, 60) + draw_legs(radius, 30, 60) def draw_legs(radius, x, y): "Draws legs starting from the perimeter of the big circle (spider's body)" @@ -48,12 +48,12 @@ def draw_legs(radius, x, y): penup() backward(leg_length) # Move back to the perimeter of the big circle -def draw_connection_line(): +def draw_connection_line(y): "Draw a line from the top of the big circle (head) to the center of the small circle (body)" penup() goto(30, 400) pendown() - goto(30, 120) # Draw a line to the center of the small circle (spider's body) + goto(30, y) # Draw a line to the center of the small circle (spider's body) penup() goto(0, 0) diff --git a/spidermov.py b/spidermov.py new file mode 100644 index 0000000..f64275d --- /dev/null +++ b/spidermov.py @@ -0,0 +1,80 @@ +from turtle import * +from superturtle import * +from superturtle.movement import * +import time +import random +from spider import draw_circle, draw_legs, draw_connection_line, draw_spider +from spiderweb import draw_web + +# Function to simulate the explosion of the spider like a firework +def explode_spider(x, y, radius): + """Simulates the explosion of the spider like a firework.""" + for _ in range(20): + penup() + goto(x, y) + setheading(random.randint(0, 360)) # Random direction + forward(random.randint(radius, radius * 3)) # Random distance + pendown() + dot(10, random.choice(["red", "orange", "yellow", "white"])) # Draw explosion dot + penup() + + time.sleep(1) + update() # Update the screen to show the explosion + clear() # Clear the screen after explosion + update() + + # Draw rainbow after explosion + draw_rainbow_splash() + +# Function to draw a rainbow splash +def draw_rainbow_splash(): + """Draws a rainbow like a splash of colorful dashed and solid lines of different lengths.""" + colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] + penup() + goto(0, 0) # Start from the center of the screen + for color in colors: + for _ in range(2): # Repeat each color two times + setheading(random.randint(0, 360)) # Random direction for each line + pencolor(color) + pensize(2) + length = random.randint(100, 200) # Random length for each line + pendown() + if random.choice([True, False]): # Randomly choose between dashed and solid lines + for _ in range(length // 15): # Create dashed lines + forward(10) + penup() + forward(5) + pendown() + else: + forward(length) # Create solid line + penup() + goto(0, 0) # Return to the center + update() # Update the screen to show the rainbow splash + + + +# Function to draw the entire scene +def draw_scene(side_length): + """Draws the entire scene with the web, spider, and animation.""" + draw_web(side_length) # Draw the web + update() # Update the screen to show the web + time.sleep(1) + penup() + goto(0, 0) + setheading(0) + pendown() + draw_spider(60) # Draw the spider with the specified radius + update() # Update the screen to show the spider + draw_connection_line(120) # Draw the connection line from the top of the screen to the spider + update() # Update the screen to show the connection line + hideturtle() + time.sleep(1) + explode_spider(30, 60, 60) # Explode the spider + done() + +# Setup +setup(width=800, height=800) +tracer(0) # Disable automatic screen updates for smooth animation + +# Draw the entire scene +draw_scene(300) \ No newline at end of file