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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
import pygame
import helper
import audio
def show(screen):
running = True
audio.play_menu(True)
while running:
for event in pygame.event.get():
if event.type == pygame.MOUSEMOTION:
pygame.mouse.set_visible(True)
if event.type == pygame.MOUSEBUTTONDOWN:
left, middle, right = pygame.mouse.get_pressed()
mouse = pygame.mouse.get_pos()
print(mouse)
if left:
if 45 < mouse[0] < 195 and 40 < mouse[1] < 70:
print("New game")
screen.fill("black")
canvas = pygame.Surface((1280, 720))
canvas.fill("black")
width = screen.get_size()[0]
height = width / (16/9)
if width > screen.get_size()[0] or height > screen.get_size()[1]:
height = screen.get_size()[1]
width = height * (16/9)
canvas.blit(helper.text("Generating world...", 20, (255, 255, 255)), (50, 50))
scaled_win = pygame.transform.scale(canvas, (width, height))
screen.blit(scaled_win, (screen.get_size()[0] / 2 - width / 2, screen.get_size()[1] / 2 - height / 2))
pygame.display.flip()
blocks = []
for i in range(20):
for j in range(20):
blocks.append((802 + j * 21 - i * 42, 202 + j * 13 + i, "grass_block"))
import game
audio.stop(1)
game.run(screen, blocks)
return
elif 45 < mouse[0] < 205 and 40+25 < mouse[1] < 70+25:
print("Load game")
elif 45 < mouse[0] < 125 and 40+25*2 < mouse[1] < 70+25*2:
print("Settings")
elif 45 < mouse[0] < 90 and 40+25*3 < mouse[1] < 70+25*3:
print("Exit")
running = False
if event.type == pygame.QUIT:
running = False
screen.fill("black")
canvas = pygame.Surface((1280, 720))
canvas.fill("red")
width = screen.get_size()[0]
height = width / (16/9)
if width > screen.get_size()[0] or height > screen.get_size()[1]:
height = screen.get_size()[1]
width = height * (16/9)
canvas.blit(helper.text("Start new game", 20, (255, 255, 255)), (50, 50))
canvas.blit(helper.text("Load saved game", 20, (255, 255, 255)), (50, 75))
canvas.blit(helper.text("Settings", 20, (255, 255, 255)), (50, 100))
canvas.blit(helper.text("Exit", 20, (255, 255, 255)), (50, 125))
scaled_win = pygame.transform.scale(canvas, (width, height))
screen.blit(scaled_win, (screen.get_size()[0] / 2 - width / 2, screen.get_size()[1] / 2 - height / 2))
audio.play_menu()
pygame.display.flip()
|