-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (52 loc) · 2.14 KB
/
main.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
"""
Credits go to that russian coder, youtube channel name 'Standalone coder'
link to his video: https://www.youtube.com/watch?v=YwejI7TJ_Y4
"""
import os
import pygame as pg
from random import choice, randrange
class Symbol:
def __init__(self, x, y, speed):
self.x, self.y = x, y
self.speed = speed
self.value = choice(green_katakana)
self.interval = randrange(5, 30)
def draw(self, color):
frames = pg.time.get_ticks()
if not frames % self.interval:
self.value = choice(green_katakana if color == 'green' else lightgreen_katakana)
self.y = self.y + self.speed if self.y < HEIGHT else -FONT_SIZE
surface.blit(self.value, (self.x, self.y))
class SymbolColumn:
def __init__(self, x, y):
self.column_height = randrange(8, 24)
self.speed = randrange(3, 7)
self.symbols = [Symbol(x, i, self.speed) for i in range(y, y - FONT_SIZE * self.column_height, -FONT_SIZE)]
def draw(self):
[symbol.draw('green') if i else symbol.draw('lightgreen') for i, symbol in enumerate(self.symbols)]
os.environ['SDL_VIDEO_CENTERED'] = '1'
RES = WIDTH, HEIGHT = 1920,1080
FONT_SIZE = 20
alpha_value = 0
pg.init()
screen = pg.display.set_mode(RES)
surface = pg.Surface(RES)
surface.set_alpha(alpha_value)
clock = pg.time.Clock()
katakana = [chr(int('0x30a0', 16) + i) for i in range(96)]
font = pg.font.Font("C:\\Users\\USER\\Documents\\Dev\\Python\\MATRIX_DIGITAL\\MS_mincho.ttf", FONT_SIZE, bold=True)
green_katakana = [font.render(char, True, (40, randrange(160, 256), 10)) for char in katakana]
lightgreen_katakana = [font.render(char, True, pg.Color('lightgreen')) for char in katakana]
symbol_columns = [SymbolColumn(x, randrange(-HEIGHT, 0)) for x in range(0, WIDTH, FONT_SIZE)]
indent = 0
while True:
screen.blit(surface, (0, 0))
surface.fill(pg.Color('black'))
[symbol_column.draw() for symbol_column in symbol_columns]
if not pg.time.get_ticks() % 20 and alpha_value < 170:
alpha_value += 6
surface.set_alpha(alpha_value)
[exit() for i in pg.event.get() if i.type == pg.QUIT]
pg.display.flip()
indent += 1
clock.tick(60)