# drapeaux.py

Created by julien-bernon

Created on October 19, 2020

2.93 KB

```from kandinsky import *
def france():
for i in range(320):
for j in range(220):
if i<(320/3):
set_pixel(i,j,(0,0,255))
elif i<(2*320/3):
set_pixel(i,j,(255,255,255))
else :
set_pixel(i,j,(255,0,0))

def italie():
for i in range(320):
for j in range(220):
if i<(320/3):
set_pixel(i,j,(0,255,0))
elif i<(2*320/3):
set_pixel(i,j,(255,255,255))
else :
set_pixel(i,j,(255,0,0))

def allemagne():
for i in range(320):
for j in range(220):
if j<(220/3):
set_pixel(i,j,(0,0,0))
elif j<(2*220/3):
set_pixel(i,j,(255,255,0))
else :
set_pixel(i,j,(255,0,0))

def rec_france():
fill_rect(0,0,320//3,220,(0,0,255))
fill_rect(320//3,0,2*320//3,220,(255,255,255))
fill_rect(2*320//3,0,320,220,(255,0,0))

def rec_italie():
fill_rect(0,0,320//3,220,(0,255,0))
fill_rect(320//3,0,2*320//3,220,(255,255,255))
fill_rect(2*320//3,0,320,220,(255,0,0))

def rec_allemagne():
fill_rect(0,0,320,220//3,(0,0,0))
fill_rect(0,220//3,320,2*220//3,(255,255,0))
fill_rect(0,2*220//3,320,220,(255,0,0))

def oscillation():
valeur=0
while True:
fill_rect(0,0,320,220,(255-valeur,valeur,0))
valeur=(valeur+1)%256

def bouge1(vitx,vity,posx,posy):
while True:
fill_rect(posx,posy,10,10,(255,255,255))
posx+=vitx
posy+=vity
fill_rect(posx,posy,10,10,(255,0,0))

def bouge2(vitx,vity,posx,posy):
while not(posx<0 or posy<0 or posx>(320-10) or posy>(220-10)):
fill_rect(posx,posy,10,10,(255,255,255))
posx+=vitx
posy+=vity
fill_rect(posx,posy,10,10,(255,0,0))

def bouge3(vitx,vity,posx,posy):
while True:
if posx<0 or posx>(320-10):
vitx=-vitx
if posy<0 or posy>(220-10):
vity=-vity
fill_rect(posx,posy,10,10,(255,255,255))
posx+=vitx
posy+=vity
fill_rect(posx,posy,10,10,(255,0,0))

from time import sleep
def bouge4(vitesse,vitx,vity,posx,posy):
while True:
if posx<0 or posx>(320-10):
vitx=-vitx
if posy<0 or posy>(220-10):
vity=-vity
fill_rect(posx,posy,10,10,(255,255,255))
posx+=vitx
posy+=vity
fill_rect(posx,posy,10,10,(255,0,0))
sleep(1/vitesse)

from ion import *
def bouge5():
posx,posy=160,110
vitesse=3
while True:
if posx<0 or posy<0 or posx>(320-10) or posy>(220-10):
print("Perdu !")
return False
fill_rect(posx,posy,10,10,(255,255,255))
if keydown(KEY_LEFT):
posx-=1
if keydown(KEY_RIGHT):
posx+=1
if keydown(KEY_UP):
posy-=1
if keydown(KEY_DOWN):
posy+=1
if keydown(KEY_PLUS):
vitesse+=1
if keydown(KEY_MINUS):
vitesse-=1
fill_rect(posx,posy,10,10,(255,0,0))
sleep(1/vitesse)```