Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/game/SelectCharacterState.py
blob: be3ae0212ed3da37291f872b439f0f93fedc8a44 (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
# -*- coding: utf-8 -*-

import pygame

from api.GameState import CGameState
from api.Label import CLabel
from api.Game import CGame
from api.Sprite2 import CSprite

from SelectAreaState import CSelectAreaState

import api.Image as Image

from gettext import gettext as _


class CSelectCharacterState(CGameState):
    
    mBackground = None

    def init(self):
        CGameState.__init__(self)
        
        self.mPartida = None
        
        self.mBackground = Image.loadImage('assets/images/selectArea/background.png', False)
        CGame().setBackground(self.mBackground)
        
        border = Image.loadImage('assets/images/selectPartida/border.png')
        
        self.mElisa = CSprite()
        #ancho = 216 -> 1200 - 216 - juan.X = 834
        self.mElisa.setXY(684, 250)
        elisa = Image.loadImage('assets/images/selectArea/T-elisa.png')
        self.mElisa.setImage(elisa)
        CGame().addChild(self.mElisa)
        
        self.mBorderElisa = CSprite()
        self.mBorderElisa.setXY(674, 240)
        self.mBorderElisa.setImage(border)
        self.mElisaIs = False
        
        self.mJuan = CSprite()
        self.mJuan.setXY(300, 250)
        juan = Image.loadImage('assets/images/selectArea/T-juan.png')
        self.mJuan.setImage(juan)
        CGame().addChild(self.mJuan)
        
        self.mBorderJuan = CSprite()
        self.mBorderJuan.setXY(290, 240)
        self.mBorderJuan.setImage(border)
        self.mJuanIs = False
                
        mes = _('Selecciona tu personaje')
        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 setPartida(self, aPartida):
        self.mPartida = aPartida
       
    def update(self):
        #print "menu update"
        CGameState.update(self)

        if self.mJuan.clicked():
            print "clicked Juan"
            CGame().setCharacter(self.mPartida, 'Juan')
            ms = CSelectAreaState()
            CGame().setState(ms)
            ms.setPartida(self.mPartida)
            return
        
        elif self.mElisa.clicked():
            print "clicked Elisa"
            CGame().setCharacter(self.mPartida, 'Elisa')
            ms = CSelectAreaState()
            CGame().setState(ms)
            ms.setPartida(self.mPartida)
            return
        
        if self.mJuan.mouseOver():
            if not(self.mJuanIs):
                self.mJuanIs = True
                CGame().addChild(self.mBorderJuan)
                return
        else:
            if self.mJuanIs:
                self.mJuanIs = False
                CGame().removeChild(self.mBorderJuan)
                return
       
        if self.mElisa.mouseOver():
            if not(self.mElisaIs):
                self.mElisaIs = True
                CGame().addChild(self.mBorderElisa)
                return
        else:
            if self.mElisaIs:
                self.mElisaIs = False
                CGame().removeChild(self.mBorderElisa)
                return

    def destroy(self):
        CGameState.destroy(self)
        CGame().removeChild(self.mElisa)
        CGame().removeChild(self.mBorderElisa)
        self.mElisa.destroy()
        self.mElisa = None
        CGame().removeChild(self.mJuan)
        CGame().removeChild(self.mBorderJuan)
        self.mJuan.destroy()
        self.mJuan = None
        CGame().removeChild(self.mMessage)
        self.mMessage = None
        self.mBackground = None
        print "CMenuState destroy"