lucifers_spelletje.py

Created by numworks-nl

Created on March 02, 2023

1.13 KB

Linker toets om één lucifer weg te halen, De omhoog-toets om er twee weg te halen, rechter toets om er drie weg te halen. Je speelt om de beurt tegen de computer en je mag de laatste lucifer niet pakken! Lukt het jou om te winnen van de computer?


from math import *
from kandinsky import *
from ion import *
from time import *

def draw(nb, color, top):
  for i in range(nb):
    fill_rect(i*15+10,70,5,50,color)
    fill_rect(i*15+9,60,7,10,top)
brown=color(255,204,153)
red=color(255,0,0)
white=color(255,255,255)
lucifers=0
draw(20,brown,red)
while lucifers<19:
  while keydown(KEY_LEFT) or keydown(KEY_UP) or keydown(KEY_RIGHT):
    continue
  while True :
    draw_string("Neem 1, 2 of 3 lucifers weg.",10,140)
    draw_string("De computer speelt na jou.",10,160)
    draw_string("Links=1 ; omhoog=2 ; rechts=3",10,180)
    if keydown(KEY_LEFT):
      lucifers+=1
      break
    else:
      if keydown(KEY_UP):
        lucifers+=2
        break
      else:
        if keydown(KEY_RIGHT):
          lucifers+=3
          break
  draw(lucifers,white,white)
  sleep(0.3)
  if lucifers==19:
    draw_string("Je hebt gewonnen",100,30)
  else:
    if (20-lucifers)%4==3:
      lucifers+=2
    else:
      if (20-lucifers)%4==0:
        lucifers+=3
      else:
        lucifers+=1
    draw(lucifers,white,white)
    if lucifers==19:
      draw_string("Je hebt verloren",100,30)

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.