Exemplo n.º 1
0
 def update(self):
     if (self.current_point < self.point_count):
         self.current_point += 1
     else:
         # somewhere in here we check for collision with the flag
         Command.dispatch(
             Command(Category.Ball,
                     lambda ball: ball.set_at(self.points[-1])))
Exemplo n.º 2
0
 def handle_realtime_input(self, keys):
     if keys[K_LEFT]:
         Command.dispatch(
             Command(Category.Golfer,
                     lambda golfer: golfer.handle_keypress(Keys.Left)))
     if keys[K_RIGHT]:
         Command.dispatch(
             Command(Category.Golfer,
                     lambda golfer: golfer.handle_keypress(Keys.Right)))
Exemplo n.º 3
0
 def handle_input_event(self, event):
     if event.type == MOUSEBUTTONDOWN and event.button == 1:
         print("adding a command")
         Command.dispatch(
             Command(Category.SwingMeter,
                     lambda meter: meter.handle_click()))
     elif event.type == MOUSEBUTTONUP and event.button == 1:
         Command.dispatch(
             Command(Category.SwingMeter,
                     lambda meter: meter.handle_unclick()))