-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicpygame.py
63 lines (52 loc) · 2.21 KB
/
basicpygame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pygame
def main():
# Initialise screen
pygame.init()
pygame.display.set_caption('Risk it!')
screen = pygame.display.set_mode((1000, 700))
# Fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
# Display some text
font = pygame.font.Font(None, 36)
text = font.render("There are 3 boxes, each with a set amount of money: either 0, 500, or 1000 pounds!", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
background.blit(text, textpos)
font = pygame.font.Font(None, 30)
text = font.render("Would you rather take 100 pounds or choose a box?", 1, (10, 10, 10))
background.blit(text, (200, 100))
font = pygame.font.Font(None, 30)
text = font.render("Choose a box!", 1, (10, 10, 10))
background.blit(text, (100, 400))
font = pygame.font.Font(None, 30)
text = font.render("Take the 100 pounds!", 1, (10, 10, 10))
background.blit(text, (600, 400))
# Blit everything to the screen
screen.blit(background, (0, 0))
# Event loop
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
screen.blit(background, (0, 0))
green = ((50,205,50))
pygame.draw.rect(screen, green, (125,500,100,50))
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if 125+100 > mouse[0] > 125 and 500 + 50 > mouse[1] >500:
if click[0] == 1:
font = pygame.font.SysFont("comicsansms", 30)
text = font.render("You are willing to take risks :)", 1, (10, 10, 10))
background.blit(text, (300, 200))
red = ((250, 0, 0))
pygame.draw.rect(screen, red, (650,500,100,50))
if 650+100 > mouse[0] > 650 and 500 + 50 > mouse[1] >500:
if click[0] == 1:
font = pygame.font.SysFont("comicsansms", 30)
text = font.render("You are not willing not take risks :(", 1, (10, 10, 10))
background.blit(text, (300, 200))
pygame.display.update()
pygame.display.flip()
if __name__ == '__main__': main()