forked from dhatch/PyRunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenuTest.py
60 lines (57 loc) · 1.49 KB
/
menuTest.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
import pygame
from pygame.locals import*
#import key names
from pygame.key import *
import os
import platform
import random
import sys
import math
from kezmenu import KezMenu
if platform.system() == 'Windows':
os.environ['SDL_VIDEODRIVER'] = 'windib'
pygame.init()
screen = None
endMenu = None
_debug = True
selected = None
clock = pygame.time.Clock()
def init():
#create screen
global screen
if(_debug):
screen = pygame.display.set_mode((600, 820))
else:
screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
def option(x):
global selected
selected = x
print "selected",x
def endMenu():
global selected
global endMenu
global clock
global screen
selected = None
endMenu = KezMenu(["Play Again", lambda: option(1)],
["Quit", lambda: option(2)])
endMenu.color = (255,255,255)
endMenu.focus_color = (0,255,0)
endMenu.enableEffect('enlarge-font-on-focus', font = None, size = 16, enlarge_factor = 2.)
while True:
time_passed = clock.tick() / 1000.
events = pygame.event.get()
endMenu.update(events,time_passed)
screen.fill((0,0,0,0))
endMenu.draw(screen)
pygame.display.update()
if selected is not None:
break
for x in events:
if x.type == KEYDOWN:
if x.dict["key"] == K_ESCAPE:
pygame.display.quit()
return
pygame.display.quit()
init()
endMenu()