-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuts.py
92 lines (74 loc) · 2.75 KB
/
cuts.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
import time
import numpy
import pygame
import resources
def ShowImage(screen, image):
center = screen.get_rect().center
screen.blit(image,
(center[0] - (image.get_rect().width / 2),
center[1] - (image.get_rect().height / 2)))
pygame.display.flip()
def FadeTo(screen, source, destination, frames=20):
size = source.get_size()
center = screen.get_rect().center
src = pygame.surfarray.pixels3d(source)
dest = pygame.surfarray.pixels3d(destination)
image = pygame.surfarray.pixels3d(pygame.Surface(size))
columns = range(size[0])
rows = range(size[1])
for frame in range(frames + 1):
fin = float(frame) / float(frames)
fout = float(frames - frame) / float(frames)
image = (src * fout) + (dest * fin)
screen.blit(pygame.surfarray.make_surface(image),
(center[0] - (size[0] / 2),
center[1] - (size[1] / 2)))
pygame.display.flip()
def ShowLogo(screen):
clock = pygame.time.Clock()
logo_frame = [
resources.load_image('int0_sketch.png'),
resources.load_image('int0_pencil.png'),
resources.load_image('int0_ink.png'),
resources.load_image('int0_final.png')
]
white = pygame.Surface(logo_frame[0].get_size())
white.fill((255, 255, 255, 255))
black = pygame.Surface(screen.get_size())
black = black.convert_alpha()
black.set_alpha(255)
black.fill((0, 0, 0, 0))
screen.fill((0, 0, 0))
pygame.display.flip()
for w in range(256):
screen.fill((w, w, w))
pygame.display.flip()
FadeTo(screen, white, logo_frame[0])
for frm in range(len(logo_frame) -1):
FadeTo(screen, logo_frame[frm], logo_frame[frm + 1])
time.sleep(1.0)
for w in range(256):
black.fill((0, 0, 0, w))
screen.blit(black, (0, 0))
pygame.display.flip()
def StartLevel(screen, background, level_no):
size = resources.FONT.size('Level %s' % level_no)
screen_size = screen.get_size()
center = ((screen_size[0] / 2) - (size[0] / 2),
(screen_size[1] / 2) - (size[1] / 2))
for alpha in range(255):
screen.blit(background, (0, 0))
level = resources.FONT.render('Level %s' % level_no, 1,
(alpha, alpha, alpha, 255))
screen.blit(level, center)
pygame.display.flip()
time.sleep(1.0)
for alpha in range(255):
screen.blit(background, (0, 0))
level = resources.FONT.render('Level %s' % level_no, 1,
(255 - alpha, 255 - alpha, 255 -alpha, 255))
screen.blit(level, center)
pygame.display.flip()
screen.blit(background, (0, 0))
pygame.display.flip()