Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import pygame
  2. from pygame.locals import *
  3.  
  4. winWidth=600
  5. winHeight=480
  6. color_CYAN=(0,255,255)
  7.  
  8. pygame.init()
  9.  
  10. caption="Image Test"
  11. pygame.display.set_caption(caption)
  12.  
  13. Game_Window=pygame.display.set_mode((winWidth,winHeight))
  14. Game_Window.fill(color_CYAN)
  15.  
  16. font1 = pygame.font.SysFont(None, 32)#normal font with size of 32;font design not specified.
  17. text1=font1.render("Hello I am simple text", True,(255,0,0))#text color specified to red
  18.  
  19. font2 = pygame.font.SysFont("ArialBlack", 52)#font with size of 52 and font style specified
  20. text2= font2.render("Hello I am styled text ", True,(0,0,255))#text color specified to blue
  21.  
  22.  
  23. font3 = pygame.font.Font("kongtext.ttf", 14)#font with size of 32 with external font
  24. text3= font3.render("Hello I am text with externalfont ", True,(0,0,0))#text color specified to Black
  25.  
  26. text4 =font1.render("Hello I am simple text with yellow background", True,(255,0,0),(255,255,0))#text color specified to red
  27.  
  28. fontUnderline= font1
  29. fontUnderline.set_underline(True)
  30.  
  31. textUnderline = fontUnderline.render("underlined Text", True, (255, 128, 0))
  32.  
  33. fontBold= font1
  34. fontBold.set_bold(True)
  35.  
  36. textBold = fontBold.render("bold Text", True, (255, 128, 128))
  37.  
  38. fontItalic= font1
  39. fontItalic.set_italic(True)
  40.  
  41. textItalic = fontItalic.render("italic Text", True, (255, 0, 128))
  42.  
  43. while True:
  44.  
  45. for event in pygame.event.get():
  46. if event.type==QUIT:
  47. pygame.quit()
  48. exit()
  49.  
  50. Game_Window.blit(text1,(20,20))
  51. Game_Window.blit(text2,(20,50))
  52. Game_Window.blit(text3,(20,100))
  53. Game_Window.blit(text4,(20,130))
  54. Game_Window.blit(textUnderline,(20,170))
  55. Game_Window.blit(textBold,(20,210))
  56. Game_Window.blit(textItalic,(20,260))
  57.  
  58. pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement