Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/game/SelectPartidaState.py
blob: 8164b7e3493092d2c4c28dd794b52232e373a30c (plain)
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
141
142
143
144
145
146
147
148
149
# -*- coding: utf-8 -*-

import pygame
import MenuState
import api.GameState
from api.GameState import CGameState
from api.MultiLabel import CMultiLabel
from api.Label import CLabel
import api.Game
from api.Game import CGame
from api.Button import CButton
from api.Sprite2 import CSprite

from SelectCharacterState import CSelectCharacterState

import api.Image as Image

from gettext import gettext as _

class CSelectPartidaState(CGameState):
    
    mBackground = None


    def init(self):
        CGameState.__init__(self)
        
        self.mBackground = Image.loadImage('assets/images/selectPartida/background.png', False)
        CGame().setBackground(self.mBackground)

        recuadro = Image.loadImage('assets/images/selectPartida/recuadro.png')
        self.mPartida1 = CSprite()
        self.mPartida1.setXY(100, 240)
        self.mPartida1.setImage(recuadro)
        CGame().addChild(self.mPartida1)
        
        border = Image.loadImage('assets/images/selectPartida/recuadro-interno.png')
        self.mBorderPartida1 = CSprite()
        self.mBorderPartida1.setXY(100, 240)
        self.mBorderPartida1.setImage(border)
        self.mPartida1Is = False
        
        self.mPartida2 = CSprite()
        self.mPartida2.setXY(450, 240)
        self.mPartida2.setImage(recuadro)
        CGame().addChild(self.mPartida2)
        
        self.mBorderPartida2 = CSprite()
        self.mBorderPartida2.setXY(450, 240)
        self.mBorderPartida2.setImage(border)
        self.mPartida2Is = False
        
        self.mPartida3 = CSprite()
        self.mPartida3.setXY(800, 240)
        self.mPartida3.setImage(recuadro)
        CGame().addChild(self.mPartida3)
        
        self.mBorderPartida3 = CSprite()
        self.mBorderPartida3.setXY(800, 240)
        self.mBorderPartida3.setImage(border)
        self.mPartida3Is = False
                
        mes = _('Selecciona una partida')
        self.mMessage = CLabel()
        self.mMessage.bgColor = (255, 125, 50)
        self.mMessage.fgColor = (0xFF, 0xFF, 0xFF)
        self.mMessage.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
        self.mMessage.set_center((600, 150))
        self.mMessage.set_size((400, 40))
        self.mMessage.set_text(unicode(mes, 'UTF-8'))
        CGame().addChild(self.mMessage)
        
       
    def update(self):
        #print "menu update"
        CGameState.update(self)

        if self.mPartida1.clicked():
            print "partida 1"
            ch = CSelectCharacterState()
            CGame().setState(ch)
            return
            
        elif self.mPartida2.clicked():
            print "partida 2"
            ch = CSelectCharacterState()
            CGame().setState(ch)
            return
        
        elif self.mPartida3.clicked():
            print "partida 3"
            ch = CSelectCharacterState()
            CGame().setState(ch)
            return
        
        if self.mPartida1.mouseOver():
            if not(self.mPartida1Is):
                self.mPartida1Is = True
                CGame().addChild(self.mBorderPartida1)
                return
        else:
            if self.mPartida1Is:
                self.mPartida1Is = False
                CGame().removeChild(self.mBorderPartida1)
                return
            
        if self.mPartida2.mouseOver():
            if not(self.mPartida2Is):
                self.mPartida2Is = True
                CGame().addChild(self.mBorderPartida2)
                return
        else:
            if self.mPartida2Is:
                self.mPartida2Is = False
                CGame().removeChild(self.mBorderPartida2)
                return
        
        if self.mPartida3.mouseOver():
            if not(self.mPartida3Is):
                self.mPartida3Is = True
                CGame().addChild(self.mBorderPartida3)
                return
        else:
            if self.mPartida3Is:
                self.mPartida3Is = False
                CGame().removeChild(self.mBorderPartida3)
                return

    def destroy(self):
        CGameState.destroy(self)

        CGame().removeChild(self.mMessage)
        self.mMessage = None
        
        CGame().removeChild(self.mPartida1)
        self.mPartida1 = None
        CGame().removeChild(self.mBorderPartida1)
        self.mBorderPartida1 = None
        CGame().removeChild(self.mPartida2)
        self.mPartida2 = None
        CGame().removeChild(self.mBorderPartida2)
        self.mBorderPartida2 = None
        CGame().removeChild(self.mPartida3)
        self.mPartida3 = None
        CGame().removeChild(self.mBorderPartida3)
        self.mBorderPartida3 = None
        
        self.mBackground = None
        print "CMenuState destroy"