Python implements barrage effects based on the pygame library (multi-line display, different speeds, different colors, and cyclic display)

1. To achieve the goal   

        Use python to achieve a display effect similar to bullet chatting. The text of the bullet chatting is stored in a txt file, and the bullet chatting is displayed in multiple lines. The color of the bullet chatting is different, the speed of the bullet chatting is different, and the bullet chatting should be displayed in a loop.

  

 

Bullet text data: danmu.txt

Brother God forever , 
so 
handsome ah ah 
ah ah ah ah ah ah ah ah ah ah ah ah 
666 
loved and loved 
la la la la la la 
Li La! Awesome! Awesome! 
It’s amazing, 
watch the barrage with peace of mind, don’t be noisy . 
The picture is too beautiful, I dare 
not 
watch it. 
My family members, who knows 
? 
Woooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo , but also pay attention to warmth 
, I think it is quite cute, 
just sing and dig at home, not suitable for going out on the street. 
Frogs are beneficial insects and cannot be sold. 
It's hot, it's not hot! 
The helplessness of the people at the bottom, 
isn't the frog seller afraid of the heat? 
Too expensive, unreasonable prices, tricking children into forcing adults to spend. 
Isn't this more respectable than begging? It's normal 
that everything is restricted to Shanghai. 
I think this is very good. 
It adds fun to the current high-paced life and also solves the problem of population employment.

Guess you like

Origin blog.csdn.net/c1007857613/article/details/130686635