Main menu and loading somewhat finished.

This commit is contained in:
Sakse Dalum 2012-08-07 15:46:40 +02:00
parent b0062a5ba7
commit 5452dfdfe0
2 changed files with 13 additions and 10 deletions

View File

@ -40,18 +40,10 @@ class Game(object):
self.clock = pygame.time.Clock() self.clock = pygame.time.Clock()
self.jukebox = jukebox.Jukebox(
os.path.abspath(os.path.join("resources", "music")),
["basshit.ogg"])
# Add main menu object to list of objects.
self.objs.append(main_menu.MainMenu(self, os.path.abspath(os.path.join(
"resources", "graphics", "main_menu.png"))))
self.level = None
self.ticks = self.prev_ticks = pygame.time.get_ticks() self.ticks = self.prev_ticks = pygame.time.get_ticks()
self.load()
def start(self): def start(self):
self.running = True self.running = True
self.run() self.run()
@ -59,6 +51,16 @@ class Game(object):
def stop(self): def stop(self):
self.running = False self.running = False
def load(self):
self.objs.append(main_menu.MainMenu(self, os.path.abspath(os.path.join(
"resources", "graphics", "main_menu.png"))))
self.level = None
self.jukebox = jukebox.Jukebox(
os.path.abspath(os.path.join("resources", "music")),
["basshit.ogg"])
self.jukebox.stop()
self.jukebox.play()
def run(self): def run(self):
t = pygame.time.get_ticks() t = pygame.time.get_ticks()
dt = 0 dt = 0

View File

@ -43,6 +43,7 @@ class MainMenu(object):
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE: if event.key == pygame.K_SPACE:
self.game.goto_level(level.Level("landing")) self.game.goto_level(level.Level("landing"))
self.game.objs.remove(self)
def draw(self, window): def draw(self, window):
window.blit(self.background_img, (0, 0)) window.blit(self.background_img, (0, 0))