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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# -*- coding: utf-8 -*-
import pygame
from api.GameState import CGameState
from api.Game import CGame
from api.Button import CButton
from CreditsState import CCreditsState
import api.Image as Image
from game.PresentationState import CPresentationState
from game.SelectPartidaState import CSelectPartidaState
from gettext import gettext as _
OVER_COLOR = (255, 0, 0)
NORMAL_COLOR = (255, 125, 50)
class CMenuState(CGameState):
def init(self):
CGameState.__init__(self)
self.mBackground = Image.loadImage('assets/images/selectArea/background.jpg', False)
CGame().setBackground(self.mBackground)
self.mButtonPresentation = CButton()
self.mButtonPresentation.bgColor = (0x99, 0x99, 0x66)
self.mButtonPresentation.fgColor = (0xFF, 0xFF, 0xFF)
self.mButtonPresentation.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
self.mButtonPresentation.set_center((200, 100))
self.mButtonPresentation.set_size((200, 40))
self.mButtonPresentation.set_text(unicode(_('Presentacion'), 'UTF-8'))
CGame().addChild(self.mButtonPresentation)
self.mButtonPlay = CButton()
self.mButtonPlay.bgColor = NORMAL_COLOR
self.mButtonPlay.fgColor = (0xFF, 0xFF, 0xFF)
self.mButtonPlay.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 32)
self.mButtonPlay.set_center((600, 370))
self.mButtonPlay.set_size((200, 40))
self.mButtonPlay.set_text(unicode(_('Jugar'), 'UTF-8'))
CGame().addChild(self.mButtonPlay)
self.mButtonCredits = CButton()
self.mButtonCredits.bgColor = NORMAL_COLOR
self.mButtonCredits.fgColor = (0xFF, 0xFF, 0xFF)
self.mButtonCredits.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 32)
self.mButtonCredits.set_center((600, 420))
self.mButtonCredits.set_size((200, 40))
self.mButtonCredits.set_text(unicode(_('Créditos'), 'UTF-8'))
CGame().addChild(self.mButtonCredits)
self.mButtonHelp = CButton()
self.mButtonHelp.bgColor = NORMAL_COLOR
self.mButtonHelp.fgColor = (0xFF, 0xFF, 0xFF)
self.mButtonHelp.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 32)
self.mButtonHelp.set_center((600, 470))
self.mButtonHelp.set_size((200, 40))
self.mButtonHelp.set_text(unicode(_('Ayuda'), 'UTF-8'))
CGame().addChild(self.mButtonHelp)
self.mButtonExit = CButton()
self.mButtonExit.bgColor = NORMAL_COLOR
self.mButtonExit.fgColor = (0xFF, 0xFF, 0xFF)
self.mButtonExit.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 32)
self.mButtonExit.set_center((600, 520))
self.mButtonExit.set_size((200, 40))
self.mButtonExit.set_text(unicode(_('Salir'), 'UTF-8'))
CGame().addChild(self.mButtonExit)
def update(self):
#print "menu update"
CGameState.update(self)
if self.mButtonPlay.mouseOver():
self.mButtonPlay.set_bgColor(OVER_COLOR)
else:
self.mButtonPlay.set_bgColor(NORMAL_COLOR)
if self.mButtonCredits.mouseOver():
self.mButtonCredits.set_bgColor(OVER_COLOR)
else:
self.mButtonCredits.set_bgColor(NORMAL_COLOR)
if self.mButtonHelp.mouseOver():
self.mButtonHelp.set_bgColor(OVER_COLOR)
else:
self.mButtonHelp.set_bgColor(NORMAL_COLOR)
if self.mButtonExit.mouseOver():
self.mButtonExit.set_bgColor(OVER_COLOR)
else:
self.mButtonExit.set_bgColor(NORMAL_COLOR)
if self.mButtonCredits.clicked():
print "clicked credits"
#cs = CHelpState()
cs = CCreditsState()
CGame().setState(cs)
return
elif self.mButtonPresentation.clicked():
print "clicked presentation"
presentation = CPresentationState()
CGame().setState(presentation)
return
elif self.mButtonPlay.clicked():
print "clicked play"
partida = CSelectPartidaState()
CGame().setState(partida)
return
elif self.mButtonHelp.clicked():
print "clicked help"
#cs = CHelpState()
hp = CCreditsState()
CGame().setState(hp)
return
elif self.mButtonExit.clicked():
print 'exit'
CGame().destroy()
exit()
def destroy(self):
CGameState.destroy(self)
CGame().removeChild(self.mButtonCredits)
CGame().removeChild(self.mButtonPresentation)
CGame().removeChild(self.mButtonPlay)
CGame().removeChild(self.mButtonHelp)
CGame().removeChild(self.mButtonExit)
self.mButtonCredits = None
self.mButtonPlay = None
self.mButtonExit = None
self.mButtonExit = None
|