Closed KiedusCracknell closed 1 year ago
Fixed by changing tower draw method from this:
def draw(self, win):
"""
draws the tower
:param win: surface
:return: None
"""
img = self.tower_imgs[0]
win.blit(img, (self.x-img.get_width()//2, self.y-img.get_height()//2))
#draw menu
if self.selected:
# define menu and buttons
self.menu.draw(win)
to this:
def draw(self, win):
"""
draws the tower
:param win: surface
:return: None
"""
img = self.tower_imgs[0]
win.blit(img, (self.x-img.get_width()//2, self.y-img.get_height()//2))
#draw menu
if self.selected:
# define menu and buttons
self.menu = Menu(self, self.x, self.y, menu_bg)
self.menu.add_btn(upgrade_btn, "Upgrade")
self.menu.draw(win)
defining the menu in the tower draw function instead of its init ensures that the position of the towers menu is where it is supposed to be instead of where the tower was when the instance was created(under its button on the menu)
see upgrade menu to right, under sidebar when it is supposed to render above each tower