You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.3 KiB
73 lines
2.3 KiB
import pygame
|
|
import math
|
|
from scroller import scroller
|
|
from scroller import char_sheet
|
|
|
|
pygame.init()
|
|
|
|
size = width, height = 320, 240
|
|
|
|
black = 0, 0, 0
|
|
red = 255, 0, 0
|
|
characters = [' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+',
|
|
',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8',
|
|
'9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E',
|
|
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
|
|
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
|
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
|
|
'z', '{', '|', '}', '~', '©']
|
|
|
|
char_sheet = char_sheet.CharSheet("jeromBD-metal-CCBY3.png",
|
|
characters, 16, 16)
|
|
|
|
x = 320
|
|
y = 120
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
scroller = scroller.Scroller("IT'S BEEN... one week since you looked at me, " +
|
|
"cocked your head to the side and said \"I'm " +
|
|
"angry\" ")
|
|
|
|
screen = pygame.display.set_mode(size)
|
|
|
|
while 1:
|
|
dt = clock.tick(60)
|
|
|
|
screen.fill(black)
|
|
|
|
i = 0
|
|
|
|
if not scroller.sheet_chars:
|
|
scroller.get_next_char(320, 120, 0.1, 2, 0, 20)
|
|
|
|
for sheet_char in scroller.sheet_chars:
|
|
sheet_char.x -= sheet_char.x_speed * dt
|
|
|
|
sheet_char.angle += sheet_char.y_speed
|
|
|
|
sheet_char.y = ((sheet_char.radius *
|
|
math.sin(sheet_char.angle * math.pi / 180)) +
|
|
120)
|
|
|
|
if (sheet_char.x < -(char_sheet.char_width)):
|
|
scroller.delete_first_char()
|
|
i -= 1
|
|
else:
|
|
if (i == (len(scroller.sheet_chars) - 1) and
|
|
sheet_char.x <= (width - char_sheet.char_width)):
|
|
scroller.get_next_char(320, 120, 0.1, 2, 0, 20)
|
|
print(str(len(scroller.sheet_chars) - 1) + " | " + str(i) +
|
|
" | " + str(scroller.next_char))
|
|
|
|
i += 1
|
|
|
|
sect = char_sheet.get_sheet(sheet_char)
|
|
sprite = pygame.Rect((sect[0] * 16),
|
|
(sect[1] * 16), 16, 16)
|
|
|
|
screen.blit(char_sheet.sheet, (sheet_char.x,
|
|
sheet_char.y), sprite)
|
|
|
|
pygame.display.flip()
|
|
|