-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffects.py
More file actions
52 lines (45 loc) · 1.76 KB
/
effects.py
File metadata and controls
52 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import random
import pygame
class MapTransitionIn:
def __init__(self, game, done):
self.BLOCK_SIZE = 10
self.screen = game.screen
self.size = game.GAME_AREA_SIZE_PIXELS
self.surface = pygame.Surface(game.GAME_AREA_SIZE_PIXELS, pygame.SRCALPHA)
self.pos = game.GAME_AREA_POS.int_xy
self.done = done
self.rects = []
for x in range(0, self.size[0], self.BLOCK_SIZE):
for y in range(0, self.size[1], self.BLOCK_SIZE):
self.rects.append(pygame.Rect(x, y, self.BLOCK_SIZE, self.BLOCK_SIZE))
random.shuffle(self.rects)
def __call__(self):
for _ in range(10):
if not self.rects:
self.done()
return
r = self.rects.pop()
self.surface.fill(pygame.Color("black"), r)
self.screen.blit(self.surface, self.pos)
class MapTransitionOut:
def __init__(self, game, done):
self.BLOCK_SIZE = 10
self.screen = game.screen
self.size = game.GAME_AREA_SIZE_PIXELS
self.surface = pygame.Surface(game.GAME_AREA_SIZE_PIXELS, pygame.SRCALPHA)
self.surface.fill(pygame.Color("black"))
self.pos = game.GAME_AREA_POS.int_xy
self.done = done
self.rects = []
for x in range(0, self.size[0], self.BLOCK_SIZE):
for y in range(0, self.size[1], self.BLOCK_SIZE):
self.rects.append(pygame.Rect(x, y, self.BLOCK_SIZE, self.BLOCK_SIZE))
random.shuffle(self.rects)
def __call__(self):
for _ in range(10):
if not self.rects:
self.done()
return
r = self.rects.pop()
self.surface.fill((0, 0, 0, 0), r)
self.screen.blit(self.surface, self.pos)