# spring.py

Created by numworks

Created on March 19, 2020

4.5 KB

Script pour fêter le printemps ! Installez la dernière mise à jour pour pouvoir faire fonctionner ce script.

```from kandinsky import *
from time import *
from ion import *
from random import *

#COLORS
black = (0,0,0)
white = (255,255,255)
green = (130,200,100)
yellow = (255,180,50)
yellow2 = (230,130,0)
pink1 = (230,0,125)
pink2 = (240,160,200)
red1 = (250,180,140)
red2 = (220,60,0)
grey = (236,235,235)

def draw_icon(x,image_type):
offset = 1
if x == 2:
offset = 70
if x == 3:
offset = 140
fill_rect(32+offset,41,66,78,white)
if image_type == 1:
draw_flower(offset)
elif image_type == 2:
draw_tulip(offset)
else:
draw_rose(offset)

def draw_casino():
fill_rect(32,33,208,8,yellow)
fill_rect(24,33,8,154,yellow)
fill_rect(32,179,208,8,yellow)
fill_rect(240,33,9,154,yellow)
fill_rect(98,41,6,78,yellow)
fill_rect(169,41,6,78,yellow)
fill_rect(32,119,208,6,yellow)
fill_rect(253,129,14,30,yellow)
fill_rect(269,107,9,45,yellow)
fill_rect(278,107,4,14,yellow)
fill_rect(284,76,9,45,yellow)
fill_rect(265,33,40,40,yellow)
draw_string("OK",276,45,white,yellow)

def draw_flower(offset):
#green
fill_rect(64+offset,75,2,35,green)
fill_rect(58+offset,101,6,3,green)
fill_rect(58+offset,97,4,4,green)
fill_rect(59+offset,95,2,2,green)
fill_rect(69+offset,95,2,2,green)
fill_rect(66+offset,101,6,3,green)
fill_rect(68+offset,97,4,4,green)
#yellow
fill_rect(60+offset,65,10,3,yellow)
fill_rect(63+offset,62,4,9,yellow)
#pink1
fill_rect(54+offset,68,3,7,pink1)
fill_rect(57+offset,65,3,3,pink1)
fill_rect(67+offset,61,3,4,pink1)
fill_rect(67+offset,68,3,4,pink1)
fill_rect(60+offset,68,3,4,pink1)
fill_rect(54+offset,58,3,7,pink1)
fill_rect(73+offset,58,3,7,pink1)
fill_rect(73+offset,68,3,7,pink1)
fill_rect(57+offset,75,6,2,pink1)
fill_rect(67+offset,75,6,2,pink1)
fill_rect(67+offset,56,6,2,pink1)
fill_rect(57+offset,56,6,2,pink1)
fill_rect(70+offset,65,3,3,pink1)
fill_rect(63+offset,71,4,4,pink1)
fill_rect(63+offset,58,4,4,pink1)
fill_rect(60+offset,61,3,4,pink1)
#pink2
fill_rect(67+offset,72,3,3,pink2)
fill_rect(60+offset,72,3,3,pink2)
fill_rect(60+offset,58,3,3,pink2)
fill_rect(67+offset,58,3,3,pink2)
fill_rect(70+offset,58,3,7,pink2)
fill_rect(70+offset,68,3,7,pink2)
fill_rect(57+offset,68,3,7,pink2)
fill_rect(57+offset,58,3,7,pink2)

def draw_rose(offset):
#green
fill_rect(66+offset,80,5,1,green)
fill_rect(59+offset,89,5,1,green)
fill_rect(66+offset,95,5,1,green)
fill_rect(64+offset,75,2,35,green)
#down
fill_rect(56+offset,74,18,1,red1)
fill_rect(55+offset,71,20,3,red2)
fill_rect(53+offset,68,23,3,red1)
fill_rect(52+offset,64,25,4,red2)
fill_rect(55+offset,61,19,3,red1)
fill_rect(58+offset,58,13,3,red2)
fill_rect(60+offset,57,9,1,red1)

def draw_tulip(offset):
#green
fill_rect(60+offset,75,1,2,green)
fill_rect(59+offset,77,3,2,green)
fill_rect(69+offset,79,1,2,green)
fill_rect(68+offset,81,3,2,green)
fill_rect(67+offset,83,5,19,green)
fill_rect(66+offset,102,5,2,green)
fill_rect(59+offset,98,5,2,green)
fill_rect(58+offset,79,5,19,green)
fill_rect(64+offset,75,2,35,green)
#yellow
fill_rect(63+offset,73,4,1,yellow)
fill_rect(62+offset,72,6,1,yellow)
fill_rect(61+offset,57,8,15,yellow)
fill_rect(60+offset,59,1,1,yellow)
fill_rect(63+offset,56,3,1,yellow)
#yellow2
fill_rect(60+offset,58,1,1,yellow2)
fill_rect(61+offset,57,1,1,yellow2)
fill_rect(62+offset,56,1,1,yellow2)
fill_rect(66+offset,56,2,1,yellow2)
fill_rect(63+offset,58,3,1,yellow2)
fill_rect(68+offset,60,1,1,yellow2)
fill_rect(69+offset,57,2,14,yellow2)
fill_rect(58+offset,60,1,10,yellow2)
fill_rect(59+offset,59,1,13,yellow2)
fill_rect(69+offset,71,1,1,yellow2)
fill_rect(68+offset,72,1,1,yellow2)
fill_rect(67+offset,73,1,1,yellow2)
fill_rect(63+offset,74,4,1,yellow2)
fill_rect(63+offset,65,1,1,yellow2)
fill_rect(64+offset,64,1,1,yellow2)
fill_rect(65+offset,63,1,1,yellow2)
fill_rect(66+offset,62,1,1,yellow2)
fill_rect(61+offset,63,2,11,yellow2)
fill_rect(60+offset,60,1,13,yellow2)

def gambling():
icons = 3
icon_left = randint(1,icons)
icon_middle = randint(1,icons)
icon_right = randint(1,icons)
draw_icon(1, icon_left)
draw_icon(2, icon_middle)
draw_icon(3, icon_right)

if (icon_left==icon_middle) and (icon_middle==icon_right):
return True
else:
return False

draw_casino()

while (True):
if keydown(KEY_OK):
fill_rect(32,125,208,53,white)
result = False
for i in range(20):
result = gambling()
if result:
draw_string("You win !",90,140,black)
else:
draw_string("Try again",90,140,black)
sleep(0.01)```