def update_velocity(self):
HALF_WIDTH = const.WINDOW_WIDTH//2 - self.width//2
if (const.FROST_POTION_X+self.width/2) - self.dest_x == 0:
self.vel_x = 0
self.vel_y = self.SPEED
elif (const.FROST_POTION_Y+self.height/2) - self.dest_y == 0:
if self.dest_x <= const.BOMB_X:
''' note the equals '''
self.vel_x = -self.SPEED
self.vel_y = 0
elif self.dest_x > const.BOMB_X:
self.vel_x = self.SPEED
self.vel_y = 0
else:
dy = self.dest_y - (const.FROST_POTION_Y+self.height/2)
dx = self.dest_x - (const.FROST_POTION_X+self.width/2)
radians = math.atan2(dy, dx)# + math.pi/2
self.vel_y = math.sin(radians)*self.SPEED
self.vel_x = math.cos(radians)*self.SPEED
degrees = radians * 180.0 / math.pi
评论列表
文章目录