def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if self.ship_id < 0 and event.type == pygame.MOUSEBUTTONDOWN:
# make it impossible to deselect the main character
self.board.active_ship = 0
self.ship_id = 0
if self.moveable == True:
pos = event.pos
column = (pos[0] - self.layout.menu_w) // (self.layout.width)
row = (pos[1] - self.layout.top_margin) // (self.layout.height)
self.direction = [0, 0]
arrow_clicked = False
if column == self.owl_pos[0] - 1 and row == self.owl_pos[1]:
self.direction[0] = -1
arrow_clicked = True
elif column == self.owl_pos[0] + 1 and row == self.owl_pos[1]:
self.direction[0] = 1
arrow_clicked = True
elif column == self.owl_pos[0] and row == self.owl_pos[1] - 1:
self.direction[1] = -1
arrow_clicked = True
elif column == self.owl_pos[0] and row == self.owl_pos[1] + 1:
self.direction[1] = 1
arrow_clicked = True
if arrow_clicked:
self.check_direction_kdown()
if (event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN) and self.moveable == False:
self.move = False
elif event.type == pygame.KEYUP or event.type == pygame.MOUSEBUTTONUP:
self.highlight_color(-1)
self.mainloop.redraw_needed[0] = True
self.move = False
评论列表
文章目录