def update_player(self): # Aキーで左に移動 画面外には行けない if pyxel.btn(pyxel.KEY_A): self.x = max(self.x - 2, 0) self.face_right = False # 左を向かせる # Dキーで右に移動 画面外には行けない if pyxel.btn(pyxel.KEY_D): self.x = min(self.x + 2, pyxel.width - 16) self.face_right = True # 右を向かせる # 重力加速度を速度に加算(終端速度6) self.vy = min(self.vy + GRAVITY, 6) # クリックでジャンプ if pyxel.btn(pyxel.MOUSE_LEFT_BUTTON): # 接地時 if self.onfloor and self.can_jump: h = max(self.y - pyxel.mouse_y, 8) + 4 self.vy = - (2 * GRAVITY * h) ** 0.5 self.onfloor = False self.can_jump = False play_sound(0) play_sound(1) # 落下時 else: self.vy = min(self.vy, 1) # ボタンを話したらジャンプ可能になる。ボタンを押しっぱなしでジャンプが誤爆する対策 elif pyxel.btnr(pyxel.MOUSE_LEFT_BUTTON) or pyxel.btnr(pyxel.KEY_F): self.can_jump = True # y方向の移動を反映 self.y += self.vy
def update(self): if pyxel.btnp(pyxel.KEY_Q): pyxel.quit() diffs = { Direction.North: Point(0, -1), Direction.West: Point(-1, 0), Direction.South: Point(0, 1), Direction.East: Point(1, 0) } directions = { Direction.North: { pyxel.KEY_A: Direction.West, pyxel.KEY_D: Direction.East }, Direction.West: { pyxel.KEY_A: Direction.South, pyxel.KEY_D: Direction.North }, Direction.South: { pyxel.KEY_A: Direction.East, pyxel.KEY_D: Direction.West }, Direction.East: { pyxel.KEY_A: Direction.North, pyxel.KEY_D: Direction.South } } new_pos = Point(-1, -1) # north if pyxel.btnr(pyxel.KEY_W): diff = diffs[self.char_direction] new_pos = Point(self.char_pos.x + diff.x, self.char_pos.y + diff.y) if new_pos.x < 0 or new_pos.y < 0 or new_pos.x > 15 or new_pos.y > 15 \ or self.dungeon[new_pos.y, new_pos.x] > 0: pyxel.play(0, 1) else: self.char_pos = new_pos self.window = self.update_window() print(self.window) print(self.draw_seq()) # south if pyxel.btnr(pyxel.KEY_S): diff = diffs[self.char_direction] new_pos = Point(self.char_pos.x - diff.x, self.char_pos.y - diff.y) if new_pos.x < 0 or new_pos.y < 0 or new_pos.x > 15 or new_pos.y > 15 \ or self.dungeon[new_pos.y, new_pos.x] > 0: pyxel.play(0, 1) else: self.char_pos = new_pos self.window = self.update_window() print(self.window) if pyxel.btnr(pyxel.KEY_A): self.char_direction = directions[self.char_direction][pyxel.KEY_A] self.window = self.update_window() if pyxel.btnr(pyxel.KEY_D): self.char_direction = directions[self.char_direction][pyxel.KEY_D] self.window = self.update_window()
def tally(self): if pyxel.btnr(pyxel.KEY_SPACE): self.count += 1 self.cd_active = True elif pyxel.btnr(pyxel.KEY_R): self.count = 0
def select_npc(): # IF NPC INSIDE BOX - BECOMES SELECTED if pyxel.btnr(pyxel.MOUSE_LEFT_BUTTON): for npc in npc_list: if pyxel.btnr(pyxel.MOUSE_LEFT_BUTTON) and npc.npc_selected: npc.npc_selected = False if npc.npc_x in range(H.line_x1, H.line_x2) and npc.npc_y in range( H.line_y1, H.line_y2): npc.npc_selected = True elif npc.npc_x in range(H.line_x2, H.line_x1) and npc.npc_y in range( H.line_y1, H.line_y2): npc.npc_selected = True elif npc.npc_x in range(H.line_x1, H.line_x2) and npc.npc_y in range( H.line_y2, H.line_y1): npc.npc_selected = True elif npc.npc_x in range(H.line_x2, H.line_x1) and npc.npc_y in range( H.line_y2, H.line_y1): npc.npc_selected = True
def choose_state(cls): if SplashScreen.splash_active: if pyxel.btnr(pyxel.KEY_DOWN) and SplashScreen.arrow_y < 120: SplashScreen.arrow_y += 20 elif pyxel.btnr(pyxel.KEY_DOWN) and SplashScreen.arrow_y > 120: SplashScreen.arrow_y = 80 if pyxel.btnr(pyxel.KEY_UP) and SplashScreen.arrow_y > 80: SplashScreen.arrow_y -= 20 elif pyxel.btnr(pyxel.KEY_UP) and SplashScreen.arrow_y < 80: SplashScreen.arrow_y = 80 if SplashScreen.arrow_y == 80 and pyxel.btnr( pyxel.KEY_ENTER) or pyxel.btnr(pyxel.KEY_KP_ENTER): SplashScreen.splash_active = False new_game.NewGame.new_game_started = True elif SplashScreen.arrow_y == 100 and pyxel.btnr( pyxel.KEY_ENTER) or pyxel.btnr(pyxel.KEY_KP_ENTER): SplashScreen.splash_active = False main_gui.MainUI.main_ui_active = True elif SplashScreen.arrow_y == 120 and pyxel.btnr( pyxel.KEY_ENTER) or pyxel.btnr(pyxel.KEY_KP_ENTER): pyxel.quit()
def update(self): if pyxel.btn(pyxel.KEY_LEFT): self.direction = Direction.LEFT self.acc_x = -common.PLYAER_STEP if pyxel.btn(pyxel.KEY_RIGHT): self.direction = Direction.RIGHT self.acc_x = common.PLYAER_STEP if pyxel.btnp(pyxel.KEY_Z) or pyxel.btnp(pyxel.KEY_SPACE): if self.jump_count < 2: # ダブルジャンプまでは許容する self.acc_y = common.JUMP self.jump_count += 1 if pyxel.btnp(pyxel.KEY_X): # 攻撃 self.attack = True if pyxel.btnr(pyxel.KEY_LEFT) or pyxel.btnr(pyxel.KEY_RIGHT): self.acc_x = 0 # X軸方向の移動 self.move_x() # Y軸方向の移動 self.move_y() # 描画の準備 self.prepare_draw()
def update_menu(state: State): menu_ = menu(state) if pyxel.btnr(pyxel.KEY_UP): state.menu_index = max(state.menu_index - 1, 0) pyxel.play(3, 55) elif pyxel.btnr(pyxel.KEY_DOWN): state.menu_index = min(state.menu_index + 1, len(menu_) - 1) pyxel.play(3, 55)
def display_rect(self): global is_rect if is_rect == 1 and pyxel.btnr(pyxel.KEY_SPACE): is_rect = 0 elif is_rect == 0 and pyxel.btnr(pyxel.KEY_SPACE): pyxel.play(2,9, loop=False) is_rect = 1 if is_rect == 1: pyxel.rect(1,1,254,48,0) self.display(self.font, 4, 0, "Samsara\nくりかえす せかい\nやあ おでかけですか?")
def auto_status(cls): if not main_gui.MainUI.main_ui_active: return if pyxel.btnr(pyxel.KEY_S): Turns.auto_play = True Turns.auto_turns() if pyxel.btnr(pyxel.KEY_P): Turns.auto_play = False
def get_input_list(self): self.input_list = [ key for key in range(pyxel.KEY_A, pyxel.KEY_Z + 1) if pyxel.btnr(key) ] self.input_list += [ key for key in (pyxel.KEY_UP, pyxel.KEY_DOWN, pyxel.KEY_LEFT, pyxel.KEY_RIGHT, pyxel.KEY_SPACE) if pyxel.btnr(key) ] return self.input_list
def update(self): if pyxel.btnr(pyxel.KEY_MINUS): self.input("-") for k in range(pyxel.KEY_A, pyxel.KEY_Z + 1): if pyxel.btnr(k): self.input(chr(k - 18 + 97)) # _A=18 a=97 if pyxel.btnr(pyxel.KEY_BACKSPACE): self.bs() if pyxel.btnr(pyxel.KEY_DELETE): self.clear() if pyxel.btnr(pyxel.KEY_SPACE): self.clear()
def check_debug_input(self): if not DEBUG: return key = 0 if pyxel.btnr(pyxel.KEY_0): self.scene = Scene.GAME self.game.goto_level(12) if pyxel.btnr(pyxel.KEY_1): key = 1 if pyxel.btnr(pyxel.KEY_2): key = 2 if pyxel.btnr(pyxel.KEY_3): key = 3 if pyxel.btnr(pyxel.KEY_4): key = 4 if key: self.scene = Scene.GAME self.game.goto_level(LEVELS_PER_BATCH * (key - 1) + 1)
def update_anim(self): frame_x = self.anim_w * 7 if not self.grounded: if not self.on_wall: if self.vy >= 0: frame_x = self.anim_w * 13 else: frame_x = self.anim_w * 12 else: if self.vy > 0: # climb up animation pass elif self.vy < 0: # climb down animation pass else: # not climbing, but on wall animation pass else: if pyxel.btn(pyxel.KEY_A) or pyxel.btn(pyxel.KEY_D): if pyxel.btnp(pyxel.KEY_A) or pyxel.btnp(pyxel.KEY_D): self.anim_zero_frame = pyxel.frame_count frame_x = self.anim_w * (( (pyxel.frame_count - self.anim_zero_frame) // 4) % 6) # TODO: set running and idle frame counts and use those instead of just ints. else: if pyxel.btnr(pyxel.KEY_A) or pyxel.btnr(pyxel.KEY_D): self.anim_zero_frame = pyxel.frame_count frame_x = self.anim_w * (6 + ( (pyxel.frame_count - self.anim_zero_frame) // 4) % 6) # TODO: make the rendering offset between player collision box # and the image blt dynamic based on frame size and hit box size pyxel.blt(self.x - 1, self.y - 5, 0, frame_x, 16, -self.direction * self.width + (3 * -self.direction), self.height + 5, 1) if self.attacking: if pyxel.btnp(pyxel.KEY_L): self.attack_zero_frame = pyxel.frame_count else: if pyxel.frame_count < self.attack_zero_frame + self.attack_frame_count: frame_x = self.anim_w * ( 17 + (pyxel.frame_count - self.attack_zero_frame) // 2) pyxel.blt( self.x + self.direction * 4, self.y - 5, 0, frame_x, 16, -self.direction * self.width + (3 * -self.direction), self.height + 5, 1) else: self.attacking = False
def _keyActions(self): # ---vvv---左右移動 if pyxel.btn(pyxel.KEY_LEFT): # 左加速 self._vx = max(self._vx - 0.5 , -2) # 左最大速度 if pyxel.btnr(pyxel.KEY_LEFT): # キーを離したら vector をリセット self._vx = 0 if pyxel.btn(pyxel.KEY_RIGHT): # 右加速 self._vx = min(self._vx + 0.5 , 2) # 右最大速度 右画面端までしかいかない if pyxel.btnr(pyxel.KEY_RIGHT): # キーを離したら vector をリセット self._vx = 0 # ---^^^---左右移動 self._jump()
def update(self): player = self.game.player rabbit = self.game.rabbit if pyxel.btnp(pyxel.constants.KEY_LEFT, player.tick_rate, player.tick_rate): player.move_left() elif pyxel.btnp(pyxel.constants.KEY_RIGHT, player.tick_rate, player.tick_rate): player.move_right() elif pyxel.btnp(pyxel.constants.KEY_UP, player.tick_rate, player.tick_rate): player.move_up() elif pyxel.btnp(pyxel.constants.KEY_DOWN, player.tick_rate, player.tick_rate): player.move_down() # debug stuffs elif pyxel.btnr(pyxel.constants.KEY_PERIOD): player.tick_rate -= 1 elif pyxel.btnr(pyxel.constants.KEY_COMMA): player.tick_rate += 1 elif pyxel.btnr(pyxel.constants.KEY_R): self.game.load_level() elif pyxel.btnr(pyxel.constants.KEY_LEFT_BUTTON): self.game.debug_x_y(pyxel.mouse_x, pyxel.mouse_y) # rabbit cheat elif pyxel.btnp(pyxel.constants.KEY_W, player.tick_rate, player.tick_rate): rabbit.movement_type = MovementType.NONE rabbit.target = None rabbit.move_up() elif pyxel.btnp(pyxel.constants.KEY_A, player.tick_rate, player.tick_rate): rabbit.movement_type = MovementType.NONE rabbit.target = None rabbit.move_left() elif pyxel.btnp(pyxel.constants.KEY_D, player.tick_rate, player.tick_rate): rabbit.movement_type = MovementType.NONE rabbit.target = None rabbit.move_right() elif pyxel.btnp(pyxel.constants.KEY_S, player.tick_rate, player.tick_rate): rabbit.movement_type = MovementType.NONE rabbit.target = None rabbit.move_down() elif pyxel.btnp(pyxel.constants.KEY_X, player.tick_rate, player.tick_rate): self.game.start_rabbit()
def get_input(self): if pyxel.btn(pyxel.KEY_S): self.lander.thrust_y += 1 else: self.lander.thrust_y -= 4 if pyxel.btn(pyxel.KEY_A): self.lander.thrust_x += 1 if pyxel.btn(pyxel.KEY_D): self.lander.thrust_x += -1 if pyxel.btnr(pyxel.KEY_A) or pyxel.btnr(pyxel.KEY_D): self.lander.thrust_x = 0
def update0(self): self.mx += self.dx self.dx *= -1 if self.mx <= 5 or self.mx + Game.MW >= pyxel.width // 2 - 5 else 1 if not self.isjumping: # running if [k for k in self.keys if pyxel.btn(k)]: self.energy = (self.energy + 1) % (self.EnergyMax + 1) if [k for k in self.keys if pyxel.btnr(k)]: self.dy, self.isjumping = (-self.energy - 0) / 4.4, True elif not [ it for it in self.floors if it[0] + 0 < self.mx + Game.MW and it[0] + Game.W - 0 > self.mx and self.my + Game.MH == it[1] ]: # 踏み外す self.dy, self.isjumping = 0, True else: # jumping self.my += self.dy if self.dy < 0: # 上昇中 self.scroll_y = min(self.scroll_y, self.my - 40) self.genfloors() else: # 落下中 if s := [ it for it in self.floors if it[0] + 0 < self.mx + Game.MW and it[0] + Game.W - 0 > self.mx and self.my + Game.MH - self.dy <= it[1] and self.my + Game.MH >= it[1] ]: # 着地 self.my, self.isjumping, self.energy = s[0][ 1] - Game.MH, False, 0 if self.my > self.scroll_y + pyxel.height + Game.MH: # ゲームオーバー self.update = self._update().__next__ self.dy += 0.4
def process_input(root): capturer = Widget._capture_widget if capturer: mx = pyxel.mouse_x my = pyxel.mouse_y last_mx, last_my = Widget._capture_last_pos if mx != last_mx or my != last_my: capturer.call_event_handler('drag', Widget._capture_key, mx - capturer.x, my - capturer.y, mx - last_mx, my - last_my) Widget._capture_last_pos = (mx, my) if pyxel.btnr(Widget._capture_key): capturer.call_event_handler('release', Widget._capture_key, mx - capturer.x, my - capturer.y) press_x, press_y = Widget._capture_press_pos if (pyxel.frame_count <= Widget._capture_time + WIDGET_CLICK_TIME and abs(pyxel.mouse_x - press_x) <= WIDGET_CLICK_DIST and abs(pyxel.mouse_y - press_y) <= WIDGET_CLICK_DIST): capturer.call_event_handler('click', Widget._capture_key, mx - capturer.x, my - capturer.y) root._release_mouse() root._process_input()
def _process_capture(self): capture_info = Widget._mouse_capture_info last_x, last_y = capture_info.last_pos x = pyxel.mouse_x y = pyxel.mouse_y if x != last_x or y != last_y: self.trigger_event( "mouse_drag", capture_info.key, x, y, x - last_x, y - last_y, ) capture_info.last_pos = (x, y) if self.is_hit(x, y): self.trigger_event("mouse_hover", x, y) if pyxel.btnp(capture_info.key, WIDGET_HOLD_TIME, WIDGET_REPEAT_TIME): self.trigger_event("mouse_repeat", capture_info.key, x, y) if pyxel.btnr(capture_info.key): self.trigger_event("mouse_up", capture_info.key, x, y) press_x, press_y = capture_info.press_pos if (pyxel.frame_count <= capture_info.time + WIDGET_CLICK_TIME and abs(x - press_x) <= WIDGET_CLICK_DIST and abs(y - press_y) <= WIDGET_CLICK_DIST): self.trigger_event("mouse_click", capture_info.key, x, y) self._end_capture()
def update(self): for key in self.pressed_keys: if pyxel.btnp(key): self.pressed_keys[key][STATE.CURRENT] = True self.pressed_keys[key][STATE.EVER] = True elif pyxel.btnr(key): self.pressed_keys[key][STATE.CURRENT] = False
def _process_capture(self): capture_info = Widget._capture_info last_mx, last_my = capture_info.last_pos mx = pyxel.mouse_x my = pyxel.mouse_y if mx != last_mx or my != last_my: self.call_event_handler("mouse_drag", capture_info.key, mx, my, mx - last_mx, my - last_my) capture_info.last_pos = (mx, my) if self.is_hit(mx, my): self.call_event_handler("mouse_hover", mx, my) if pyxel.btnp(capture_info.key, WIDGET_HOLD_TIME, WIDGET_REPEAT_TIME): self.call_event_handler("mouse_repeat", capture_info.key, mx, my) if pyxel.btnr(capture_info.key): self.call_event_handler("mouse_up", capture_info.key, mx, my) press_x, press_y = capture_info.press_pos if (pyxel.frame_count <= capture_info.time + WIDGET_CLICK_TIME and abs(pyxel.mouse_x - press_x) <= WIDGET_CLICK_DIST and abs(pyxel.mouse_y - press_y) <= WIDGET_CLICK_DIST): self.call_event_handler("mouse_click", capture_info.key, mx, my) self._release_mouse()
def update(self): if pyxel.btn(pyxel.KEY_ALT): if pyxel.btnp(pyxel.KEY_SPACE): self.star_map.gen_new_map() if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON): self.star_map.select_hovered_system(move_camera=True) if pyxel.btnp(pyxel.MOUSE_RIGHT_BUTTON): self.mouse_pos_when_press = pyxel.mouse_x, pyxel.mouse_y self.last_map_pos = tuple(self.camera.position) if pyxel.btnr(pyxel.MOUSE_RIGHT_BUTTON): self.mouse_pos_when_press = None if pyxel.btn(pyxel.MOUSE_RIGHT_BUTTON): tmp_pos = Vec2(self.last_map_pos[::]) old_mx, old_my = self.mouse_pos_when_press tmp_pos.x -= pyxel.mouse_x - old_mx tmp_pos.y -= pyxel.mouse_y - old_my self.camera.move_to(tmp_pos.x, tmp_pos.y, smooth=True) self.camera.update() self.star_map.update()
def process_input(self): if not self._is_visible: return False widget = Widget._capture_widget if widget: mx = pyxel.mouse_x my = pyxel.mouse_y last_mx, last_my = Widget._capture_last_pos if mx != last_mx or my != last_my: widget.call_event_handler('drag', Widget._capture_key, mx - widget.x, my - widget.y, mx - last_mx, my - last_my) Widget._capture_last_pos = (mx, my) if pyxel.btnr(Widget._capture_key): widget.call_event_handler('release', Widget._capture_key, mx - widget.x, my - widget.y) press_x, press_y = Widget._capture_press_pos if (pyxel.frame_count <= Widget._capture_time + CLICK_TIME and abs(pyxel.mouse_x - press_x) <= CLICK_DIST and abs(pyxel.mouse_y - press_y) <= CLICK_DIST): widget.call_event_handler('click', Widget._capture_key, mx - widget.x, my - widget.y) self._release_mouse() return True for widget in reversed(self.children): if widget.process_input(): return True mx = pyxel.mouse_x my = pyxel.mouse_y if (mx >= self.x and mx < self.x + self.width and my >= self.y and my < self.y + self.height): key = None if pyxel.btnp(pyxel.KEY_LEFT_BUTTON): key = pyxel.KEY_LEFT_BUTTON elif pyxel.btnp(pyxel.KEY_RIGHT_BUTTON): key = pyxel.KEY_RIGHT_BUTTON if key is not None: self._capture_mouse(key) x = mx - self.x y = my - self.y self.call_event_handler('press', key, x, y) self.call_event_handler('drag', key, x, y, 0, 0) return True self.call_event_handler('hover', mx - self.x, my - self.y) return False
def update(self): if pyxel.btnp(pyxel.KEY_ESCAPE): pyxel.quit() if pyxel.btnp(pyxel.KEY_W): self.has_won = True if not self.locked and pyxel.btnr(pyxel.KEY_SPACE): script = INPUT_PREAMBLE + self.read_input() self.reset_vars() try: self.locked = True if (self.upgraded or (not self.upgraded and not any(bf in script for bf in self.blocked_functions))): exec(script) except signals.Help: self.set_msg( signals.HELP if self.upgraded else signals.START_HELP) except signals.Credits: self.set_msg(signals.CREDITS) except signals.See as see: """Start typing out info on the named target.""" if see.msg in self.targets: tgt: Target = self.targets[see.msg] self.set_msg( f'{see.msg} ({tgt.x}, {tgt.y}) - Relative to you: ({tgt.x-self.player.x}, {tgt.y-self.player.y})\n{tgt.comment}' ) else: self.set_msg(f'{see.msg}: no such target') except signals.Right as right: self.player.deltax = right.dist except signals.Left as left: self.player.deltax = -left.dist except signals.Up as up: self.player.deltay = -up.dist except signals.Down as down: self.player.deltay = down.dist except signals.Shoot as shot: self.inputed_angle = shot.angle % 360 self.beam_angle = radians(-shot.angle) self.beam_start_time = pyxel.frame_count pyxel.play(3, 0) except: pass self.move_player() if len(self.seemsg) > 0: self.typeout()
def update(self): super().update() if pyxel.btnr(pyxel.KEY_SPACE): self.root.initGame() self.color += 1 if self.color > 15: self.color = 1
def ballon_control(): global switch, force # Add force for each dt if (pyxel.btnp(pyxel.KEY_UP, period=20) or pyxel.btnp(pyxel.KEY_DOWN, period=20) or pyxel.btnp(pyxel.KEY_LEFT, period=20) or pyxel.btnp(pyxel.KEY_RIGHT, period=20)): if not switch: force += 50 else: force -= 50 if force == 650 or force == -50: switch = not switch ballon_control() # Apply force based on the arrow key if pyxel.btnr(pyxel.KEY_UP): ballon.apply_force(0, -force) force = 0 switch = False if pyxel.btnr(pyxel.KEY_DOWN): ballon.apply_force(0, force) force = 0 switch = False if pyxel.btnr(pyxel.KEY_LEFT): ballon.apply_force(-force, 0) force = 0 switch = False if pyxel.btnr(pyxel.KEY_RIGHT): ballon.apply_force(force, 0) force = 0 switch = False #Handbrake if pyxel.btn(pyxel.KEY_SPACE): b_force_x = (ballon.mass * ballon.velocity_x) / dt b_force_y = (ballon.mass * ballon.velocity_y) / dt ballon.apply_force(-b_force_x, -b_force_y)
def menu_load(self): if pyxel.btnr(pyxel.KEY_M): self.menu += 1 if self.menu == 1: pyxel.rectb(*menu_box) pyxel.text(menu_box[0] + 2, menu_box[1] + 2, "THE MENU", 1) pyxel.mouse(visible=True) else: self.menu = 0
def change_vector(self): # 速度変更 if pyxel.btn(pyxel.KEY_LEFT): # 左加速 self.x_axis_vector = max(self.x_axis_vector - 0.5 , -2) # 左最大速度 if pyxel.btnr(pyxel.KEY_LEFT): # キーを離したら vector をリセット self.x_axis_vector = 0 if pyxel.btn(pyxel.KEY_RIGHT): # 右加速 self.x_axis_vector = min(self.x_axis_vector + 0.5 , 2) # 右最大速度 右画面端までしかいかない if pyxel.btnr(pyxel.KEY_RIGHT): # キーを離したら vector をリセット self.x_axis_vector = 0 if self.y_coordinate < WINDOW_HIGHT - CHARACTOR_HIGHT: if self.on_graund: self.y_axis_vector = 0 else : self.y_axis_vector = min(self.y_axis_vector + 1, 5) # 落下速度の最大値 else: self.y_axis_vector = 0
def update(self): self.__mouse_pos[0] = pyxel.mouse_x // Board.TileSize self.__mouse_pos[1] = pyxel.mouse_y // Board.TileSize if pyxel.btnr(pyxel.MOUSE_LEFT_BUTTON): for c in self.Candidates: if c[0] == self.__mouse_pos[0] and \ c[1] == self.__mouse_pos[1]: return True return False
def update(self): for key_code, btn in self.buttons.items(): if pyxel.btnp(key_code): btn.press() elif pyxel.btnr(key_code): btn.release() if pyxel.btnp(pyxel.KEY_SPACE): self.next_game_pad()