Exemple #1
0
def dessine(mot,p,e):
  global to_find
  for i in range(len(mot)):
    if mot[i] in to_find:
      canvas.draw_line((i+1)*e+(i)*p,60,(i+1)*(e+p),60)
    else:
      a = (i+1)*e+(i)*p
      b = (i+1)*(e+p)
      canvas.draw_text( (a+b)/2 , 50 , mot[i])
Exemple #2
0
    def render(self):
        self.time += 1
        canvas.clear()
        canvas.draw_image(images[self.fond.name], self.fond.center, self.fond.size, (470, 150), self.fond.size2, 0)
        canvas.draw_image(
            images[self.ball.info.name],
            self.ball.info.center,
            self.ball.info.size,
            self.ball.pos,
            self.ball.info.size2,
            self.ball.angle,
        )
        canvas.draw_line((500, 146), (400, 146), 3, "Red")
        canvas.draw_text("Score: " + str(self.ball.get_score()), (370, 46), 30, "Orange")
        c = self.get_kb()
        if c == "38":
            self.ball.shooting = True
            self.ball.shoot()
        if c == None:
            self.ball.shooting = False

        self.ball.update()
def render():
  global jeu, count, partie, timer
  canvas.clear()
  
  canvas.draw_image(echiquier, (175,171),(350,342),(250,250),(500,500),0)
 
  board = str(jeu.board).split()
 
  j = 0
  for ligne in board:
    i = 0
    for c in ligne:
      i += 1
      if c<> ".":
        x = ML+i*(W-2*ML)/8 - 25
        y = MT+j*(W-2*MT)/8 + 12
        p = pieces[c]
        
        canvas.draw_image(pions,
                         (
						 pions_center[0]+p[1]*pions_size[0],
                         pions_center[1]+p[0]*pions_size[1]),
                         pions_size,
                         (x,y),
                         pions_size2,
                         0
        )
    j += 1  
  
  
  
  if count < len(partie):
    canvas.draw_text(partie[count],(20,20),24,'Blue')
    jeu.move(partie[count])
    jeu.advance()
  
  count += 1
def draw():
  
  global bits, out
  canvas.fill_rect(0,0,500,500)
  left = 80
  top = 30
  canvas.draw_line((0,30+top),(500,30+top),4,'Blue')  
  cl2 = 'Yellow'
  
  canvas.draw_text("ENTREES",(left-30,25+top),24,cl2)
  canvas.draw_text("SORTIES",(left+250,25+top),24,cl2)
  canvas.draw_circle((left, 50+top), 10, 2, 'Blue', color(str(bits['A'])))
  canvas.draw_circle((left, 73+top), 10, 2, 'Blue', color(str(bits['B'])))
  canvas.draw_circle((left, 96+top), 10, 2, 'Blue', color(str(bits['C'])))

  canvas.draw_circle((left+170, 50+top), 10, 2, 'Blue', color(out))
  
  canvas.draw_text("A: "+str(bits['A']),(left+15,58+top),24,cl2)
  canvas.draw_text("B: "+str(bits['B']),(left+15,80+top),24,cl2)
  canvas.draw_text("C: "+str(bits['C']),(left+15,102+top),24,cl2)
  canvas.draw_text(inp.get_text(),(left+185,58+top),24,cl2)
  
  """
  A FAIRE:
  
  Dessiner avec draw_circle et draw_line les interrupteurs
  et les faire basculer et eteindre quand les entrees changent
  
  """
  #dessin des fils
  canvas.draw_line((0,290+top),(100,290+top),3,'Blue')
  canvas.draw_line((150,290+top),(200,290+top),3,'Blue')
  canvas.draw_line((200,230+top),(200,350+top),3,'Blue')
  canvas.draw_line((200,230+top),(250,230+top),3,'Blue')
  canvas.draw_line((200,350+top),(250,350+top),3,'Blue')
  canvas.draw_line((300,230+top),(350,230+top),3,'Red')
  canvas.draw_line((300,350+top),(350,350+top),3,'Red')
  canvas.draw_line((350,230+top),(350,350+top),3,'Red')
  canvas.draw_line((500,290+top),(350,290+top),3,'Red') 
  canvas.draw_circle((420, 290+top), 30, 2, 'Blue', color(out))
  
  canvas.draw_text("A",(115,270+top),24,cl2)
  canvas.draw_text("B",(267,210+top),24,cl2)
  canvas.draw_text("C",(267,330+top),24,cl2)
  #dessin des interrupteurs
  
  if bits['C'] == 0:
    canvas.draw_line((250,350+top),(300,350+top),3,'Orange')
  else:
    canvas.draw_line((250,350+top),(300,330+top),3,'Orange')
def draw(mycanvas):
  #ceci est la fonction qui gere l'ecran
  global bits
  left = 80
  top = 30
  canvas.draw_line((0,30+top),(500,30+top),4,'Blue')  
  cl2 = 'Yellow'
  
  canvas.draw_text("ENTREES",(left-30,25+top),24,cl2)
  canvas.draw_text("SORTIES",(left+250,25+top),24,cl2)
  canvas.draw_circle((left, 50+top), 10, 2, 'Blue', color(str(bits['A'])))
 
  canvas.draw_circle((left+250, 50+top), 10, 2, 'Blue', color(str(bits['A'])))
  
  canvas.draw_text("A: "+str(bits['A']),(left+15,58+top),24,cl2)
  canvas.draw_text("L: "+str(bits['A']),(left+265,58+top),24,cl2)
 
  canvas.draw_line((0,290+top),(100,290+top),3,'Red')
  #canvas.draw_line((150,290+top),(300,290+top),3,'Blue')
  canvas.draw_line((500,290+top),(150,290+top),3,'Blue') 
  
  canvas.draw_circle((420, 290+top), 30, 2, 'Blue', color(str(bits['A'])))
  
  canvas.draw_text("A",(115,270+top),24,cl2)
  canvas.draw_text("L",(410,240+top),24,cl2)
  
  if bits['A'] == 0:
    canvas.draw_line((100,290+top),(150,270+top),3,'Orange')
  else:
    canvas.draw_line((100,290+top),(150,290+top),3,'Orange')
  
  """
def draw():
  #ceci est la fonction qui gere l'ecran
  global bits
  canvas.fill_rect(0,0,500,500)
  left = 80
  top = 30
  canvas.draw_line((0,30+top),(500,30+top),4,'Blue')  
  cl2 = 'Yellow'
  
  canvas.draw_text("ENTREES",(left-30,25+top),24,cl2)
  canvas.draw_text("SORTIES",(left+250,25+top),24,cl2)
  if (bits['A']+bits['B'] >= 1):
    equ = 1
  else:
    equ = 0
  canvas.draw_circle((left, 50+top), 10, 2, 'Blue', color(str(bits['A'])))
  canvas.draw_circle((left, 80+top), 10, 2, 'Blue', color(str(bits['B'])))
 
  canvas.draw_circle((left+250, 50+top), 10, 2, 'Blue', color(str(equ)))
  
  canvas.draw_text("A: "+str(bits['A']),(left+15,58+top),24,cl2)
  canvas.draw_text("B: "+str(bits['B']),(left+15,88+top),24,cl2)
  canvas.draw_text("L: "+str(equ),(left+265,58+top),24,cl2)
 
  canvas.draw_line((0,290+top),(100,290+top),3,'Red')
  canvas.draw_line((150,350+top),(200,350+top),3,'Blue')
  canvas.draw_line((50,350+top),(100,350+top),3,'Red')
  canvas.draw_line((50,350+top),(50,290+top),3,'Red')
  canvas.draw_line((200,350+top),(200,290+top),3,'Blue')
  canvas.draw_line((500,290+top),(150,290+top),3,'Blue') 
  
  canvas.draw_circle((420, 290+top), 30, 2, 'Blue', color(str(equ)))
  
  canvas.draw_text("A",(115,270+top),24,cl2)
  canvas.draw_text("B",(115,320+top),24,cl2)
  canvas.draw_text("L",(410,240+top),24,cl2)
  
  if bits['A'] == 0:
    canvas.draw_line((100,290+top),(150,270+top),3,'Orange')
  else:
    canvas.draw_line((100,290+top),(150,290+top),3,'Orange')
    
  if bits['B'] == 0:
    canvas.draw_line((100,350+top),(150,330+top),3,'Orange')
  else:
    canvas.draw_line((100,350+top),(150,350+top),3,'Orange')
  
  """
Exemple #7
0
 def render(self):
 
   #global errors, mot, to_find, msg , end_game
 
   canvas.clear()
 
   if self.msg <> None:
     canvas.draw_text(200,250,self.msg)
 
   if self.end_game:
     canvas.add_button(26*18,0,18,18,"@")
   
   c = self.get_mouse()
   if c <> None:
     #une lettre est cliquee mouse_handler
     #canvas.draw_text(200,250,c)
     self.mouse_handler(c)
   
 
   w = 18
   for i in range(26):
     canvas.add_button(i*w,0,18,18,chr(65+i))
 
 
   n = len(self.mot)
   p = (500 * 2) / ( 3*n + 1 )
   e = p / 2
   
   for i in range(len(self.mot)):
     if self.mot[i] in self.to_find:
       canvas.draw_line((i+1)*e+(i)*p,80,(i+1)*(e+p),80)
     else:
       a = (i+1)*e+(i)*p
       b = (i+1)*(e+p)
       canvas.draw_text((a+b)/2 - e/2 , 70, self.mot[i])
 
 
   if (self.errors > 1):
     canvas.draw_line(100,400,200,400)
   if (self.errors >= 2):
     canvas.draw_line(100,400,200,400)  
   if (self.errors >= 3):
     canvas.draw_line(150,400,150,150)
   if (self.errors >= 4):
     canvas.draw_line(150,150,300,150)
   if (self.errors >= 5):
     canvas.draw_line(225,150,150,230)
   if (self.errors >= 6):
     canvas.draw_line(300,150,300,180)
   if (self.errors >= 7):
     canvas.draw_circle(300,200,20)
   if (self.errors >= 8):
     canvas.draw_line(300,220,300,300)
   if (self.errors >= 9):
     canvas.draw_line(300,300,330,360)
   if (self.errors >= 10):
     canvas.draw_line(300,300,270,360)
   if (self.errors >= 11):
     canvas.draw_line(300,240,330,300)
   if (self.errors >= 12):
     canvas.draw_line(300,240,270,300)
Exemple #8
0
  def render(self):
    global a_missile, lives, score
    
          
    if lives == 0:
      canvas.draw_text("YOU LOOSE :(",(200,230),30,"Red")
      return
    
    self.time += 1
    wtime = (self.time / 4) % WIDTH
    
    canvas.clear()
    canvas.draw_image(self.fond.get_image(),self.fond.center,self.fond.size,(250,250),self.fond.size2,0)
    canvas.draw_image(self.debris.get_image(), self.debris.get_center(), self.debris.get_size(), (wtime - WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT),0)
    canvas.draw_image(self.debris.get_image(), self.debris.get_center(), self.debris.get_size(), (wtime + WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT),0)

    canvas.draw_image(self.ship.info.image,self.ship.info.center,self.ship.info.size,self.ship.pos,self.ship.info.size2,self.ship.angle)
    #canvas.draw_circle(self.ship.pos[0],self.ship.pos[1],self.ship.radius)
    canvas.draw_image(self.a_missile.info.image,self.a_missile.info.center,self.a_missile.info.size,self.a_missile.pos,self.a_missile.info.size2,self.a_missile.angle)  
   
    
    if self.a_rock.exploded:
      if (wtime) % 24 == 0:
        self.a_rock.exploded = False
        x = random.randrange(0,2)
        y = random.randrange(0,HEIGHT)
        x = x * WIDTH
        self.a_rock.set_pos(x,y)
        if x == 0:
          vx = 1
        else:
          vx = -1
        vy = 1
        self.a_rock.set_vit(vx,vy)
      #self.a_rock.exploded = False
      canvas.draw_image(self.a_rock_exploded.info.image,
                        (self.a_rock_exploded.info.center[0]
                         +((wtime) % 24)*self.a_rock_exploded.info.size[0],
                         self.a_rock_exploded.info.center[1]),
                        self.a_rock_exploded.info.size,
                        self.a_rock.pos,
                        self.a_rock_exploded.info.size,
                        0)  

    else:
      canvas.draw_image(self.a_rock.info.image,self.a_rock.info.center,self.a_rock.info.size,self.a_rock.pos,self.a_rock.info.size2,self.a_rock.angle)  
    canvas.draw_text("lives: "+str(lives)+" score: "+str(score),(320,30),24,'Orange')
    
    #canvas.draw_circle(self.a_rock.pos[0],self.a_rock.pos[1],self.a_rock.radius)
    
    c = self.get_kb()
    if c == '32':
      self.ship.shoot(self.a_missile)
    if c == '37':
      self.ship.dec_angle()
    if c == '39':
      self.ship.inc_angle()
    if c == '38' and (self.time % 10 == 0):
      self.ship.set_thrust(True)
    if c == None:
      self.ship.stop_angle()
      self.ship.set_thrust(False)
      
    self.ship.update()
    self.a_missile.update()
    self.a_rock.update()
    self.check_collision()
def draw():

    global bits, out
    canvas.fill_rect(0, 0, 500, 500)
    left = 80
    top = 30
    canvas.draw_line((0, 30 + top), (500, 30 + top), 4, "Blue")
    cl2 = "Yellow"

    canvas.draw_text("ENTREES", (left - 30, 25 + top), 24, cl2)
    canvas.draw_text("SORTIES", (left + 250, 25 + top), 24, cl2)
    canvas.draw_circle((left, 50 + top), 10, 2, "Blue", color(str(bits["A"])))
    canvas.draw_circle((left, 73 + top), 10, 2, "Blue", color(str(bits["B"])))
    canvas.draw_circle((left, 96 + top), 10, 2, "Blue", color(str(bits["C"])))

    canvas.draw_circle((left + 170, 50 + top), 10, 2, "Blue", color(out))

    canvas.draw_text("A: " + str(bits["A"]), (left + 15, 58 + top), 24, cl2)
    canvas.draw_text("B: " + str(bits["B"]), (left + 15, 80 + top), 24, cl2)
    canvas.draw_text("C: " + str(bits["C"]), (left + 15, 102 + top), 24, cl2)
    canvas.draw_text(inp.get_text(), (left + 185, 58 + top), 24, cl2)

    """
Exemple #10
0
e = p / 2

lettres = []
to_find = []

for c in mot:
  if not(c in to_find):
    to_find.append(c)

while (len(to_find)>0) and (errors<12):
  dessine(mot,p,e)
  lettre = input('Donne une lettre: ')
  ch = lettre[0].upper()
  if ch in ['A','B','C','D','E','F','G','H','I','J',
          'K','L','M','N','O','P','Q','R','S','T',
          'U','V','W','X','Y','Z','-']:
    if not(ch in lettres):
      lettres.append(ch)
    if ch in mot:
      to_find.remove(ch)
    else:
      errors += 1
      process()
    
    dessine(mot,p,e)
 
if (errors >= 12):
  canvas.draw_text( 200 , 250 , "YOU LOOSE :(")
else:
  canvas.draw_text( 200 , 250 , "YOU WIN :)")
errors = 0  
def draw(mycanvas):
    # ceci est la fonction qui gere l'ecran
    global bits
    left = 80
    top = 30
    canvas.draw_line((0, 30 + top), (500, 30 + top), 4, "Blue")
    cl2 = "Yellow"

    canvas.draw_text("ENTREES", (left - 30, 25 + top), 24, cl2)
    canvas.draw_text("SORTIES", (left + 250, 25 + top), 24, cl2)
    canvas.draw_circle((left, 50 + top), 10, 2, "Blue", color(str(bits["A"])))
    canvas.draw_circle((left, 73 + top), 10, 2, "Blue", color(str(bits["B"])))
    canvas.draw_circle((left, 96 + top), 10, 2, "Blue", color(str(bits["C"])))

    equ = process(inp.get_text())
    canvas.draw_circle((left + 250, 50 + top), 10, 2, "Blue", color(equ))

    canvas.draw_text("A: " + str(bits["A"]), (left + 15, 58 + top), 24, cl2)
    canvas.draw_text("B: " + str(bits["B"]), (left + 15, 80 + top), 24, cl2)
    canvas.draw_text("C: " + str(bits["C"]), (left + 15, 102 + top), 24, cl2)
    canvas.draw_text(inp.get_text(), (left + 265, 58 + top), 24, cl2)

    """