diff options
author | Alan Aguiar <alanjas@hotmail.com> | 2014-02-09 02:58:54 (GMT) |
---|---|---|
committer | Alan Aguiar <alanjas@hotmail.com> | 2014-02-09 02:58:54 (GMT) |
commit | 9ee38995928416569826257ef489de8519d8b00e (patch) | |
tree | bf655254381cfd088a6cb247d6b21dce8a05dc0a /src | |
parent | 5a89c7d9cd6abdccdcd0369d95c966eb9afbcab4 (diff) |
end a1g3 with dialog
Diffstat (limited to 'src')
-rw-r--r-- | src/assets/data/area1game3_data.py | 2 | ||||
-rw-r--r-- | src/game/Area1Game3.py | 326 |
2 files changed, 217 insertions, 111 deletions
diff --git a/src/assets/data/area1game3_data.py b/src/assets/data/area1game3_data.py index 0f53e48..1cbe878 100644 --- a/src/assets/data/area1game3_data.py +++ b/src/assets/data/area1game3_data.py @@ -3,6 +3,8 @@ from gettext import gettext as _ +HELP = _('Ayuda a Elisa a\ncontestar las preguntas de Juan') + DIALOG = [ _('Sabés que pasa\ncuando un chico\nse desarrolla?'), _('mmm... no...'), diff --git a/src/game/Area1Game3.py b/src/game/Area1Game3.py index 8370d94..40ee9fc 100644 --- a/src/game/Area1Game3.py +++ b/src/game/Area1Game3.py @@ -17,6 +17,9 @@ from assets.data import area1game3_data OVER_COLOR = (255, 0, 0) NORMAL_COLOR = (255, 125, 50) +GOODS = 8 +BADS = 4 + class CArea1Game3(CGameState): @@ -24,7 +27,6 @@ class CArea1Game3(CGameState): CGameState.__init__(self) self.mBackground = None - self.mButtonBack = None self.mLabelQuestion = None self.mButtonTrue = None @@ -38,10 +40,13 @@ class CArea1Game3(CGameState): self.mDialogBad = None self.mActualQuestionN = None self.mTupleQuestion = None + self.mEndDialog = None self.mQuestionAnswered = False self.mQuestionShowed = False self.mQuestionCorrect = False self.mActiveDialog = None + self.mAlphaSet = True + self.mHelpShowed = True self.mboy_list = [] self.mgirl_list = [] self.mCurrentState = 0 @@ -67,9 +72,9 @@ class CArea1Game3(CGameState): q = (unicode(t[0], 'UTF-8'), t[1]) self.mGirlDict[i] = q - self.mDialog = [] + self.mCharDialog = [] for e in area1game3_data.DIALOG: - self.mDialog.append(unicode(e, 'UTF-8')) + self.mCharDialog.append(unicode(e, 'UTF-8')) self.mInitB = unicode(area1game3_data.INITB, 'UTF-8') self.mInitG = unicode(area1game3_data.INITG, 'UTF-8') @@ -79,9 +84,11 @@ class CArea1Game3(CGameState): # randomize it random.shuffle(self.mboy_list) random.shuffle(self.mgirl_list) - - self.mBsetted = False - self.mNsetted = True + + self.mBBsetted = False + self.mNBsetted = True + self.mBHsetted = False + self.mNHsetted = True self.mBackImageN = Image.loadImage('assets/images/back.png') self.mBackImageB = Image.loadImage('assets/images/back_big.png') @@ -91,6 +98,16 @@ class CArea1Game3(CGameState): self.mButtonBack.setImage(self.mBackImageN) CGame().addChild(self.mButtonBack) + + # help button + self.mHelpImageN = Image.loadImage('assets/images/help.png') + self.mHelpImageB = Image.loadImage('assets/images/help_big.png') + + self.mButtonHelp = CSprite(1110, 30) + self.mButtonHelp.setRegistrationPointOffset(22, 22) + self.mButtonHelp.setImage(self.mHelpImageN) + CGame().addChild(self.mButtonHelp) + self.mLabelQuestion = Globe((500, 250), pico='None', text=' ') self.mLabelQuestion.set_center((600, 250)) @@ -119,7 +136,6 @@ class CArea1Game3(CGameState): self.mButtonNext.center = (600, 500) self.mButtonNext.size = (200, 40) self.mButtonNext.set_text(_('Siguiente')) - CGame().addChild(self.mButtonNext) self.mBoy = CSprite(100, 400) self.mBoy.loadImage('assets/images/a1g3/Juan-chico-costado-parado.png') @@ -132,16 +148,15 @@ class CArea1Game3(CGameState): CGame().addChild(self.mGirl) # sabes que le pasa - self.mDialogBoy1 = Globe((300, 170), text=self.mDialog[0]) + self.mDialogBoy1 = Globe((300, 170), text=self.mCharDialog[0]) self.mDialogBoy1.set_center((300, 300)) - CGame().addChild(self.mDialogBoy1) # mmm.. no... - self.mDialogGirl1 = Globe((200, 100), pico='right', text=self.mDialog[1]) + self.mDialogGirl1 = Globe((200, 100), pico='right', text=self.mCharDialog[1]) self.mDialogGirl1.set_center((900, 300)) # a ver.. - self.mDialogBoy2 = Globe((200, 100), pico='left', text=self.mDialog[2]) + self.mDialogBoy2 = Globe((200, 100), pico='left', text=self.mCharDialog[2]) self.mDialogBoy2.set_center((300, 300)) self.mDialogGood = Globe((200, 75), pico='left', text=self.mGoodA) @@ -153,119 +168,198 @@ class CArea1Game3(CGameState): self.mPoints = CPoints(250, 10) CGame().addChild(self.mPoints) + alphasurface = pygame.Surface((1200,900)) + alphasurface.convert() + alphasurface.fill((100,100,100)) + alphasurface.set_alpha(200) + + self.mAlpha = CSprite(0, 0) + self.mAlpha.setImage(alphasurface) + CGame().addChild(self.mAlpha) + + self.mButtonAccept = CButton() + self.mButtonAccept.bgColor = NORMAL_COLOR + self.mButtonAccept.font = font28 + self.mButtonAccept.center = (600, 400) + self.mButtonAccept.size = (200, 40) + self.mButtonAccept.set_text(_('Aceptar')) + CGame().addChild(self.mButtonAccept) + + msg = area1game3_data.HELP + self.mInstructions = Globe((450, 150), text=unicode(msg, 'UTF-8'), pico=None) + self.mInstructions.set_center((600, 300)) + CGame().addChild(self.mInstructions) + self.mCurrentState = 0 self.time = 0 def update(self): CGameState.update(self) - if self.mButtonBack.mouseOver(): - if not(self.mBsetted): - self.mBsetted = True - self.mNsetted = False - self.mButtonBack.setRegistrationPointOffset(27, 27) - self.mButtonBack.setImage(self.mBackImageB) - else: - if not(self.mNsetted): - self.mBsetted = False - self.mNSetted = True - self.mButtonBack.setRegistrationPointOffset(22, 22) - self.mButtonBack.setImage(self.mBackImageN) - - if self.mButtonBack.clicked(): - #print "clicked back of a1g3" - hs = HallState.CHallState() - CGame().setState(hs) - hs.setCurrentGame(2) - return - - if self.mCurrentState < 4: - if self.mButtonNext.mouseOver(): - self.mButtonNext.set_bgColor(OVER_COLOR) - else: - self.mButtonNext.set_bgColor(NORMAL_COLOR) + if not(self.mAlphaSet): - if self.mButtonNext.clicked(): - self.mCurrentState = self.mCurrentState + 1 - - if self.mCurrentState == 1: - CGame().removeChild(self.mDialogBoy1) - CGame().addChild(self.mDialogGirl1) - - elif self.mCurrentState == 2: - CGame().removeChild(self.mDialogGirl1) - CGame().addChild(self.mDialogBoy2) - - elif self.mCurrentState == 3: - CGame().removeChild(self.mDialogBoy2) - self.mCurrentState = 4 - CGame().removeChild(self.mButtonNext) + if self.mButtonBack.mouseOver(): + if not(self.mBBsetted): + self.mBBsetted = True + self.mNBsetted = False + self.mButtonBack.setRegistrationPointOffset(27, 27) + self.mButtonBack.setImage(self.mBackImageB) + else: + if not(self.mNBsetted): + self.mBBsetted = False + self.mNBSetted = True + self.mButtonBack.setRegistrationPointOffset(22, 22) + self.mButtonBack.setImage(self.mBackImageN) + + if self.mButtonHelp.mouseOver(): + if not(self.mBHsetted): + self.mBHsetted = True + self.mNHsetted = False + self.mButtonHelp.setRegistrationPointOffset(27, 27) + self.mButtonHelp.setImage(self.mHelpImageB) + else: + if not(self.mNHsetted): + self.mBHsetted = False + self.mNHSetted = True + self.mButtonHelp.setRegistrationPointOffset(22, 22) + self.mButtonHelp.setImage(self.mHelpImageN) - # Pregunta - elif self.mCurrentState == 4: - self.time = self.time + 1 + if self.mButtonBack.clicked(): + #print "clicked back of a1g3" + hs = HallState.CHallState() + CGame().setState(hs) + hs.setCurrentGame(2) + return - if self.mQuestionShowed == False: - if self.next_questionB(): - CGame().addChild(self.mLabelQuestion) - CGame().addChild(self.mButtonTrue) - CGame().addChild(self.mButtonFalse) - self.mQuestionShowed = True - else: - self.mCurrentState = 5 + if self.mButtonHelp.clicked(): + self.mAlphaSet = True + self.mHelpShowed = True + CGame().addChild(self.mAlpha) + CGame().addChild(self.mInstructions) + CGame().addChild(self.mButtonAccept) + return + if self.mCurrentState == 0: + CGame().addChild(self.mDialogBoy1) + CGame().addChild(self.mButtonNext) + self.mCurrentState = 1 - elif (self.mQuestionAnswered == False): - if self.mButtonTrue.mouseOver(): - self.mButtonTrue.set_bgColor(OVER_COLOR) - else: - self.mButtonTrue.set_bgColor(NORMAL_COLOR) - - if self.mButtonFalse.mouseOver(): - self.mButtonFalse.set_bgColor(OVER_COLOR) + if self.mCurrentState < 5: + if self.mButtonNext.mouseOver(): + self.mButtonNext.set_bgColor(OVER_COLOR) else: - self.mButtonFalse.set_bgColor(NORMAL_COLOR) - - if self.mButtonTrue.clicked(): - CGame().removeChild(self.mLabelQuestion) - CGame().removeChild(self.mButtonTrue) - CGame().removeChild(self.mButtonFalse) - self.mButtonTrue.set_bgColor(NORMAL_COLOR) - if self.mTupleQuestion[1] == True: - CGame().addChild(self.mDialogGood) - self.mGood = self.mGood + 1 - self.mPoints.set_goods(self.mGood) - else: - CGame().addChild(self.mDialogBad) - self.mBad = self.mBad + 1 - self.mPoints.set_bads(self.mBad) - self.mQuestionAnswered = True - self.time = 0 + self.mButtonNext.set_bgColor(NORMAL_COLOR) + + if self.mButtonNext.clicked(): + self.mCurrentState = self.mCurrentState + 1 + + if self.mCurrentState == 2: + CGame().removeChild(self.mDialogBoy1) + CGame().addChild(self.mDialogGirl1) + + elif self.mCurrentState == 3: + CGame().removeChild(self.mDialogGirl1) + CGame().addChild(self.mDialogBoy2) - elif self.mButtonFalse.clicked(): - CGame().removeChild(self.mLabelQuestion) - CGame().removeChild(self.mButtonTrue) - CGame().removeChild(self.mButtonFalse) - self.mButtonFalse.set_bgColor(NORMAL_COLOR) - if self.mTupleQuestion[1] == False: - CGame().addChild(self.mDialogGood) - self.mGood = self.mGood + 1 - self.mPoints.set_goods(self.mGood) + elif self.mCurrentState == 4: + CGame().removeChild(self.mDialogBoy2) + self.mCurrentState = 5 + CGame().removeChild(self.mButtonNext) + + # Pregunta + elif self.mCurrentState == 5: + self.time = self.time + 1 + + if self.mQuestionShowed == False: + if self.next_questionB(): + CGame().addChild(self.mLabelQuestion) + CGame().addChild(self.mButtonTrue) + CGame().addChild(self.mButtonFalse) + self.mQuestionShowed = True else: - CGame().addChild(self.mDialogBad) - self.mBad = self.mBad + 1 - self.mPoints.set_bads(self.mBad) - self.mQuestionAnswered = True - self.time = 0 - - elif self.mQuestionAnswered == True: - if self.time > 2*30: - CGame().removeChild(self.mDialogGood) - CGame().removeChild(self.mDialogBad) - self.mQuestionShowed = False - self.mQuestionAnswered = False - self.mActiveDialog = None + self.mCurrentState = 6 + elif (self.mQuestionAnswered == False): + if self.mButtonTrue.mouseOver(): + self.mButtonTrue.set_bgColor(OVER_COLOR) + else: + self.mButtonTrue.set_bgColor(NORMAL_COLOR) + + if self.mButtonFalse.mouseOver(): + self.mButtonFalse.set_bgColor(OVER_COLOR) + else: + self.mButtonFalse.set_bgColor(NORMAL_COLOR) + + if self.mButtonTrue.clicked(): + CGame().removeChild(self.mLabelQuestion) + CGame().removeChild(self.mButtonTrue) + CGame().removeChild(self.mButtonFalse) + self.mButtonTrue.set_bgColor(NORMAL_COLOR) + if self.mTupleQuestion[1] == True: + CGame().addChild(self.mDialogGood) + self.mGood = self.mGood + 1 + self.mPoints.set_goods(self.mGood) + else: + CGame().addChild(self.mDialogBad) + self.mBad = self.mBad + 1 + self.mPoints.set_bads(self.mBad) + self.mQuestionAnswered = True + self.time = 0 + + elif self.mButtonFalse.clicked(): + CGame().removeChild(self.mLabelQuestion) + CGame().removeChild(self.mButtonTrue) + CGame().removeChild(self.mButtonFalse) + self.mButtonFalse.set_bgColor(NORMAL_COLOR) + if self.mTupleQuestion[1] == False: + CGame().addChild(self.mDialogGood) + self.mGood = self.mGood + 1 + self.mPoints.set_goods(self.mGood) + else: + CGame().addChild(self.mDialogBad) + self.mBad = self.mBad + 1 + self.mPoints.set_bads(self.mBad) + self.mQuestionAnswered = True + self.time = 0 + + elif self.mQuestionAnswered == True: + if self.time > 2*30: + CGame().removeChild(self.mDialogGood) + CGame().removeChild(self.mDialogBad) + self.mQuestionShowed = False + self.mQuestionAnswered = False + self.mActiveDialog = None + if (self.mGood == GOODS) or (self.mBad > BADS): + self.mCurrentState = 6 + + elif self.mCurrentState == 6: + + self.mAlphaSet = True + CGame().addChild(self.mAlpha) + msg = _('Has terminado con %s respuestas bien') % self.mGood + self.mEndDialog = Globe((450, 100), text=unicode(msg, 'UTF-8'), pico=None) + self.mEndDialog.set_center((600, 300)) + CGame().addChild(self.mEndDialog) + CGame().addChild(self.mButtonAccept) + else: + if self.mButtonAccept.mouseOver(): + self.mButtonAccept.set_bgColor(OVER_COLOR) + else: + self.mButtonAccept.set_bgColor(NORMAL_COLOR) + + if self.mButtonAccept.clicked(): + if self.mHelpShowed: + self.mAlphaSet = False + self.mHelpShowed = False + self.mButtonAccept.set_bgColor(NORMAL_COLOR) + CGame().removeChild(self.mAlpha) + CGame().removeChild(self.mInstructions) + CGame().removeChild(self.mButtonAccept) + else: + hs = HallState.CHallState() + CGame().setState(hs) + hs.setCurrentGame(2) + return def next_questionB(self): if not(self.mboy_list == []): @@ -290,8 +384,9 @@ class CArea1Game3(CGameState): def destroy(self): CGameState.destroy(self) - + CGame().removeChild(self.mEndDialog) CGame().removeChild(self.mButtonBack) + CGame().removeChild(self.mButtonHelp) CGame().removeChild(self.mLabelQuestion) CGame().removeChild(self.mButtonTrue) CGame().removeChild(self.mButtonFalse) @@ -304,8 +399,13 @@ class CArea1Game3(CGameState): CGame().removeChild(self.mDialogGood) CGame().removeChild(self.mDialogBad) CGame().removeChild(self.mPoints) + CGame().removeChild(self.mAlpha) + CGame().removeChild(self.mInstructions) + CGame().removeChild(self.mButtonAccept) + - self.mButtonBackA1G3 = None + self.mButtonBack = None + self.mButtonHelp = None self.mLabelQuestion = None self.mButtonTrue = None self.mButtonFalse = None @@ -317,4 +417,8 @@ class CArea1Game3(CGameState): self.mDialogGood = None self.mDialogBad = None self.mPoints = None + self.mAlpha = None + self.mInstructions = None + self.mButtonAccept = None + self.mDialog = None
\ No newline at end of file |