mario_animation.py

Created by marius-layan

Created on February 05, 2024

5.89 KB

le bus était de découvrir la bibliothèque “turtle”. C’est mon tout premier visuelle sur la numworks c’est une petite animation du jeu Mario.


from turtle import *
hideturtle()
speed(10)
pensize(100)
a=-130
for i in range(4):
  penup()
  color('blue')
  goto(-150,a)
  a+=65
  pendown()
  goto(150,a)
penup()
pensize(22)
goto(-5,-80)
color('green')
pendown()
goto(-5,-45)
penup()
goto(-15,-35)
color('blue')
pensize(5)
pendown()
goto(5,-35)


penup()
color('black')
goto(5,-110)
pensize(5)
pendown()
goto(5,-50)
penup()
goto(-15,-110)
pendown()
goto(-15,-50)
penup()
goto(-18,-50)
pendown()
goto(8,-50)
goto(8,-40)
goto(-18,-40)
goto(-18,-50)

penup()
goto(-170,-100)
pensize(50)
color('brown')
pendown()
goto(170,-100)

penup()
goto(-170,-76)
pensize(8)
color('green')
pendown()
goto(170,-76)

penup()
goto(-50,80)
pensize(4)
color('white')
pendown()
goto(-20,80)
penup()
goto(-50,83)
pendown()
goto(-20,83)
penup()
goto(-45,86)
pendown()
goto(-25,86)
penup()
goto(-40,89)
pendown()
goto(-30,89)
penup()
goto(0,30)
pendown()
goto(30,30)
penup()
goto(0,33)
pendown()
goto(30,33)
penup()
goto(5,36)
pendown()
goto(25,36)
penup()
goto(10,39)
pendown()
goto(20,39)

penup()
goto(100,-29)
pendown()
goto(130,-29)
penup()
goto(100,-26)
pendown()
goto(130,-26)
penup()
goto(105,-23)
pendown()
goto(125,-23)
penup()
goto(110,-20)
pendown()
goto(120,-20)

penup()
goto(-100,40)
pendown()
goto(-130,40)
penup()
goto(-100,43)
pendown()
goto(-130,43)
penup()
goto(-105,46)
pendown()
goto(-125,46)
penup()
goto(-110,49)
pendown()
goto(-120,49)
a=25
b=-66
c=-5
d=-40
while 0==0:
  for i in range(50):
    a+=2
    pensize(4)
    penup()
    color('black')
    goto(a+8,b)
    pendown()
    goto(a+8,b-4)
    penup()
    goto(a+16,b)
    pendown()
    goto(a+16,b-4)
    penup()
    color('brown')
    goto(a,b)
    pendown()
    goto(a+20,b)
    goto(a+20,b+4)
    goto(a,b+4)
    penup()
    goto(a+4,b+8)
    pendown()
    goto(a+16,b+8)
    color('blue')
    penup()
    goto(a-2,b+8)
    pendown()
    goto(a-2,b)
    penup()
    goto(a+2,b+11)
    pendown()
    goto(a+2,b+8)
    penup()
    pensize(3)
    goto(a+14,b-5)
    pendown()
    goto(a+12,b-3)
    penup()
    goto(a+4,b-5)
    pendown()
    goto(a+4,b-3)
    goto(a+4,b-3)
    goto(a+4,b-4)
    
    if i<7:
      d+=4
    if -1<i<6:
      pensize(4)
      penup()
      color('white')
      goto(c-7,d)
      pendown()
      goto(c-7,d)
      penup()
      goto(c+7,d)
      pendown()
      goto(c+7,d)
    if 0<i<6:
      penup()
      color('red')
      goto(c-7,d-4)
      pendown()
      goto(c+7,d-4)
      penup()
      color('white')
      goto(c-5,d-4)
      pendown()
      goto(c+5,d-4)
    if 1<i<6:
      penup()
      color('red')
      goto(c-6,d-8)
      pendown()
      goto(c+6,d-8)
      penup()
      color('blue')
      goto(c-8,d-8)
      pendown()
      goto(c-8,d-8)
      penup()
      goto(c+8,d-8)
      pendown()
      goto(c+8,d-8)
    if 2<i<6:
      penup()
      goto(c-12,d-12)
      pendown()
      goto(c+12,d-12)
      penup()
      color('red')
      goto(c-3,d-10)
      pendown()
      goto(c+3,d-10)
    if 3<i<6:
      color('blue')
      penup()
      goto(c-5,d-16)
      pendown()
      goto(c+5,d-16)
      penup()
      color('green')
      goto(c,d-11)
      pendown()
      goto(c,d-16)
    if 4<i<6:
      penup()
      goto(c,d-18)
      pendown()
      goto(c,d-20)
    if 17<i<25:
      d-=4
      pensize(10)
    if i==18:
      penup()
      color('blue')
      goto(c-8,d)
      pendown()
      goto(c+8,d)
    if i==19:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if i==20:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if i==21:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if i==22:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d-2)


  for j in range(50):
    
    a-=2
    pensize(4)
    penup()
    color('black')
    goto(a+8,b)
    pendown()
    goto(a+8,b-4)
    penup()
    goto(a+16,b)
    pendown()
    goto(a+16,b-4)
    penup()
    color('brown')
    goto(a,b)
    pendown()
    goto(a+20,b)
    goto(a+20,b+4)
    goto(a,b+4)
    penup()
    goto(a+4,b+8)
    pendown()
    goto(a+16,b+8)
    color('blue')
    penup()
    goto(a+24,b-2)
    pendown()
    goto(a+24,b+10)
    penup()
    goto(a+18,b+11)
    pendown()
    goto(a+18,b+8)
    penup()
    pensize(3)
    goto(a+18,b-5)
    pendown()
    goto(a+18,b-3)
    penup()
    goto(a+10,b-5)
    pendown()
    goto(a+10,b-3)
    
    if j<7:
      d+=4
    if -1<j<6:
      pensize(4)
      penup()
      color('white')
      goto(c-7,d)
      pendown()
      goto(c-7,d)
      penup()
      goto(c+7,d)
      pendown()
      goto(c+7,d)
    if 0<j<6:
      penup()
      color('red')
      goto(c-7,d-4)
      pendown()
      goto(c+7,d-4)
      penup()
      color('white')
      goto(c-5,d-4)
      pendown()
      goto(c+5,d-4)
    if 1<j<6:
      penup()
      color('red')
      goto(c-6,d-8)
      pendown()
      goto(c+6,d-8)
      penup()
      color('blue')
      goto(c-8,d-8)
      pendown()
      goto(c-8,d-8)
      penup()
      goto(c+8,d-8)
      pendown()
      goto(c+8,d-8)
    if 2<j<6:
      penup()
      goto(c-12,d-12)
      pendown()
      goto(c+12,d-12)
      penup()
      color('red')
      goto(c-3,d-10)
      pendown()
      goto(c+3,d-10)
    if 3<j<6:
      color('blue')
      penup()
      goto(c-5,d-16)
      pendown()
      goto(c+5,d-16)
      penup()
      color('green')
      goto(c,d-11)
      pendown()
      goto(c,d-16)
    if 4<j<6:
      penup()
      goto(c,d-18)
      pendown()
      goto(c,d-20)
    if 17<j<25:
      d-=4
      pensize(10)
    if j==18:
      penup()
      color('blue')
      goto(c-8,d)
      pendown()
      goto(c+8,d)
    if j==19:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if j==20:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if j==21:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d)
    if j==22:
        penup()
        goto(c-8,d)
        pendown()
        goto(c+8,d-2)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.