Skip to content

Commit

Permalink
improve mouseclic and rename it to mouseclick
Browse files Browse the repository at this point in the history
  • Loading branch information
bydariogamer committed Jul 22, 2022
1 parent 7fa6fb7 commit 3deb457
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions button.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ def mouseover(self, resize=None):
elif self.rect.collidepoint(pygame.mouse.get_pos()):
return True

def mouseclic(self, resize=None):
if self.mouseover(resize=resize) and pygame.mouse.get_pressed(num_buttons=3)[0]:
return True
else:
return False
def mouseclick(self, resize=None):
return self.mouseover(resize=resize) and pygame.mouse.get_pressed(num_buttons=3)[0]
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ async def menu_start_loop():
clock.tick(config.BASE_FPS)

# LOGIC
if play_button.mouseclic(resize=resize):
if play_button.mouseclick(resize=resize):
state = "choose"
if help_button.mouseclic(resize=resize):
if help_button.mouseclick(resize=resize):
state = "help"
if exit_button.mouseclic(resize=resize):
if exit_button.mouseclick(resize=resize):
state = "close"

# RENDER
Expand Down Expand Up @@ -233,7 +233,7 @@ async def menu_choose_loop():

# LOGIC
for level in levels[pages[page]]:
if level[0].mouseclic(resize=resize):
if level[0].mouseclick(resize=resize):
try:
if mouse_rel:
player = Player(Level(pygame.mixer.Sound(level[1]), level[2]))
Expand Down Expand Up @@ -277,7 +277,7 @@ async def menu_choose_loop():
pygame.display.update()
await asyncio.sleep(0)

if page_back.mouseclic(resize=resize) and mouse_rel:
if page_back.mouseclick(resize=resize) and mouse_rel:
page -= 1
if page < 0:
page = 0
Expand All @@ -286,7 +286,7 @@ async def menu_choose_loop():
for level in levels:
level[0].color = color

if page_forward.mouseclic(resize=resize) and mouse_rel:
if page_forward.mouseclick(resize=resize) and mouse_rel:
page += 1
if page > len(pages) - 1:
page -= 1
Expand Down

0 comments on commit 3deb457

Please sign in to comment.