thedoorgame.py

Created by ews31415

Created on August 06, 2021

1.3 KB

Pick a door and test your luck. Will you win the car? Will you win $5,000? Or is there a goat in the future?


# 2021-08-05 EWS
# Three Door Game
# based on Lets Make A Deal
from math import *
from random import *
from kandinsky import *
from ion import *

# set up the key function
def key():
  while True:
    if keydown(KEY_ONE):
      return 1
    if keydown(KEY_TWO):
      return 2
    if keydown(KEY_THREE):
      return 3

# initial doors: indigo, fir green, orange
fill_rect(40,15,100,75,color(43,43,95))
fill_rect(140,15,200,75,color(34,139,34))
fill_rect(240,15,300,75,color(255,127,0))
# text, wheat
draw_string("1",70,45,color(245,222,179),color(43,43,95))
draw_string("2",170,45,color(245,222,179),color(34,139,34))
draw_string("3",270,45,color(245,222,179),color(255,127,0))
# prize setup
p=["\u0024 5,000","CAR","GOAT"]
l=[0,1,2]
w=[]
for i in range(3):
  a=choice(l)
  w.append(a)
  l.remove(a)
# ask for a door
draw_string("Which door do you want?",40,120,color(0,0,0))
k=key()
if k==1:
  ps=p[w[0]]
if k==2:
  ps=p[w[1]]
if k==3:
  ps=p[w[2]]
# the reveal
fill_rect(40,15,100,75,color(0,0,0))
fill_rect(140,15,200,75,color(0,0,0))
fill_rect(240,15,300,75,color(0,0,0))
# text, wheat
draw_string(p[w[0]],45,45,color(245,222,179),color(0,0,0))
draw_string(p[w[1]],145,45,color(245,222,179),color(0,0,0))
draw_string(p[w[2]],245,45,color(245,222,179),color(0,0,0))
draw_string("You win: "+ps,40,160,color(0,0,0))