def get_room_at_mouse(g_obj, mpos_mapped): rooms = g_obj.dungeon.get_rooms() rw, rh = g_obj.rw, g_obj.rh for r in rooms: gx, gy = r.grid_pos rr = Rect(gx * rw, gy * rh, rw, rh) if rr.collidepoint(mpos_mapped): return r return None
def should_be_open_tbt(self, lout, bx, by, roomx, roomy, ox, oy, tsw, tsh, m, direction): if direction == "east": range_mod = 2 else: range_mod = 2 tw, th = self.tw, self.th cam = self.cam cx, cy = cam.get() # print(cx, cy) rw, rh = self.rw, self.rh rx = tw * roomx * rw ry = th * roomy * rh rsize = tw, th u = self.mc x, y = u.anim_pos rux, ruy = ox + x * tw, oy + y * th aox, aoy = 0, 0 if (u.state == "attacking" and u.attack_weapon.attack_type == "melee") or u.dashing: aox, aoy = u.projectile_pos mc_pos = rux + aox + cx + tw / 2, ruy + aoy + cy + th / 2 mpos = m mover = [] inrange = [] for dx, dy in product(range(tsw), range(tsh)): at = rx + (bx - ox + dx) * tw + cx, ry + (by - oy + dy) * th + cy # at = (bx+dx) * tw, (by+dy) * th # self.swin.blit(img, at) r = Rect(at, rsize) if r.collidepoint(mpos): mover.append(True) else: mover.append(False) if in_range(mc_pos, r.center, 3 + tw * range_mod): inrange.append(True) else: inrange.append(False) if any(inrange): # and any(mover): return True else: return False