# import pygame module in this programimportpygame# activate the pygame library# initiate pygame and give permission# to use pygame's functionality.pygame.init()# create the display surface object# (x, y) is the height and width of pygame windowwin=pygame.display.set_mode((500,500))# set the pygame window namepygame.display.set_caption("Scrolling Text")# setting the pygame font style(1st parameter)# and size of font(2nd parameter)Font=pygame.font.SysFont('timesnewroman',30)# define the RGB value for white,# green, yellow, orange colourwhite=(255,255,255)yellow=(255,255,0)green=(0,255,255)orange=(255,100,0)done=False# Split the text into letters# 3rd parameter is font colour and# 4th parameter is Font backgroundletter1=Font.render("H",False,orange,yellow)letter2=Font.render("E",False,orange,green)letter3=Font.render("M",False,orange,yellow)letter4=Font.render("A",False,orange,green)letter5=Font.render("N",False,orange,yellow)letter6=Font.render("T",False,orange,green)letter7=Font.render("H",False,orange,yellow)# assigning values to# i and c variablei=0c=1# infinite loopwhilenotdone:if(i>=820):i=0c+=1pygame.time.wait(500)# completely fill the surface object# with white colorwin.fill(white)if(c%6==0):# Scrolling the text in diagonal# on right side of the Screen.# copying the text surface object# to the display surface object# at the center coordinate.win.blit(letter1,(662-i,-162+i))win.blit(letter2,(639-i,-139+i))win.blit(letter3,(608-i,-108+i))win.blit(letter4,(579-i,-79+i))win.blit(letter5,(552-i,-52+i))win.blit(letter6,(529-i,-29+i))win.blit(letter7,(500-i,0+i))i+=80if(c%6==5):# Scrolling the text in diagonal on# left side of the Screen.win.blit(letter1,(-162+i,-162+i))win.blit(letter2,(-135+i,-135+i))win.blit(letter3,(-110+i,-110+i))win.blit(letter4,(-79+i,-79+i))win.blit(letter5,(-52+i,-52+i))win.blit(letter6,(-27+i,-27+i))win.blit(letter7,(0+i,0+i))# Decides the speed of# the text on screeni+=80if(c%6==4):# Scrolling the text in# right side of the Screen.win.blit(letter1,(480,-180+i))win.blit(letter2,(480,-150+i))win.blit(letter3,(480,-120+i))win.blit(letter4,(480,-90+i))win.blit(letter5,(480,-60+i))win.blit(letter6,(480,-30+i))win.blit(letter7,(480,0+i))# Decides the speed of# the text on screeni+=80if(c%6==3):# Scrolling the text in left# side of the Screen.win.blit(letter1,(0,-180+i))win.blit(letter2,(0,-150+i))win.blit(letter3,(0,-120+i))win.blit(letter4,(0,-90+i))win.blit(letter5,(0,-60+i))win.blit(letter6,(0,-30+i))win.blit(letter7,(0,0+i))# Decides the speed of# the text on screeni+=80if(c%6==1):win.blit(letter1,(-124+i,0))win.blit(letter2,(-102+i,0))win.blit(letter3,(-82+i,0))win.blit(letter4,(-58+i,0))win.blit(letter5,(-40+i,0))win.blit(letter6,(-19+i,0))win.blit(letter7,(0+i,0))# Decides the speed of# the text on screeni+=80if(c%6==2):# Scrolling the text in bottom of the Screen.win.blit(letter1,(-124+i,470))win.blit(letter2,(-102+i,470))win.blit(letter3,(-82+i,470))win.blit(letter4,(-58+i,470))win.blit(letter5,(-40+i,470))win.blit(letter6,(-19+i,470))win.blit(letter7,(0+i,470))# Decides the speed# of the text on screeni+=80# Draws the surface object to the screen.pygame.display.update()# iterate over the list of Event objects# that was returned by pygame.event.get() methodforeventinpygame.event.get():if(event.type==pygame.QUIT):done=True#Delay with 5mspygame.time.wait(500)pygame.quit()