From: Simon Cross Date: Fri, 16 May 2014 22:40:23 +0000 (+0200) Subject: Put the menu screen background in place. X-Git-Tag: 0.1~166 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=b45d28f06dc88f85be83d6e5e3d7d05363e41df9;p=naja.git Put the menu screen background in place. --- diff --git a/naja/scenes/menu.py b/naja/scenes/menu.py index adc42df..750d2ce 100644 --- a/naja/scenes/menu.py +++ b/naja/scenes/menu.py @@ -15,11 +15,17 @@ from naja.scenes.load_save import LoadGameScene, SaveGameScene 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 diff --git a/naja/widgets/image_box.py b/naja/widgets/image_box.py new file mode 100644 index 0000000..5709cec --- /dev/null +++ b/naja/widgets/image_box.py @@ -0,0 +1,22 @@ +"""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)