From 6a53ed63649c34a3b39a26e3554ee7e72204d034 Mon Sep 17 00:00:00 2001 From: grace-xing6 Date: Mon, 7 Oct 2024 21:22:57 -0400 Subject: [PATCH] updated spidermov under the help of ChatGPT (Canvas), I turned the spider with its web to the color splash like a firework The things I could not figure out is how to make it come down from the top and get bigger. I used ChatGPT to generate this code but it didn't work well. I also added arguments in the function to make it connected with others. --- __pycache__/spider.cpython-310.pyc | Bin 1550 -> 1549 bytes __pycache__/spider.cpython-312.pyc | Bin 0 -> 2096 bytes __pycache__/spidermov.cpython-310.pyc | Bin 0 -> 2044 bytes __pycache__/spiderweb.cpython-310.pyc | Bin 1512 -> 1512 bytes __pycache__/spiderweb.cpython-312.pyc | Bin 0 -> 2153 bytes drawing.py | 33 ++++++----- spider.py | 10 ++-- spidermov.py | 80 ++++++++++++++++++++++++++ 8 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 __pycache__/spider.cpython-312.pyc create mode 100644 __pycache__/spidermov.cpython-310.pyc create mode 100644 __pycache__/spiderweb.cpython-312.pyc create mode 100644 spidermov.py diff --git a/__pycache__/spider.cpython-310.pyc b/__pycache__/spider.cpython-310.pyc index ebb16554bb26a60c0a33a8c7f419835d560fb957..84e475191764c357a211128c8faed89dd94c0392 100644 GIT binary patch delta 242 zcmeC<>E+?g=jG*M00NsGPdHI>b89`hq0I}JC*cph64S+-mLk&X;V+vCWa|%l@ z3nP%9!V2WGrLaT!j1c)|W=4h-hF}Iw4!@UjKz%Q5CKodqvuH9FaZL_n72dp?iG`6- zaPk4>UA!pvO>Sq=lBr>6W&#=A%m5@AfmSht_$e$v<5(x3Wr>Eq$e=jG*M0D>bd%;~E)^71og}tU%ptlh3onstW-P$eh3kG^GN_DgrVX{4|-1m_ZyC Y5Wxx}_$CLi+A%6m?q_udl9ySn0NO$+8vpaya&h0Am3BA91M_Cy%$qke@BM!7 z&tkDapuLc?^+Ar1m#9oyW;_`^hRIW65|i5Gw+xMDG@fPRS+tuovmLsYHKh(&lS~<; zY$_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RC5qFya+I9Ep5q!BP7=dzyL2=iQ3woA3FjqM&Nz0NhaT`b{hUE6>w zW20iBWFc&5WF>5;DTP?tXtm_<$aWCIT-#eNC_0z*bG4o|%Q9~kFq0iyc0vbnxoRw% z{p{&`uws%&k7kkSSJ91ab1r8=i=#H8@5CcDA3EN>~7NNu}L7)C4(4S$tKzaN93!q;x zjF7W8>>MDuurlD{6Fg@gpn7u74DfM)JwEr}0u^2X1<(kLF6p2q-0*lVeZUyI{Qwm` zqq%>{^ghrGc<&A#4))%`ehE+9y7ugZ_g&AeJbF+Ay|Z@T|JZgkJ{p<6LvH}|hNs^@ z!hJQMY8#p>$l3@IfQ2fRK3J70N5}+E!9v=oQgW!)AQmcI9vlcQYLk|to|{FpH|gpD zu1F6_j3BbkTnkZW;q!7OvPc4`xyqs!QkBBA4EvZ|BtC?ggjwXY8URWT>Q6A5MXmjg z!B%`qD?Wz!2&LJDh#fOA8-SY_{{XyD;v6_{mD>M zo^{u(?^5dn68}Wa1Cs3{cl)o;&O_!`73PF z(D7|_=vBvv%T=NN07ZWR6`2MAz(+Qe+$?Og5OTgSau=bQ+_X_^1rA;0*k@li#O`~Uy| delta 19 ZcmaFC{eqh-pO=@50SE#ZH*(!$1pqM&1aklY diff --git a/__pycache__/spiderweb.cpython-312.pyc b/__pycache__/spiderweb.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2144b296494d66c8cc1b2f3a49a93ca65205f13e GIT binary patch literal 2153 zcmZ`)O>7fK6rR~#+Y52xIB^`H5#2(eStv2C8mQE&Dr!VkA>1E8LPgYCJR8S}z3a@b zNfSA$4^;BOt;_`?wTGxD5bC|h9xL^NQ6i$%9*~+#Zjf-|Q2O53>lhJ6nzwJ}y?O7= zyzjmJr@wzcf$=q!^Y_Dq{ELfVNF8Qp3Yfcu5k`yT4~e!p+T|qV^2Cstbc=kaFd1lw zDL}(41T@0JK-I;Fu5O`8oqF^{j&`i$Cj?W5xl;pjm$+RSqfC0xiGvasb;MxugO1J= zx&AI8%hW|1VpK^WgA8dhca8g|M&9c*7u;cg=X`@NbSsLy5h;x z#YHc~4J&VY!;BjXS;x$mOv^P{wpg%CkQMSXt}c0fPJx-(qG{#b8Bf85gE!H%7Z+1k z9Fse#JU4P?YRYuxT)Uhq8FK|IpIs=pGufQY%v5P1mrhlzf}2j2xjk#<+$=f-rIb?! zb9}+PF;QOh`b8M95CQNQIDu3WCk>=VHkC+SspoEG{K1i?aYwByzWUb6g*A2DSNrR% z(dVmu^{M93p9h{rNc`Xq93p!s=TDH_B~^gIQXf8fo-9kfsR|w#QgRyP@@~4SG>}0` zx`}##u3%77m1et%YVRR+_XT{Qxof5IfkIpXUDVm@bXD5bUX*ls>Fg9do}(EWrb)wR z);`qC`HE50Iw=I9#k7*a=N!$QF}1Q?uv}+L0S_5H%rP7ScwB7dFae z(_)@nwjD3tu?8}y;1+Dl(G?!Wvjc&o1B!l(B*2g3MS?KUp$3Bw0K@T?f?#5u3qWe* z$%wX^zMZXQHWJC&MSu9fO8m}8^@y*=ngeU<+rB!~h;FDOkJYi3I`-S8U$3mIN1sMW zV(hs}LdnO@ zAhe>LGw}W#bL)j}6ph?m28v&1wtJrl&+Qu~K+cgIg6ROZ;D!iWT0i^KSFcBi;1&@c zf&zUt!XV`U!DWD8Zzt)(0c0hFZwBXTMFKn4VxY=0;a~7c58_cys>%yPE2jaspohFbP zc^)PM!_D+BSL@V|C!6zk4%E+WBu7`?xoxh@-@aBqzZuh3n)pBYS7ZT4x8w~!9uMOUx_zQt|^CoC9$rwqsr*}ys%s0 zZqbB)PNi(}&LYvXm?+sdP5e!XgtdK(#v*DDpI&(4n1J2Ne4&0)vRS2Qe#%dQ00VT8 tc`8#%eUk9WL7yCXl1M%z@ogzgN4JMm`u=uOqKR#_pQd&+iH-_${{w;n(G36q literal 0 HcmV?d00001 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