Среда, 07.01.2026, 12:41 | Приветствую Вас Гость

...

Код

Главная » Статьи » Python

Генератор числового текста

import pygame
import sys
import random

def generate_text():
word = ""
for i in range(0,50):
word += str(random.randint(0,9))
return word

FPS = 60
WIDTH = 800
HEIGHT = 600
WHITE = (255, 255, 255)
pygame.init()
pygame.font.init()
font = pygame.font.SysFont('Arial', 36)
RANDCOLOR = (random.randint(0,255), random.randint(0,255), random.randint(0,255))
clock = pygame.time.Clock()
sc = pygame.display.set_mode((WIDTH,HEIGHT))
x = 0
y = 0

sc.fill(WHITE)
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
RANDCOLOR = (random.randint(0,255), random.randint(0,255), random.randint(0,255))
text_surface = font.render(generate_text(), True, RANDCOLOR)
sc.blit(text_surface, (x, y))
y = y + 50
pygame.display.update()
print(generate_text())
clock.tick(FPS)


Категория: Python | Добавил: moskov (26.10.2025)
Просмотров: 12 | Рейтинг: 0.0/0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]

Меню сайта

Категории раздела

PHP [47]
C++ [71]
Autoit [131]
Processing [105]
Basic4GL [7]
Fasm [2]
PABC [7]
Js [241]
Gentee [1]
Python [226]
Java android [3]
Small Basic [9]

Мини-чат

Статистика


Онлайн всего: 1
Гостей: 1
Пользователей: 0

Форма входа

Друзья сайта

  • ЗОВ КОСМОСА

  • Хулиган Вселенной

  • Тюремная поэзия

  • Религиозная поэзия

  • Сайт клана ЛеГиоН
  • Поиск