-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText.py
63 lines (54 loc) · 1.85 KB
/
Text.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
import pygame
from Transitions import *
class Text():
"""Text Rendering"""
def __init__(this, screen, text, x, y, color, size, font, center, fadeInLeft, fadeInTop, fadeColor, startX, startY, speed):
this.screen = screen
this.text = text
this.x = x
this.desiredX = x
this.y = y
this.desiredY = y
this.color = color
this.desiredColor = color
this.size = size
this.speed = speed
pygame.font.init() # Initializes the font
this.font = pygame.font.Font(font, size)
this.center = center
this.fadeInLeft = fadeInLeft
this.fadeInTop = fadeInTop
this.fadeColor = fadeColor
if (fadeInLeft):
this.x = startX
if (fadeInTop):
this.y = startY
if (fadeColor):
this.color = (0,0,0)
def Draw(this):
if (this.fadeInLeft):
this.x = Transitions.FadeInLeft(this.x, this.desiredX, this.speed)
this.y = this.desiredY
if (this.fadeInTop):
this.y = Transitions.FadeInLeft(this.y, this.desiredY, this.speed)
if (this.fadeColor):
this.color = Transitions.FadeInColor(this.color, this.desiredColor, this.speed)
text = this.font.render(this.text, 1, this.color)
textInfo = text.get_rect()
coords = (this.x, this.y)
if (this.center):
coords = (this.x - textInfo.center[0], this.y)
this.screen.blit(text, coords) # Puts text on the screen
def UpdatePosition(this, x, y):
this.x = x
this.y = y
def SetText(this, text):
this.text = text
def GetText(this):
return this.text
def SetColor(this, color):
this.color = color
def AddText(this, text):
this.text += text
def RemoveLetter(this):
this.text = this.text[:-1]