Skip to content

Commit

Permalink
added continous and different music in menu and level
Browse files Browse the repository at this point in the history
  • Loading branch information
NYC00kie committed Jan 26, 2022
1 parent 87b8a37 commit af6d580
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ def change_text(self, text, bg="black"):
def show(self, screen):
screen.blit(self.surface, (self.x-(0.5*self.size[0]), self.y))

def click(self, event, pygame):
def click(self, event, pygame, music):
x, y = pygame.mouse.get_pos()
if event.type == pygame.MOUSEBUTTONDOWN:
if pygame.mouse.get_pressed()[0]:
if self.rect.collidepoint(x, y):
self.change_text(self.feedback, bg="red")
music.musicobject.stop()
draw = Draw()
draw.drawlevel(self.assignedobj, pygame)
draw.drawlevel(self.assignedobj, pygame,
volume=music.musicobject.get_volume())
self.assignedobj.reset()
music.musicobject.play(-1)

def hover(self, screen):
x, y = pygame.mouse.get_pos()
Expand Down Expand Up @@ -98,12 +101,11 @@ def checkforfinish(self, Level):
else:
return False

def drawlevel(self, Level, pygame):

self.musicobject = pygame.mixer.Sound(Level.levelmusicpath)

self.musicobject.play(-1)
def drawlevel(self, Level, pygame, volume=0.1):

Level.musicobject = pygame.mixer.Sound(Level.levelmusicpath)
Level.musicobject.set_volume(volume)
Level.musicobject.play(-1)
while True:

starttime = time.time()
Expand All @@ -127,6 +129,7 @@ def drawlevel(self, Level, pygame):
)
)
pygame.display.flip()
Level.musicobject.stop()
time.sleep(2)
return None

Expand All @@ -139,6 +142,7 @@ def drawlevel(self, Level, pygame):

# returns to the menu screen if the del key is pressed
if pressed_keys[pygame.K_DELETE]:
Level.musicobject.stop()
return None

# speed calculation
Expand Down Expand Up @@ -210,7 +214,7 @@ def drawmenu(self, Levelist, pygame):
if event.type == pygame.QUIT or pressed_keys[pygame.K_ESCAPE]:
sys.exit()
for btn in texts:
btn.click(event, pygame)
btn.click(event, pygame, self)
btn.hover(screen)
screen.fill((60, 25, 60))

Expand Down

0 comments on commit af6d580

Please sign in to comment.