diff --git a/concept/character-design01.png b/concept/character-design01.png
new file mode 100644
index 0000000..ee15614
Binary files /dev/null and b/concept/character-design01.png differ
diff --git a/resources/graphics/main_menu.png b/resources/graphics/main_menu.png
new file mode 100644
index 0000000..3329d0a
Binary files /dev/null and b/resources/graphics/main_menu.png differ
diff --git a/robotgame.py b/robotgame.py
index 254e72b..ed59326 100755
--- a/robotgame.py
+++ b/robotgame.py
@@ -40,6 +40,9 @@ for module_name in module_names:
if not module.get_init():
print("Failed to initialise %s module." % module_name)
sys.exit()
+if not pygame.image.get_extended():
+ print("Pygame does not support extended image support.")
+ sys.exit()
import argparse
diff --git a/robotgame/game.py b/robotgame/game.py
index 20d5179..fab23f1 100644
--- a/robotgame/game.py
+++ b/robotgame/game.py
@@ -28,6 +28,8 @@ import os
import pygame
import jukebox
+import level
+import main_menu
class Game(object):
"""Create an object to handle the game."""
@@ -38,9 +40,15 @@ class Game(object):
self.clock = pygame.time.Clock()
- self.jukebox = jukebox.Jukebox(os.path.abspath(os.path.join("resources",
- "music")),
- ["basshit.ogg"])
+ 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()
@@ -61,14 +69,19 @@ class Game(object):
self.draw()
self.clock.tick(self.speed)
+
+ def goto_level(self, level):
+ self.level = level
+
+
def update(self, t, dt):
"""
Update all game objects.
"""
# Retrieve and flush all events since last update call (this prevents
# event "bottlenecking"/lock-ups)
- events = pygame.event.get()
- for event in events:
+ e = pygame.event.get()
+ for event in e:
# Stop the game when closing the window
if event.type == pygame.QUIT:
self.stop()
@@ -80,12 +93,11 @@ class Game(object):
# Update all objects
for obj in self.objs:
if hasattr(obj, 'update'):
- obj.update(t, dt)
- self.prev_ticks = pygame.time.get_ticks()
+ obj.update(e, t, dt)
def draw(self):
"""
- Update all game objects.
+ Draw all game objects.
"""
self.window.fill((0, 0, 0))
for obj in self.objs:
diff --git a/robotgame/jukebox.py b/robotgame/jukebox.py
index b64f37a..e5d77a9 100644
--- a/robotgame/jukebox.py
+++ b/robotgame/jukebox.py
@@ -26,7 +26,6 @@ The jukebox. Handles playback of background music.
import os
import pygame
-import random
class Jukebox(object):
"""Create an object to handle music playback."""
@@ -37,11 +36,9 @@ class Jukebox(object):
def play(self):
pygame.mixer.music.load(
- os.path.join(self.music_dir,
- self.music_files[self.iterator
- % len(self.music_files)]))
+ os.path.join(self.music_dir, self.music_files[self.iterator]))
pygame.mixer.music.play()
- self.iterator += 1
+ self.iterator = (self.iterator + 1) % len(self.music_files)
def stop(self):
pygame.mixer.music.stop()
diff --git a/robotgame/level.py b/robotgame/level.py
new file mode 100644
index 0000000..363a209
--- /dev/null
+++ b/robotgame/level.py
@@ -0,0 +1,29 @@
+# This file is part of ROBOTGAME
+#
+# ROBOTGAME is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# ROBOTGAME is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# ROBOTGAME. If not, see .
+#
+# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
+#
+# level.py
+# --------------------
+# date created : Tue Aug 7 2012
+# copyright : (C) 2012 Sakse Dalum
+# maintained by : Sakse Dalum
+
+"""
+A generic level.
+"""
+
+class Level(object):
+ def __init__(self, level_name):
+ pass
diff --git a/robotgame/main_menu.py b/robotgame/main_menu.py
new file mode 100644
index 0000000..7f27be4
--- /dev/null
+++ b/robotgame/main_menu.py
@@ -0,0 +1,48 @@
+# This file is part of ROBOTGAME
+#
+# ROBOTGAME is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# ROBOTGAME is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# ROBOTGAME. If not, see .
+#
+# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
+#
+# main_menu.py
+# --------------------
+# date created : Tue Aug 7 2012
+# copyright : (C) 2012 Sakse Dalum
+# maintained by : Sakse Dalum
+
+"""
+The main menu.
+"""
+
+import pygame
+import level
+
+class MainMenu(object):
+ def __init__(self, game, background_img_path):
+ self.__dict__.update(locals())
+
+ self.load()
+
+ def load(self):
+ self.background_img = pygame.image.load(self.background_img_path)
+ self.background_img = pygame.transform.smoothscale(
+ self.background_img, self.game.window.get_size())
+
+ def update(self, e, t, dt):
+ for event in e:
+ if event.type == pygame.KEYDOWN:
+ if event.key == pygame.K_SPACE:
+ self.game.goto_level(level.Level("landing"))
+
+ def draw(self, window):
+ window.blit(self.background_img, (0, 0))