python⿊客帝国代码⾬特效效果:
代码:
try:
import pygame
import sys
from pygame.locals import *
from random import randint
except:
print(“Load modules error!!”)
exit()
define some datas
SCREEN_WIDTH = 1366
SCREEN_HEIGHT = 768
LOW_SPEED = 30
HIGH_SPEED = 30
LOW_SIZE = 5
HIGH_SIZE = 30
FONT_SIZE = 14
FONT_NAME = “f”
FREQUENCE = 50
times = 0
def random color
def randomcolor():
return (randint(0, 255), randint(0, 255), randint(0, 255))
def randomspeed():
return randint(LOW_SPEED, HIGH_SPEED)
def randomposition():
return (randint(0, SCREEN_WIDTH), randint(0, SCREEN_HEIGHT))
def randomsize():
return randint(LOW_SIZE, HIGH_SIZE)
def randomoname():
return randint(0, 100000)
def randomvalue():
return randint(0, 9) # this is your own display number range
class of sprite
class Word(pygame.sprite.Sprite):
def init(self, bornposition):
pygame.sprite.Sprite.init(self)
self.value = randomvalue()
self.font = pygame.font.SysFont(“arial”, FONT_SIZE)#pygame.font.Font(FONT_NAME, FONT_SIZE) self.image = der(str(self.value), True, randomcolor())
self.speed = randomspeed()
< = _rect()
def update(self):
< = ve(0, self.speed)
op > SCREEN_HEIGHT:
self.kill()
# init the available modules
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption(“HACKER EMPIRE CAPTION RAIN”)
clock = pygame.time.Clock()
group = pygame.sprite.Group()
group_count = SCREEN_WIDTH / FONT_SIZE
mainloop
while True:
time = clock.tick(FREQUENCE)
for event in ():
pe == QUIT:
pygame.quit()
exit()
screen.fill((0, 0, 0))
for i in range(0, int(group_count)):
group.add(Word((i * FONT_SIZE, -FONT_SIZE)))
group.update()
group.draw(screen)
pygame.display.update()
# save pictures
# times += time
# if times > 5000 :
random python# pygame.image.save(screen,str(randomoname())+".png")
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论