-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainMenu.py
More file actions
98 lines (66 loc) · 2.65 KB
/
MainMenu.py
File metadata and controls
98 lines (66 loc) · 2.65 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os
import sys
import time
import pygame
from pygame.locals import *
os.environ['SDL_VIDEO_CENTERED'] = '1' # prepriping info gathering
mainClock = pygame.time.Clock()
pygame.init()
pygame.font.init()
screenInfo = pygame.display.Info() # grabbing
Screen_Width = screenInfo.current_w
Screen_Height = screenInfo.current_h
screen = pygame.display.set_mode(
(Screen_Width, Screen_Height)) # set size here
def MainMenu():
# print(Screen_Width,Screen_Height)
# Song Loop ----------------------------------------------------------
time.sleep(1)
pygame.mixer.music.load("Song/BMF_Song.mp3")
pygame.mixer.music.play(-1)
#---------------------------------------------------------------------
while True: # add a second button that adds instructions
#click = False
Background = pygame.image.load('Images/BackgroundMain.jpg')
Background = pygame.transform.scale(Background, (1920, 1080))
screen.blit(Background, (0, 0))
MouseX, MouseY = pygame.mouse.get_pos()
button_1 = pygame.Rect(400, 800, 200, 100)
button_2 = pygame.Rect(1300, 800, 200, 100)
if button_1.collidepoint((MouseX, MouseY)):
if click:
pygame.mixer.music.stop()
MainGame()
if button_2.collidepoint((MouseX, MouseY)):
if click:
pygame.mixer.music.stop()
Instuctions()
pygame.draw.rect(screen, (0, 0, 0), button_1, 5)
pygame.draw.rect(screen, (0, 0, 0), button_2, 5)
# add a custom font, normal font looks like garbage
#Font For Button 1
myfont = pygame.font.SysFont('Robotico', 50)
textsurface = myfont.render('Start Game', False, (0, 0, 0))
screen.blit(textsurface, (410, 830))
#--------------------------------------------------------------------
#font for button 2
myfont = pygame.font.SysFont('Robotico', 40)
textsurface = myfont.render('Instructions', False, (0, 0, 0))
screen.blit(textsurface, (1310, 830))
#---------------------------------------------------------------------
click = False
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
click = True
pygame.display.update()
mainClock.tick(60)
def Instuctions(): # Make instuctions when everything is done
import Instructions
def MainGame():
import MainGame
MainMenu()