def draw(self):
if self.tracking:
ui.set_color('black')
ui.fill_rect(0, 0, self.width, self.height)
else:
base_color = tuple([self.color[i] for i in range(3)])
opacity_increment = 1.0/(len(self.current_move)+1) # 0.002
alpha_incremental = 1.0 - self.animate_counter*opacity_increment
if self.animate_counter > 0:
for i in range(1, self.animate_counter):
alpha_actual = max(0, alpha_incremental)
self.draw_segment(base_color + (alpha_actual,), self.current_move[i-1], self.current_move[i])
alpha_incremental += opacity_increment
if len(self.waypoints_hit_this_turn) > 0:
(hit_distance, waypoint_index) = self.waypoints_hit_this_turn[0]
if self.animate_counter >= hit_distance:
sound.play_effect('digital:PowerUp1')
self.waypoints[waypoint_index].background_color = '#6cd655'
self.waypoints_hit_this_turn = self.waypoints_hit_this_turn[1:]
if self.animation_state == 'sploding':
splode_alpha = 1.0-self.splosion_counter*0.15
splode_radius = self.splosion_counter * 4
splode_color = base_color + (splode_alpha,)
(x,y) = self.current_move[-1]
path = ui.Path.oval(x-splode_radius,y-splode_radius,2*splode_radius,2*splode_radius)
ui.set_color(splode_color)
path.fill()
# pos1 = self.current_move[self.animate_counter - 2]
# pos2 = self.current_move[self.animate_counter - 1]
# angle = (Vector(pos2) - Vector(pos1)).degrees
#print(self.animate_counter, angle)
评论列表
文章目录