-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexture.py
26 lines (21 loc) · 895 Bytes
/
Texture.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
from Settings import st
import pygame as pg
BLS = st.BLS
# Основной класс для работы с текстурами.
class Texture:
def __init__(self, img, quality, text=''):
self.img = pg.image.load(img).convert()
self.img = pg.transform.scale(self.img, (quality, quality))
if text:
font = pg.font.Font(None, 250)
y = 0
for line in text.split('\n'):
rendline = font.render(line, True, (0, 0, 0))
y += rendline.get_rect().height
self.img.blit(rendline, (0, y))
self.quality = quality
self.raywidth = quality // st.BLS
def get(self, offs, height):
offset = int(offs) % BLS
return pg.transform.scale(self.img.subsurface(offset * self.raywidth, 0, self.raywidth, self.quality),
(2, int(height)))