Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from pygame.locals import *
- winWidth=600
- winHeight=480
- color_CYAN=(0,255,255)
- pygame.init()
- caption="Image Test"
- pygame.display.set_caption(caption)
- Game_Window=pygame.display.set_mode((winWidth,winHeight))
- Game_Window.fill(color_CYAN)
- font1 = pygame.font.SysFont(None, 32)#normal font with size of 32;font design not specified.
- text1=font1.render("Hello I am simple text", True,(255,0,0))#text color specified to red
- font2 = pygame.font.SysFont("ArialBlack", 52)#font with size of 52 and font style specified
- text2= font2.render("Hello I am styled text ", True,(0,0,255))#text color specified to blue
- font3 = pygame.font.Font("kongtext.ttf", 14)#font with size of 32 with external font
- text3= font3.render("Hello I am text with externalfont ", True,(0,0,0))#text color specified to Black
- text4 =font1.render("Hello I am simple text with yellow background", True,(255,0,0),(255,255,0))#text color specified to red
- fontUnderline= font1
- fontUnderline.set_underline(True)
- textUnderline = fontUnderline.render("underlined Text", True, (255, 128, 0))
- fontBold= font1
- fontBold.set_bold(True)
- textBold = fontBold.render("bold Text", True, (255, 128, 128))
- fontItalic= font1
- fontItalic.set_italic(True)
- textItalic = fontItalic.render("italic Text", True, (255, 0, 128))
- while True:
- for event in pygame.event.get():
- if event.type==QUIT:
- pygame.quit()
- exit()
- Game_Window.blit(text1,(20,20))
- Game_Window.blit(text2,(20,50))
- Game_Window.blit(text3,(20,100))
- Game_Window.blit(text4,(20,130))
- Game_Window.blit(textUnderline,(20,170))
- Game_Window.blit(textBold,(20,210))
- Game_Window.blit(textItalic,(20,260))
- pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement