-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix_code_rain.py
76 lines (54 loc) · 2.74 KB
/
matrix_code_rain.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
import pygame
from random import choice, randrange
pygame.init()
WIDTH, HEIGHT = 1920, 1080
RES = (WIDTH, HEIGHT)
FONT_SIZE = 35
alpha_value = randrange(30, 40, 5)
chars = ['ヲ', 'ア', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'ツ', 'テ', 'ナ', 'ニ', 'ヌ', 'ネ',
'ハ', 'ヒ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ラ', 'リ', 'ワ', '9', '8', '7', '5', '2', '1', ':', '.',
'"', '=', '*', '+', '-', '¦', '|', '_', '╌', '日', 'C', 'O', 'D', 'E', 'X', 'c', 'o', 'd', 'e', 'x', 'CODEDEX', 'codedex']
font = pygame.font.Font('font/ms mincho.ttf', FONT_SIZE)
font_2 = pygame.font.Font('font/ms mincho.ttf', FONT_SIZE - FONT_SIZE // 6)
font_3 = pygame.font.Font('font/ms mincho.ttf', FONT_SIZE - FONT_SIZE // 3)
green_chars = [font.render(char, True, (randrange(0, 100), 255, randrange(0, 100))) for char in chars]
green_chars_2 = [font_2.render(char, True, (40, randrange(100, 175), 40)) for char in chars]
green_chars_3 = [font_3.render(char, True, (40, randrange(50, 100), 40)) for char in chars]
screen = pygame.display.set_mode(RES)
display_surface = pygame.Surface(RES)
display_surface.set_alpha(alpha_value)
clock = pygame.time.Clock()
class Symbol:
def __init__(self, x, y):
self.x = x
self.y = y
self.speed = 40
self.value = choice(green_chars)
def draw(self):
self.value = choice(green_chars)
self.y = self.y + self.speed if self.y < HEIGHT else -FONT_SIZE * randrange(1, 10)
screen.blit(self.value, (self.x, self.y))
def draw_2(self):
self.value_2 = choice(green_chars_2)
self.y = self.y + self.speed if self.y < HEIGHT else -FONT_SIZE * randrange(1, 10)
screen.blit(self.value_2, (self.x, self.y))
def draw_3(self):
self.value_3 = choice(green_chars_3)
self.y = self.y + self.speed if self.y < HEIGHT else -FONT_SIZE * randrange(1, 10)
screen.blit(self.value_3, (self.x, self.y))
symbols = [Symbol(x, randrange(-HEIGHT, 0)) for x in range(0, WIDTH, FONT_SIZE * 3)]
symbols_2 = [Symbol(x, randrange(-HEIGHT, 0)) for x in range(FONT_SIZE, WIDTH, FONT_SIZE * 3)]
symbols_3 = [Symbol(x, randrange(-HEIGHT, 0)) for x in range(FONT_SIZE * 2, WIDTH, FONT_SIZE * 3)]
run = True
while run:
screen.blit(display_surface, (0, 0))
display_surface.fill(pygame.Color('black'))
[symbol.draw() for symbol in symbols]
[symbol_2.draw_2() for symbol_2 in symbols_2]
[symbol_3.draw_3() for symbol_3 in symbols_3]
pygame.time.delay(140)
pygame.display.update()
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False