from naja.scenes.new_game import NewGameScene
from naja.widgets.selector import SelectorWidget
from naja.widgets.text import TextWidget
+from naja.widgets.image_box import ImageBox
class MenuScene(Scene):
def __init__(self, state):
super(MenuScene, self).__init__(state)
+
+ background = ImageBox(
+ (0, 0), "screens/splash.png")
+ self.add(background)
+
selector = SelectorWidget()
self.add(selector)
y_offset = 0
--- /dev/null
+"""Widget to draw an image"""
+
+from naja.resources import resources
+from naja.resources.mutators import EIGHT_BIT
+from naja.widgets.base import Widget
+
+
+class ImageBox(Widget):
+ """Widget which holds an image."""
+
+ def __init__(self, pos, image, transforms=(EIGHT_BIT,)):
+ super(ImageBox, self).__init__(pos)
+ self.image = image
+ self.transforms = transforms
+
+ def prepare(self):
+ self.surface = resources.get_image(
+ self.image, transforms=self.transforms)
+ self.size = self.surface.get_rect().size
+
+ def draw(self, surface):
+ surface.blit(self.surface, self.rect)