Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame as pg
- pg.init()
- WIDTH = 800
- HEIGHT = 600
- gameDisplay = pg.display.set_mode((WIDTH,HEIGHT))
- pg.display.set_caption("My Game")
- pg.display.update()
- gold = (204, 153, 0)
- gray = (166, 166, 166)
- dark_gray = (26, 26, 26)
- red = (255, 0, 0)
- white = (255, 255, 255)
- myFont = pg.font.SysFont("monospace", 30)
- gameExit = False
- while not gameExit:
- # FRAME INITALIZE
- mouse = pg.mouse.get_pos()
- # END FRAME INITALIZE
- # EVENT LISTENER
- for event in pg.event.get():
- print(event)
- if event.type == pg.QUIT:
- ga6meExit = True
- elif event.type == pg.MOUSEBUTTONDOWN:
- print("(%d, 250) > (%d,%d) > (%d, 350)" % (WIDTH/3, mouse[0], mouse[1], WIDTH/3 + 300))
- if (WIDTH/3, 250) < mouse < (WIDTH/3 + 300, 350):
- gameExit = True
- # END EVENT LISTENER
- # DRAW
- gameDisplay.fill(white)
- label = myFont.render("Magshimim Game", 15, gold)
- gameDisplay.blit(label, (WIDTH/2 - len("Magshimim Game")*8, 0))
- label_play = myFont.render("Play", 15, red)
- gameDisplay.fill(gray, rect=[WIDTH/3, 100, 300, 100])
- gameDisplay.blit(label_play, (WIDTH/3 + 100, 125))
- label_quit = myFont.render("Quit", 15, red)
- gameDisplay.fill(dark_gray, rect=[WIDTH/3, 250, 300, 100])
- gameDisplay.blit(label_quit, (WIDTH/3 + 100, 300))
- # END DRAW
- pg.display.update()
- pg.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement