def __init__(self, state):
super(IntroductionScene, self).__init__(state)
+ self.grid_surface = None
+
background = ImageBox(
(0, 0), "screens/splash.png")
self.add(background)
self.add(PreRenderedImageBox((0, 0), game_surface))
return game_surface
+ def get_grid_surface(self, game_surface):
+ grid_size = 4
+ if self.grid_surface is None:
+ rect = game_surface.get_rect()
+ size = (rect.width, rect.height)
+ self.grid_surface = pygame.surface.Surface(
+ size, flags=pgl.SRCALPHA)
+ for i in range(0, rect.width, grid_size):
+ for j in range(0, rect.height, grid_size):
+ if (i + j) % (grid_size * 2) == 0:
+ continue
+ pygame.draw.rect(self.grid_surface, PALETTE.GREY,
+ (i, j, grid_size, grid_size))
+ return self.grid_surface
+
+ def grid_out(self, game_surface, rect):
+ orig = game_surface.copy()
+ game_surface.blit(self.get_grid_surface(game_surface), (0, 0))
+ game_surface.blit(orig, rect, rect)
+ pygame.draw.rect(game_surface, PALETTE.GREEN, rect, 8)
+
def introduction_to_screen_1(self, event):
game_surface = self.make_game_surface()
self.intro = 1
bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
box_width=400, view_port=(500, 800)))
- pygame.draw.rect(game_surface, PALETTE.GREEN, (0, 0, 480, 60), 8)
+ self.grid_out(game_surface, (0, 0, 480, 60))
def introduction_to_screen_2(self, event):
game_surface = self.make_game_surface()
bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
box_width=400, view_port=(500, 800)))
- pygame.draw.rect(game_surface, PALETTE.GREEN, (0, 540, 480, 60), 8)
+ self.grid_out(game_surface, (0, 540, 480, 60))
def introduction_to_screen_3(self, event):
game_surface = self.make_game_surface()
bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
box_width=400, view_port=(500, 800)))
- pygame.draw.rect(game_surface, PALETTE.GREEN, (488, 416, 304, 132), 8)
+ self.grid_out(game_surface, (488, 416, 304, 132))
def introduction_to_screen_4(self, event):
game_surface = self.make_game_surface()
bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
box_width=400, view_port=(500, 800)))
- pygame.draw.rect(game_surface, PALETTE.GREEN, (488, 52, 304, 240), 8)
+ self.grid_out(game_surface, (488, 52, 304, 240))
def handle_scene_event(self, ev):
if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT: