Advertisement
CmdEngineer

Untitled

Mar 10th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. import pygame as pg
  2. pg.init()
  3.  
  4. WIDTH = 800
  5. HEIGHT = 600
  6. gameDisplay = pg.display.set_mode((WIDTH,HEIGHT))
  7.  
  8. pg.display.set_caption("My Game")
  9. pg.display.update()
  10.  
  11. gold = (204, 153, 0)
  12. gray = (166, 166, 166)
  13. dark_gray = (26, 26, 26)
  14. red = (255, 0, 0)
  15. white = (255, 255, 255)
  16. myFont = pg.font.SysFont("monospace", 30)
  17.  
  18. gameExit = False
  19.  
  20. while not gameExit:
  21.     # FRAME INITALIZE
  22.     mouse = pg.mouse.get_pos()
  23.     # END FRAME INITALIZE
  24.    
  25.     # EVENT LISTENER
  26.     for event in pg.event.get():
  27.         print(event)
  28.         if event.type == pg.QUIT:
  29.             ga6meExit = True
  30.         elif event.type == pg.MOUSEBUTTONDOWN:
  31.             print("(%d, 250) > (%d,%d) > (%d, 350)" % (WIDTH/3, mouse[0], mouse[1], WIDTH/3 + 300))
  32.             if (WIDTH/3, 250) < mouse < (WIDTH/3 + 300, 350):
  33.                 gameExit = True
  34.     # END EVENT LISTENER
  35.    
  36.     # DRAW
  37.     gameDisplay.fill(white)
  38.     label = myFont.render("Magshimim Game", 15, gold)
  39.     gameDisplay.blit(label, (WIDTH/2 - len("Magshimim Game")*8, 0))
  40.  
  41.     label_play = myFont.render("Play", 15, red)
  42.     gameDisplay.fill(gray, rect=[WIDTH/3, 100, 300, 100])
  43.     gameDisplay.blit(label_play, (WIDTH/3 + 100, 125))
  44.    
  45.     label_quit = myFont.render("Quit", 15, red)
  46.     gameDisplay.fill(dark_gray, rect=[WIDTH/3, 250, 300, 100])
  47.     gameDisplay.blit(label_quit, (WIDTH/3 + 100, 300))
  48.     # END DRAW
  49.    
  50.     pg.display.update()
  51. pg.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement