fetenationale22.py

Created by apocaliips

Created on July 01, 2022

3.71 KB


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

#COLORS
black = (0,0,0)
ocre = (250,210,125)
green = (25,210,0)
grey = (236,235,235)
yellow = (255,180,50)
white = (246,245,245)
white2 = (255,255,255)

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,white2)
  if image_type == 1:
    draw_party(offset)
  elif image_type == 2:
    draw_eiffel(offset)
  else:
    draw_flag(offset)

def draw_flag():
  rects = [
  (20,48,17,32,(0,34,81)),
  (53,49,17,32,(210,15,41)),
  (15,43,5,70,(198,198,198)),
  ]
  for r in rects:
    fill_rect(*r)

def draw_party(offset):
  rects = [
  (96,55,9,2,(255,183,52)),
  (105,55,7,2,(198,198,198)),
  (118,55,7,2,(198,198,198)),
  (107,53,7,2,(198,198,198)),
  (112,49,7,2,(198,198,198)),
  (114,43,3,6,(198,198,198)),
  (116,53,7,2,(198,198,198)),
  (109,51,12,2,(198,198,198)),
  (91,57,18,2,(255,183,52)),
  (89,59,23,2,(255,183,52)),
  (88,61,17,2,(255,183,52)),
  (105,61,9,2,(210,15,41)),
  (100,63,14,2,(210,15,41)),
  (98,65,5,2,(210,15,41)),
  (96,67,7,2,(210,15,41)),
  (96,69,11,6,(210,15,41)),
  (93,74,12,3,(210,15,41)),
  (93,77,8,2,(210,15,41)),
  (107,65,6,2,(210,15,41)),
  (107,67,5,4,(210,15,41)),
  (107,71,3,2,(210,15,41)),
  (87,63,13,2,(255,183,52)),
  (87,65,11,2,(255,183,52)),
  (87,67,9,7,(255,183,52)),
  (88,74,5,3,(255,183,52)),
  (91,77,2,2,(255,183,52)),
  (103,65,4,4,(255,183,52)),
  (125,55,9,2,(255,183,52)),
  (121,57,18,2,(255,183,52)),
  (118,59,23,2,(255,183,52)),
  (125,61,17,2,(255,183,52)),
  (116,61,9,2,(210,15,41)),
  (116,63,14,2,(210,15,41)),
  (127,65,5,2,(210,15,41)),
  (127,67,7,2,(210,15,41)),
  (123,69,11,6,(210,15,41)),
  (125,74,12,3,(210,15,41)),
  (129,77,8,2,(210,15,41)),
  (117,65,6,2,(210,15,41)),
  (118,67,5,4,(210,15,41)),
  (120,71,3,2,(210,15,41)),
  (130,63,13,2,(255,183,52)),
  (132,65,11,2,(255,183,52)),
  (134,67,9,7,(255,183,52)),
  (137,74,5,3,(255,183,52)),
  (137,77,2,2,(255,183,52)),
  (123,65,4,4,(255,183,52)),
  (89,81,5,4,(255,239,120)),
  ]
  for r in rects:
    fill_rect(*r)

def draw_flag(offset):
  rects = [
  (20,48,17,32,(0,34,81)),
  (53,49,17,32,(210,15,41)),
  (15,43,5,70,(198,198,198)),
  ]
  for r in rects:
    fill_rect(*r)


def draw_eiffel(offset):
  rects = [
  (168,101,7,7,(255,183,52)),
  (160,108,17,2,(255,183,52)),
  (197,108,18,2,(255,183,52)),
  (170,98,7,6,(255,183,52)),
  (173,95,9,6,(255,183,52)),
  (181,93,7,5,(255,183,52)),
  (175,88,7,7,(255,183,52)),
  (177,82,6,6,(255,183,52)),
  (180,79,7,3,(255,183,52)),
  (181,72,6,7,(255,183,52)),
  (185,51,3,21,(255,183,52)),
  (182,48,6,3,(255,183,52)),
  (183,46,5,2,(255,183,52)),
  (186,40,2,6,(255,183,52)),
  (200,101,6,7,(255,183,52)),
  (207,103,4,5,(255,183,52)),
  (164,103,4,5,(255,183,52)),
  (196,98,7,6,(255,183,52)),
  (192,95,9,6,(255,183,52)),
  (188,93,6,5,(255,183,52)),
  (194,88,7,7,(255,183,52)),
  (192,82,6,6,(255,183,52)),
  (188,79,7,3,(255,183,52)),
  (188,72,5,7,(255,183,52)),
  (188,51,3,21,(255,183,52)),
  (188,48,6,3,(255,183,52)),
  (188,46,5,2,(255,183,52)),
  (188,40,2,6,(255,183,52)),
  ]
  for r in rects:
    fill_rect(*r)

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

while (True):
  if keydown(KEY_OK):
    fill_rect(32,125,208,53,white2)
    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)