Python pygame.MOUSEBUTTONDOWN Examples
The following are 30
code examples of pygame.MOUSEBUTTONDOWN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: rigeditor.py From renpy-shader with MIT License | 8 votes |
def handleEvents(self): self.mouse = self.get(MOUSE) for event, pos in self.context.events: self.mouse = pos handled = self.mode.handleEvent((event, pos)) if not handled: if event.type == pygame.MOUSEBUTTONDOWN: self.handleMouseDown(event, pos) elif event.type == pygame.MOUSEMOTION: self.handleMouseMotion(pos) elif event.type == pygame.MOUSEBUTTONUP: self.handleMouseUp(pos) if self.mouse: self.set(MOUSE, self.mouse)
Example #2
Source File: guide.py From My-PyChess with MIT License | 7 votes |
def prompt(win): pygame.draw.rect(win, (0, 0, 0), (110, 160, 280, 130)) pygame.draw.rect(win, (255, 255, 255), (110, 160, 280, 130), 4) win.blit(SF.PROMPT[0], (130, 170)) win.blit(SF.PROMPT[1], (130, 205)) win.blit(SF.YES, (145, 240)) win.blit(SF.NO, (305, 240)) pygame.draw.rect(win, (255, 255, 255), (140, 240, 60, 28), 2) pygame.draw.rect(win, (255, 255, 255), (300, 240, 45, 28), 2) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if 240 < event.pos[1] < 270: if 140 < event.pos[0] < 200: return True elif 300 < event.pos[0] < 345: return False # This shows the installation guide screen
Example #3
Source File: Game17.py From Games with MIT License | 7 votes |
def startInterface(screen): clock = pygame.time.Clock() while True: screen.fill((41, 36, 33)) button_1 = Button(screen, (150, 175), '1 Player') button_2 = Button(screen, (150, 275), '2 Player') for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if button_1.collidepoint(pygame.mouse.get_pos()): return 1 elif button_2.collidepoint(pygame.mouse.get_pos()): return 2 clock.tick(10) pygame.display.update()
Example #4
Source File: game079.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: # and self.start_sequence==False: if 0 <= self.board.active_ship < 22: active = self.board.ships[self.board.active_ship] self.onClick(active) else: pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin] if self.lt.rect.topleft[0] < pos[0] < self.lt.rect.topleft[0] + self.lt.rect.width and \ self.lt.rect.topleft[1] < pos[1] < self.lt.rect.topleft[ 1] + self.lt.rect.height: self.next_slide(-1) elif self.rt.rect.topleft[0] < pos[0] < self.rt.rect.topleft[0] + self.rt.rect.width and \ self.rt.rect.topleft[1] < pos[1] < self.rt.rect.topleft[ 1] + self.rt.rect.height: self.next_slide(1)
Example #5
Source File: game006.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and not self.show_msg and not self.start_sequence: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if active.unit_id in self.chosen: active.initcolor = self.highlight_color active.color = active.initcolor self.found.add(active.unit_id) if len(self.found) == self.current_count: self.completed_mode = True self.ai_enabled = True else: active.initcolor = (255, 0, 0) active.color = active.initcolor self.game_over_mode = True # self.game_over() self.ai_enabled = True
Example #6
Source File: __init__.py From My-PyChess with MIT License | 6 votes |
def main(win): pth = os.path.join("res", "stockfish", "path.txt") configured = os.path.exists(pth) clock = pygame.time.Clock() while True: clock.tick(24) showScreen(win, configured) for event in pygame.event.get(): if event.type == pygame.QUIT: return False elif event.type == pygame.MOUSEBUTTONDOWN: x, y = event.pos if 120 < x < 370 and 320 < y < 350: if configured: os.remove(pth) if guideMain(win): return True else: configured = os.path.exists(pth) pygame.display.update()
Example #7
Source File: game115.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: active = self.board.active_ship if active == 0: self.change_fract_btn(self.numbers, -1, 0) elif active == 1: self.change_fract_btn(self.numbers, 1, 0) elif active == 2: self.change_fract_btn(self.numbers, 0, -1) elif active == 3: self.change_fract_btn(self.numbers, 0, 1) elif active == 4: self.change_fract_btn(self.numbers2, -1, 0) elif active == 5: self.change_fract_btn(self.numbers2, 1, 0) elif active == 6: self.change_fract_btn(self.numbers2, 0, -1) elif active == 7: self.change_fract_btn(self.numbers2, 0, 1) self.auto_check_reset() elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER): self.check_result() elif event.type == pygame.KEYDOWN: self.auto_check_reset()
Example #8
Source File: pref.py From My-PyChess with MIT License | 6 votes |
def prompt(win): rounded_rect(win, (255, 255, 255), (110, 160, 280, 130), 4, 4) win.blit(PREF.PROMPT[0], (130, 165)) win.blit(PREF.PROMPT[1], (130, 190)) win.blit(PREF.YES, (145, 240)) win.blit(PREF.NO, (305, 240)) pygame.draw.rect(win, (255, 255, 255), (140, 240, 60, 28), 2) pygame.draw.rect(win, (255, 255, 255), (300, 240, 45, 28), 2) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if 240 < event.pos[1] < 270: if 140 < event.pos[0] < 200: return True elif 300 < event.pos[0] < 350: return False # This function shows the screen
Example #9
Source File: pref.py From My-PyChess with MIT License | 6 votes |
def main(win): prefs = load() clock = pygame.time.Clock() while True: clock.tick(24) showScreen(win, prefs) for event in pygame.event.get(): if event.type == pygame.QUIT and prompt(win): return elif event.type == pygame.MOUSEBUTTONDOWN: if 200 < event.pos[0] < 285 and 450 < event.pos[1] < 490: save(*prefs) return for cnt in range(5): if 100 + cnt*60 < event.pos[1] < 140 + cnt*60: if 250 < event.pos[0] < 330: prefs[cnt] = True if 360 < event.pos[0] < 430: prefs[cnt] = False pygame.display.update()
Example #10
Source File: loadGame.py From My-PyChess with MIT License | 6 votes |
def prompt(win): rounded_rect(win, (255, 255, 255), (110, 160, 280, 130), 10, 4) win.blit(LOADGAME.MESSAGE[0], (116, 160)) win.blit(LOADGAME.MESSAGE[1], (118, 190)) win.blit(LOADGAME.YES, (145, 240)) win.blit(LOADGAME.NO, (305, 240)) pygame.draw.rect(win, (255, 255, 255), (140, 240, 60, 28), 2) pygame.draw.rect(win, (255, 255, 255), (300, 240, 46, 28), 2) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if 240 < event.pos[1] < 270: if 140 < event.pos[0] < 200: return True elif 300 < event.pos[0] < 350: return False # This function shows the screen
Example #11
Source File: utils.py From Games with MIT License | 6 votes |
def endInterface(screen, color, is_win): screen.fill(color) clock = pygame.time.Clock() if is_win: text = 'VICTORY' else: text = 'FAILURE' font = pygame.font.SysFont('arial', 30) text_render = font.render(text, 1, (255, 255, 255)) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if (event.type == pygame.KEYDOWN) or (event.type == pygame.MOUSEBUTTONDOWN): return screen.blit(text_render, (350, 300)) clock.tick(60) pygame.display.update()
Example #12
Source File: Game12.py From Games with MIT License | 6 votes |
def switchInterface(screen): screen.fill(Config.get('bg_color')) clock = pygame.time.Clock() while True: button_1 = BUTTON(screen, (95, 150), '进入下关') button_2 = BUTTON(screen, (95, 305), '退出游戏') for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if button_1.collidepoint(pygame.mouse.get_pos()): return elif button_2.collidepoint(pygame.mouse.get_pos()): quitGame() clock.tick(60) pygame.display.update()
Example #13
Source File: Game10.py From Games with MIT License | 6 votes |
def end_interface(screen): clock = pygame.time.Clock() while True: button_1 = BUTTON(screen, (330, 190), '重新开始') button_2 = BUTTON(screen, (330, 305), '退出游戏') for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if button_1.collidepoint(pygame.mouse.get_pos()): return elif button_2.collidepoint(pygame.mouse.get_pos()): pygame.quit() sys.exit() clock.tick(60) pygame.display.update()
Example #14
Source File: Game10.py From Games with MIT License | 6 votes |
def start_interface(screen): clock = pygame.time.Clock() while True: button_1 = BUTTON(screen, (330, 190), '单人模式') button_2 = BUTTON(screen, (330, 305), '双人模式') for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if button_1.collidepoint(pygame.mouse.get_pos()): return 1 elif button_2.collidepoint(pygame.mouse.get_pos()): return 2 clock.tick(60) pygame.display.update()
Example #15
Source File: gui.py From My-PyChess with MIT License | 6 votes |
def getChoice(win, side): win.blit(CHESS.CHOOSE, (130, 10)) win.blit(CHESS.PIECES[side]["q"], (250, 0)) win.blit(CHESS.PIECES[side]["b"], (300, 0)) win.blit(CHESS.PIECES[side]["r"], (350, 0)) win.blit(CHESS.PIECES[side]["n"], (400, 0)) pygame.display.update((0, 0, 500, 50)) while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if 0 < event.pos[1] < 50: if 250 < event.pos[0] < 300: return "q" elif 300 < event.pos[0] < 350: return "b" elif 350 < event.pos[0] < 400: return "r" elif 400 < event.pos[0] < 450: return "n" # This function draws the board
Example #16
Source File: viewer.py From generals-bot with MIT License | 6 votes |
def mainViewerLoop(self): while not self._receivedUpdate: # Wait for first update time.sleep(0.5) self._initViewier() while self._runPygame: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # User clicked quit self._runPygame = False # Flag done elif event.type == pygame.MOUSEBUTTONDOWN: # Mouse Click self._handleClick(pygame.mouse.get_pos()) elif event.type == pygame.KEYDOWN: # Key Press Down self._handleKeypress(event.key) if self._receivedUpdate: self._drawViewer() self._receivedUpdate = False time.sleep(0.2) pygame.quit() # Done. Quit pygame.
Example #17
Source File: game007.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and not self.show_msg and not self.start_sequence: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if active.unit_id in self.chosen: active.initcolor = self.highlight_color active.color = self.highlight_color len1 = len(self.found) self.found.add(active.unit_id) len2 = len(self.found) if len2 > len1: self.level.game_step += 1 self.mainloop.redraw_needed[1] = True if len(self.found) == self.current_count: self.completed_mode = True self.ai_enabled = True else: active.initcolor = (255, 0, 0) active.color = (255, 0, 0) self.game_over_mode = True self.ai_enabled = True
Example #18
Source File: game036.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #19
Source File: game020.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONUP: for each in self.board.units: if each.is_door is True: self.board.all_sprites_list.move_to_front(each) self.check_result() if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() elif event.type == pygame.KEYUP: self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #20
Source File: game037.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN: self.active_item = self.board.ships[self.board.active_ship] if self.active_item.unit_id < 26: if self.prev_item is not None: self.prev_item.color = self.letter_color2 self.prev_item.update_me = True self.active_item.color = (255, 255, 255) self.create_card(self.active_item) self.prev_item = self.active_item self.mainloop.redraw_needed[0] = True
Example #21
Source File: game072.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if not self.show_msg: if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT: self.home_sqare_switch(self.board.active_ship + 1) elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT: self.home_sqare_switch(self.board.active_ship - 1) elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP: self.home_sqare_switch(self.board.active_ship - self.sumn1n2sl + 1) elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: self.home_sqare_switch(self.board.active_ship + self.sumn1n2sl) elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and not self.correct: lhv = len(self.home_square.value) self.changed_since_check = True if event.key == pygame.K_BACKSPACE: if lhv > 0: self.home_square.value = self.home_square.value[0:lhv - 1] else: char = event.unicode if len(char) > 0 and lhv < 2 and char in self.digits: self.home_square.value = char if self.auto_select: self.home_sqare_switch(self.board.active_ship + 1) else: self.home_square.value = "" self.home_square.update_me = True self.mainloop.redraw_needed[0] = True elif event.type == pygame.MOUSEBUTTONUP: self.home_sqare_switch(self.board.active_ship)
Example #22
Source File: game100.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN: pos = event.pos column = (pos[0] - self.px_padding) // (self.layout.width) row = (pos[1] - self.layout.top_margin) // (self.layout.height) if event.button == 1 and column >= 0 and 0 <= row < self.data[1]: if self.points_count == 0: pass # self.new_screen() elif event.type == pygame.MOUSEBUTTONUP: pos = event.pos active = self.board.active_ship if pos[0] > self.layout.game_margin and pos[1] > self.layout.top_margin: if -1 < active < 8 and active != self.canvas_block.unit_id: if active % 2 != 0: a = 1 else: a = -1 if self.selected[active // 2] == 0: self.selectors[active].change_image(self.selectors[active].img_src_org[0:12] + "a" + self.selectors[active].img_src_org[12:]) self.selected[active // 2] = 1 self.selectors[active - a].change_image(self.selectors[active - a].img_src_org[0:12] + "a" + self.selectors[active - a].img_src_org[12:]) else: self.selectors[active].change_image(self.selectors[active].img_src_org) self.selectors[active - a].change_image(self.selectors[active - a].img_src_org) self.selected[active // 2] = 0 self.draw_multi_axis() self.mainloop.redraw_needed[0] = True if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset()
Example #23
Source File: game110.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: active = self.board.active_ship if self.missing_number == 1: if active == 0: self.change_fract_btn(-1, 0) elif active == 1: self.change_fract_btn(1, 0) else: if active == 0: self.change_fract_btn(0, -1) elif active == 1: self.change_fract_btn(0, 1) self.auto_check_reset() elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER): self.check_result() elif event.type == pygame.KEYDOWN: lhv = len(self.active_num.value) self.changed_since_check = True if event.key == pygame.K_BACKSPACE: if lhv > 0: self.active_num.value = self.active_num.value[0:lhv - 1] else: char = event.unicode if self.typed and len(char) > 0 and lhv < 3 and char in self.digits: self.active_num.value += char elif char in self.digits: self.active_num.value = char self.typed = True if len(self.active_num.value) > 0: self.result[self.missing_number - 1] = int(self.active_num.value) else: self.result[self.missing_number - 1] = 0 self.active_num.update_me = True self.mainloop.redraw_needed[0] = True self.auto_check_reset()
Example #24
Source File: game090.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and not self.ai_enabled: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: active.perm_outline_width = 6 active.perm_outline_color = [150, 150, 255] self.history[0] = active self.clicks += 1 active.uncovered = True elif self.history[1] is None: active.perm_outline_width = 6 active.perm_outline_color = [150, 150, 255] self.history[1] = active self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.history[0].uncovered = True self.history[1].uncovered = True self.history[0].perm_outline_color = self.color2 # [50,255,50] self.history[1].perm_outline_color = self.color2 self.history[0].image.set_alpha(50) self.history[1].image.set_alpha(50) self.history[0].update_me = True self.history[1].update_me = True self.history[0].set_display_check(True) self.history[1].set_display_check(True) self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True self.history = [None, None] active.update_me = True
Example #25
Source File: game041.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: self.draw_lines() self.mainloop.redraw_needed[0] = True self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #26
Source File: game068.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: active = self.board.active_ship if active == 0: self.change_fract_btn(-1) elif active == 1: self.change_fract_btn(1) self.auto_check_reset() elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER): self.check_result() elif event.type == pygame.KEYDOWN: self.auto_check_reset() lhv = len(self.nm1.value) self.changed_since_check = True if event.key == pygame.K_BACKSPACE: if lhv > 2: self.nm1.value = self.nm1.value[0:lhv - 1] else: char = event.unicode if len(char) > 0 and char in self.digits: self.numbers_disp[0] = int(char) self.nm1.set_value("0.%s" % char) self.check_result() self.nm1.update_me = True self.mainloop.redraw_needed[0] = True
Example #27
Source File: game026.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONUP: for each in self.board.units: if each.is_door is True: self.board.all_sprites_list.move_to_front(each) self.check_result() if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() elif event.type == pygame.KEYUP: self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #28
Source File: game060.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and self.ai_enabled is False: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: self.history[0] = active self.semi_select(active) self.clicks += 1 active.uncovered = True elif self.history[1] is None: self.history[1] = active self.semi_select(active) self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.select() self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True active.update_me = True if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.custom_hover(event)
Example #29
Source File: game103.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and self.ai_enabled is False: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: active.perm_outline_width = 6 active.perm_outline_color = [150, 150, 255] self.history[0] = active self.clicks += 1 active.uncovered = True elif self.history[1] is None: active.perm_outline_width = 6 active.perm_outline_color = [150, 150, 255] self.history[1] = active self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.history[0].uncovered = True self.history[1].uncovered = True self.history[0].perm_outline_color = self.bd_color_2 # [50,255,50] self.history[1].perm_outline_color = self.bd_color_2 self.history[0].image.set_alpha(50) self.history[1].image.set_alpha(50) self.history[0].update_me = True self.history[1].update_me = True self.history[0].set_display_check(True) self.history[1].set_display_check(True) self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True self.history = [None, None] active.update_me = True
Example #30
Source File: game078.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and self.ai_enabled is False: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: self.history[0] = active self.semi_select(active) self.clicks += 1 active.uncovered = True elif self.history[1] is None: self.history[1] = active self.semi_select(active) self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.select() self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True active.update_me = True if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.custom_hover(event)