-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.py
107 lines (85 loc) · 3.38 KB
/
menu.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
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
99
100
101
102
103
104
105
106
107
print('Loading menu')
import os
script_path = os.path.dirname(os.path.realpath( __file__ ))
print('wd',script_path)
os.chdir(script_path)
import sprites as sp
import defaults as df
import pygame
import re
import time
import generic as gen
import var
import info
import adjustments
import map
import imp
import device
import buttons as btns
class AddScreen(gen.Xscreen):
def __init__(self):
gen.Xscreen.__init__(self)
self.backfile = var.assetsDir + 'backgrounds/main_background.jpg'
self.play_file = var.assetsDir + 'play_red.png'
self.menu_file = var.assetsDir + 'Buttonmenu.png'
self.adj_file = var.assetsDir + 'Button_adj.png'
self.cancel_file = var.assetsDir + 'Button_cancel.png'
self.play_txt = "Play/ Spielen/ Jugar"
self.menu_txt = "Info/ Angabe/ Info"
self.cancel_text = "Exit/ Ausgang/ Salir"
self.adj_txt = "Settings/ Wahl/ Configuracion"
self.backMusicFile = var.assetsDir + 'sounds/732704_Otravine_chop.wav'
# device.audio.play_music()
def run(self):
mapsback = sp.Sprite2()
mapsback.file = self.backfile
mapsback.w = df.display_width
mapsback.h = df.display_height
mapsback.set_image()
mapsback.rect.x = 0
mapsback.rect.y = 0
playBtn = btns.Button(self.play_file, df.display_width*0.2, df.display_height*0.8,50,50)
playBtn.hover_text = self.play_txt
infoBtn = btns.Button(self.menu_file, df.display_width*0.4, df.display_height*0.8,50,50)
infoBtn.hover_text = self.menu_txt
setBtn = btns.Button(self.adj_file, df.display_width*0.6, df.display_height*0.8,50,50)
setBtn.hover_text = self.adj_txt
canBtn = btns.Button(self.cancel_file, df.display_width*0.8, df.display_height*0.8,50,50)
canBtn.hover_text = self.cancel_text
self.loadMusic()
self.playBackMusic()
while not self.stopEngine:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.stopEngine = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
self.stopEngine = True
var.gameDisplay.fill( df.white )
self.draw_sprite2(mapsback)
if playBtn.onClick(pygame.mouse):
imp.reload(map)
time.sleep(0.1)
mapsScreen = map.AddScreen()
mapsScreen.run()
self.loadMusic()
self.playBackMusic()
if infoBtn.onClick(pygame.mouse):
imp.reload(info)
time.sleep(0.1)
infoScreen = info.AddScreen()
infoScreen.run()
self.loadMusic()
self.playBackMusic()
if canBtn.onClick(pygame.mouse):
self.stopEngine = True
break
if setBtn.onClick(pygame.mouse):
imp.reload(adjustments)
adjScreen = adjustments.AddScreen()
time.sleep(0.1)
adjScreen.run()
self.loadMusic()
self.playBackMusic()
pygame.display.update()
var.clock.tick(var.fps)