Exemple #1
0
 def update_child(self, matrix):
     next_step = mul_tuple(self.direction, self.speed)
     next_screen_position = next_point(self.screen_position, next_step)
     x, y = s2c(next_screen_position)
     if x >= X_CELL_NUM or x < 0 or y >= Y_CELL_NUM or y < 0 or not matrix[y][x]:
         # self.direction = STOP
         self.direction = TRIGONOMETRY_SUCKS[self.direction]["contr"]
Exemple #2
0
 def event(self, event):
     # self.direction = STOP
     # create STOP event to make it work
     if event.type == KEYDOWN:
         self.control_mode = "arrows"
         self.__update_direction(event.key)
         if event.key == 280:  # PgUp
             self.speed += 1
         elif event.key == 281:  # PgDown
             self.speed -= 1
     if event.type == MOUSEBUTTONDOWN:
         self.control_mode = "mouse"
         self.goal = s2c(mouse.get_pos())
         self.screen_goal = mouse.get_pos()
         self.is_new_goal = True
         print "mouse %s %s" % (self.position, self.goal)