film.py

Created by mael57703

Created on January 06, 2026

4.62 KB

Voici une petite animation qui tourne en boucle !


#Modules

from turtle import *
from kandinsky import *
from ion import *
from random import *
from time import *

#Couleurs

bg=(230,180,60)
m=(180,130,20)
bleu_c=(120,180,200)
bleu_f=(10,30,160)


#Decors

def nuit(pe):
  fill_rect(0,0,320,150,bleu_f)
  fill_rect(0,150,320,80,'green')
  fill_rect(40,25,18,18,'white')
  
  if pe==True:
    fill_rect(115,88,2,2,'white')
    fill_rect(238,35,2,2,'white')
    fill_rect(223,125,2,2,'white')
    fill_rect(243,107,2,2,'white')
    fill_rect(58,59,2,2,'white')
  
    fill_rect(154,35,2,2,'white')
    fill_rect(257,46,2,2,'white')
    fill_rect(50,82,2,2,'white')
    fill_rect(93,56,2,2,'white')
    fill_rect(212,97,2,2,'white')  
    
  if pe==False :
    for i in range(10):
      fill_rect(randint(10,310),randint(10,140),2,2,'white')

def zzz(x,y):
  fill_rect(x-int(2.5),y-10,int(7.5),int(2.5),bleu_c)
  fill_rect(x+int(2.5),y-10,int(2.5),int(7.5),bleu_c)
  fill_rect(x+int(2.5),y-5,int(7.5),int(2.5),bleu_c)
  
  fill_rect(x-5,y-int(2.5),5,int(2.5),bleu_c)
  fill_rect(x-int(2.5),y,5,int(2.5),bleu_c)
  
  fill_rect(x-int(12.5),y+int(2.5),int(7.5),int(2.5),bleu_c)
  fill_rect(x-int(7.5),y+int(2.5),int(2.5),int(7.5),bleu_c)
  fill_rect(x-int(7.5),y+int(7.5),int(7.5),int(2.5),bleu_c)

def bob_1_0(x,y) :
  fill_rect(x-5,y-int(12.5),10,int(7.5),bg)
  fill_rect(x-5,y-int(12.5),10,int(2.5),m)
  fill_rect(x-5,y-int(12.5),5,5,m)
  fill_rect(x-int(2.5),y-5,5,int(2.5),bg)
  fill_rect(x-5,y-int(3.75),10,int(16.25),'red')
  fill_rect(x-5,y+int(12.5),10,5,'blue')

def bob_1_1(x,y) :
  bob_1_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),5,10,'red')
  fill_rect(x-int(2.5),y+int(7.5),5,int(2.5),bg)
  fill_rect(x-int(2.5),y+int(17.5),5,10,'blue')

def bob_1_2(x,y) :
  bob_1_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),5,10,'red')
  fill_rect(x-int(2.5),y+int(7.5),5,int(2.5),bg)
  fill_rect(x-int(2.5),y+int(17.5),10,5,'blue')

def bob_1_3(x,y):
  bob_1_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),10,5,'red')
  fill_rect(x+int(7.5),y-int(2.5),int(2.5),5,bg)
  fill_rect(x-int(2.5),y+int(17.5),5,10,'blue')
  
def bob_2_0(x,y):
  bob_1_0(x,y)
  fill_rect(x-5,y-int(12.5),10,int(7.5),bg)
  fill_rect(x-5,y-int(12.5),10,int(2.5),m)
  fill_rect(x,y-int(12.5),5,5,m)

def bob_2_1(x,y):
  bob_2_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),5,10,'red')
  fill_rect(x-int(2.5),y+int(7.5),5,int(2.5),bg)
  fill_rect(x-int(2.5),y+int(17.5),5,10,'blue')

def bob_2_3(x,y):
  bob_2_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),5,10,'red')
  fill_rect(x-int(2.5),y+int(7.5),5,int(2.5),bg)
  fill_rect(x-int(2.5),y+int(17.5),-10,5,'blue')
  
def bob_2_2(x,y):
  bob_2_0(x,y)
  fill_rect(x-int(2.5),y-int(2.5),-10,5,'red')
  fill_rect(x-int(10),y-int(2.5),int(-2.5),5,bg)
  fill_rect(x-int(2.5),y+int(17.5),5,10,'blue')

def bob_3_0(x,y):
  fill_rect(x-int(12.5),y-5,int(7.5),10,bg)
  fill_rect(x-int(12.5),y-5,int(2.5),10,m)
  fill_rect(x-int(12.5),y,5,5,m)
  fill_rect(x-5,y-int(2.5),int(2.5),5,bg)
  
  fill_rect(x-int(3.75),y-5,18,10,'red')
  fill_rect(x-int(2.5),y-int(2.5),10,5,'red')
  fill_rect(x+int(7.5),y-int(2.5),int(2.5),5,bg)
  
  fill_rect(x+15,y-5,5,10,'blue')
  fill_rect(x+int(17.5),y-int(2.5),10,5,'blue')

#Animations

brk=False

while brk==False :
  c=0
  x=50
  y=140
  ps=0
  while True :
    if keydown(KEY_BACKSPACE) :
      brk=True
    ps=ps+1
    fill_rect(0,0,320,150,(140+c,200-c/2,255-c))    
    fill_rect(90,70,50,20,'white')    
    fill_rect(220,30,50,25,'white')    
    fill_rect(145+int(ps),20+int(ps),30,30,'yellow')
    fill_rect(0,150,320,80,'green')
    sleep(0.015)
    bob_1_3(x+int(ps)*2,y)
    sleep(0.015)
    bob_1_2(x+int(ps)*2,y)
    sleep(0.015)
    if ps>70 :
      c=c+2
    if ps>120:
      break 
  nuit(True)
  bob_1_1(290,140)
  sleep(0.5)
  bob_2_1(290,140)
  sleep(0.5)
  ps=0
  x=290
  y=140
  while True :
    if keydown(KEY_BACKSPACE) :
      brk=True
    ps=ps+2
    nuit(False)
    sleep(0.015)
    bob_2_2(x-int(ps),y)
    sleep(0.015)
    bob_2_3(x-int(ps),y)
    sleep(0.015)
    if ps>240 :
      break
  nuit(True)
  bob_2_1(50,140)
  sleep(0.5)
  nuit(True)
  bob_1_1(50,140)
  sleep(0.5)
  nuit(True)
  bob_1_2(50,150)
  sleep(0.5)
  nuit(True)
  bob_3_0(50,160)
  zzz(65,120)
  sleep(0.5)
  ps=100
  c=0
  while True :
    if keydown(KEY_BACKSPACE) :
      brk=True
    fill_rect(0,150,320,80,'green')
    fill_rect(0,0,320,150,(240-int(c),200,155+int(c)))
    fill_rect(220,30,50,25,'white')
    fill_rect(145-int(ps),20+int(ps),30,30,'yellow')
    fill_rect(90,70,50,20,'white')
    bob_3_0(50,160)
    zzz(65,120)
    ps=ps-1
    if c<100 :
      c=c+1
    if ps==0 :
      break
    sleep(0.04)
  fill_rect(0,150,320,80,'green')
  bob_1_2(50,150)
  sleep(0.5)
  fill_rect(0,150,320,80,'green')
  bob_1_1(50,140)
  sleep(1)

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.