예제 #1
0
 def complete(self):
     if g.state in (3, 4):
         return True
     if len(g.buffr) == 0 and len(g.top) == 1:
         if g.aim in g.top:
             g.state = 4  # right
             if not self.scored:
                 self.scored = True
                 g.score += g.level
                 if g.score > g.best:
                     g.best = g.score
         else:
             g.state = 3  # wrong
         if self.mouse_auto:
             buttons.set_mouse('back')
         return True
     return False
예제 #2
0
 def complete(self):
     if g.state in (3, 4):
         return True
     if len(g.buffr) == 0 and len(g.top) == 1:
         if g.aim in g.top:
             g.state = 4  # right
             if not self.scored:
                 self.scored = True
                 g.score += g.level
                 if g.score > g.best:
                     g.best = g.score
         else:
             g.state = 3  # wrong
         if self.mouse_auto:
             buttons.set_mouse('back')
         return True
     return False
예제 #3
0
 def mouse_set(self):
     if not self.mouse_auto:
         return
     if g.state == 1:  # top line
         x1, y1 = g.xy1
         dx, dy = g.offset1
         for i in range(self.mouse_ind):
             x = self.display_n(g.top[i], (x1, y1), False)
             x1 = x + g.sp1
         x1 += dx
         y1 += dy
         pygame.mouse.set_pos(x1, y1)
         g.pos = (x1, y1)
         return
     elif g.state == 2:  # ops line
         if self.mouse_auto:
             buttons.set_mouse(self.ops[self.mouse_ind])
예제 #4
0
 def mouse_set(self):
     if not self.mouse_auto:
         return
     if g.state == 1:  # top line
         x1, y1 = g.xy1
         dx, dy = g.offset1
         for i in range(self.mouse_ind):
             x = self.display_n(g.top[i], (x1, y1), False)
             x1 = x + g.sp1
         x1 += dx
         y1 += dy
         pygame.mouse.set_pos(x1, y1)
         g.pos = (x1, y1)
         return
     elif g.state == 2:  # ops line
         if self.mouse_auto:
             buttons.set_mouse(self.ops[self.mouse_ind])
예제 #5
0
 def do_key(self, key):
     if key in g.CROSS:
         bu = buttons.check()
         if bu != '':
             self.do_button(bu)
             return
         if g.state == 1:
             self.check_numbers()
         return
     if key in g.UP:
         if self.back_button.mouse_on():
             if g.state == 1:
                 self.mouse_init()
         elif buttons.active('back'):
             buttons.set_mouse('back')
             if g.state == 2:
                 self.mouse_ind = 0
         return
     if key in g.DOWN:
         if buttons.active('back'):
             if g.state in (1, 3):
                 buttons.set_mouse('back')
         return
     if key in g.RIGHT:
         if not self.complete():
             self.mouse_right()
         return
     if key in g.LEFT:
         if not self.complete():
             self.mouse_left()
         return
     if key == pygame.K_m:
         self.mouse_auto = not self.mouse_auto
         self.mouse_init()
         return
     if key in g.SQUARE or key in g.CIRCLE:
         self.do_button('new')
         return
     if key in g.TICK:
         self.inc_level()
         return
     if key == pygame.K_v:
         g.version_display = not g.version_display
         return
예제 #6
0
 def do_key(self, key):
     if key in g.CROSS:
         bu = buttons.check()
         if bu != '':
             self.do_button(bu)
             return
         if g.state == 1:
             self.check_numbers()
         return
     if key in g.UP:
         if self.back_button.mouse_on():
             if g.state == 1:
                 self.mouse_init()
         elif buttons.active('back'):
             buttons.set_mouse('back')
             if g.state == 2:
                 self.mouse_ind = 0
         return
     if key in g.DOWN:
         if buttons.active('back'):
             if g.state in (1, 3):
                 buttons.set_mouse('back')
         return
     if key in g.RIGHT:
         if not self.complete():
             self.mouse_right()
         return
     if key in g.LEFT:
         if not self.complete():
             self.mouse_left()
         return
     if key == pygame.K_m:
         self.mouse_auto = not self.mouse_auto
         self.mouse_init()
         return
     if key in g.SQUARE or key in g.CIRCLE:
         self.do_button('new')
         return
     if key in g.TICK:
         self.inc_level()
         return
     if key == pygame.K_v:
         g.version_display = not g.version_display
         return
예제 #7
0
 def mouse_left(self):
     bu = ''
     cx = g.n_cx0
     cy = g.n_cy0
     c = None
     if not self.sugar:
         if utils.mouse_on_img1(g.magician, g.magician_c):
             c = (cx + 4 * g.n_dx, cy)
         elif buttons.mouse_on('cyan'):
             self.mouse_magician()
             return
         elif buttons.mouse_on('green'):
             if buttons.active('cyan'):
                 bu = 'cyan'
             else:
                 self.mouse_magician()
                 return
         elif buttons.mouse_on('red'):
             bu = 'green'
         elif buttons.mouse_on('black'):
             bu = 'red'
         if bu != '':
             buttons.set_mouse(bu)
             return
     if c is None:
         c = (cx, cy)  # default to 1st no.
         for i in range(5):
             n = g.numbers[i]
             if utils.mouse_on_img_rect(g.n[n - 1], (cx, cy)):
                 c = (cx - g.n_dx, cy)
                 break
             cx += g.n_dx
     cx, cy = c
     cx += g.sy(.2)
     cy += g.sy(1.2)
     c = cx, cy
     pygame.mouse.set_pos(c)
     g.pos = c
     return
예제 #8
0
 def mouse_left(self):
     bu = ''
     cx = g.n_cx0
     cy = g.n_cy0
     c = None
     if not self.sugar:
         if utils.mouse_on_img1(g.magician, g.magician_c):
             c = (cx + 4 * g.n_dx, cy)
         elif buttons.mouse_on('cyan'):
             self.mouse_magician()
             return
         elif buttons.mouse_on('green'):
             if buttons.active('cyan'):
                 bu = 'cyan'
             else:
                 self.mouse_magician()
                 return
         elif buttons.mouse_on('red'):
             bu = 'green'
         elif buttons.mouse_on('black'):
             bu = 'red'
         if bu != '':
             buttons.set_mouse(bu)
             return
     if c is None:
         c = (cx, cy)  # default to 1st no.
         for i in range(5):
             n = g.numbers[i]
             if utils.mouse_on_img_rect(g.n[n - 1], (cx, cy)):
                 c = (cx - g.n_dx, cy)
                 break
             cx += g.n_dx
     cx, cy = c
     cx += g.sy(.2)
     cy += g.sy(1.2)
     c = cx, cy
     pygame.mouse.set_pos(c)
     g.pos = c
     return
예제 #9
0
 def mouse_right(self):
     bu = ''
     if not self.sugar:
         if utils.mouse_on_img1(g.magician, g.magician_c):
             bu = 'green'
             if buttons.active('cyan'):
                 bu = 'cyan'
         elif buttons.mouse_on('cyan'):
             bu = 'green'
         elif buttons.mouse_on('green'):
             bu = 'red'
         elif buttons.mouse_on('red'):
             bu = 'black'
         if bu != '':
             buttons.set_mouse(bu)
             return
     cx = g.n_cx0
     cy = g.n_cy0
     c = (cx, cy)  # default to 1st no.
     if not buttons.mouse_on('black'):
         for i in range(5):
             n = g.numbers[i]
             if utils.mouse_on_img_rect(g.n[n - 1], (cx, cy)):
                 if i == 4:
                     self.mouse_magician()
                     return
                 c = (cx + g.n_dx, cy)
                 break
             cx += g.n_dx
     cx, cy = c
     cx += g.sy(.2)
     cy += g.sy(1.2)
     c = cx, cy
     pygame.mouse.set_pos(c)
     g.pos = c
     return
예제 #10
0
 def mouse_right(self):
     bu = ''
     if not self.sugar:
         if utils.mouse_on_img1(g.magician, g.magician_c):
             bu = 'green'
             if buttons.active('cyan'):
                 bu = 'cyan'
         elif buttons.mouse_on('cyan'):
             bu = 'green'
         elif buttons.mouse_on('green'):
             bu = 'red'
         elif buttons.mouse_on('red'):
             bu = 'black'
         if bu != '':
             buttons.set_mouse(bu)
             return
     cx = g.n_cx0
     cy = g.n_cy0
     c = (cx, cy)  # default to 1st no.
     if not buttons.mouse_on('black'):
         for i in range(5):
             n = g.numbers[i]
             if utils.mouse_on_img_rect(g.n[n - 1], (cx, cy)):
                 if i == 4:
                     self.mouse_magician()
                     return
                 c = (cx + g.n_dx, cy)
                 break
             cx += g.n_dx
     cx, cy = c
     cx += g.sy(.2)
     cy += g.sy(1.2)
     c = cx, cy
     pygame.mouse.set_pos(c)
     g.pos = c
     return