Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2014-02-09 03:22:11 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2014-02-09 03:22:11 (GMT)
commitf6cf2680baca971c98c597711aae1c2ffd9f479b (patch)
treed71fd4899d680aaac43fd84008eca9bcb45fd5b1
parent9ee38995928416569826257ef489de8519d8b00e (diff)
add help to a1g4
-rw-r--r--src/assets/data/area1game4_data.py2
-rw-r--r--src/game/Area1Game4.py226
2 files changed, 162 insertions, 66 deletions
diff --git a/src/assets/data/area1game4_data.py b/src/assets/data/area1game4_data.py
index a6b3cc8..29ce592 100644
--- a/src/assets/data/area1game4_data.py
+++ b/src/assets/data/area1game4_data.py
@@ -2,6 +2,8 @@
from gettext import gettext as _
+HELP = _('Selecciona la palabra que se\ncorresponda con la definicón')
+
ITEMS = {
0: (_('pérdida de sangre\npor la vagina , que ocurre\naproximadamente cada\n28 dias'), _('menstruación')),
1: (_('hormona femenina'), _('estrógeno')),
diff --git a/src/game/Area1Game4.py b/src/game/Area1Game4.py
index 49498c0..5d1e696 100644
--- a/src/game/Area1Game4.py
+++ b/src/game/Area1Game4.py
@@ -19,6 +19,12 @@ STATE_ANSWER = 1
STATE_ANIM = 2
TIME_ANIM = 60
+OVER_COLOR = (255, 0, 0)
+NORMAL_COLOR = (255, 125, 50)
+
+GOODS = 6
+BADS = 3
+
class CArea1Game4(CGameState):
def __init__(self):
@@ -34,11 +40,21 @@ class CArea1Game4(CGameState):
self.mButtonList = []
self.mBad = 0
self.mGood = 0
+ self.mBBsetted = False
+ self.mNBsetted = True
+ self.mBHsetted = False
+ self.mNHsetted = True
+
+ self.mAlphaSet = True
+ self.mHelpShowed = True
+
+ self.mDialog = None
self.mPoints = CPoints(250, 10)
CGame().addChild(self.mPoints)
font26 = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 26)
+ font28 = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
for i in area1game4_data.ITEMS.keys():
t = area1game4_data.ITEMS[i]
@@ -77,6 +93,15 @@ class CArea1Game4(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.mButtonList[0].set_center((350, 550))
self.mButtonList[1].set_center((600, 550))
self.mButtonList[2].set_center((850, 550))
@@ -94,89 +119,158 @@ class CArea1Game4(CGameState):
self.mLabelQuestion.set_size((380, 150))
self.mLabelQuestion.set_text(self.mQuestions[self.mQuestionsL[self.mCurrentQuestion]][0])
CGame().addChild(self.mLabelQuestion)
-
- t = unicode(_('Última pregunta'), 'UTF-8')
- self.mLabelEnd = Globe((400, 100), pico='None', text=t)
- self.mLabelEnd.set_center((600, 400))
+
+ 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 = area1game4_data.HELP
+ self.mInstructions = Globe((450, 150), text=unicode(msg, 'UTF-8'), pico=None)
+ self.mInstructions.set_center((600, 300))
+ CGame().addChild(self.mInstructions)
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():
- hs = HallState.CHallState()
- CGame().setState(hs)
- hs.setCurrentGame(3)
- return
-
- if self.mLocalState == STATE_ANSWER:
- answer = -1
- for i in range(6):
- b = self.mButtonList[i]
- if b.clicked():
- answer = i
- break
-
- if not(answer == -1):
- n = -1
- if self.mCurrentQuestion < 6:
- n = self.mQuestionsL[self.mCurrentQuestion]
- if (answer == n):
- b = self.mButtonList[answer]
- b.mclicked = False
- CGame().removeChild(b)
- self.mGood = self.mGood + 1
- self.mPoints.set_goods(self.mGood)
- CGame().addChild(self.mGoodSprite)
- else:
- self.mBad = self.mBad + 1
- self.mPoints.set_bads(self.mBad)
- CGame().addChild(self.mBadSprite)
- self.mLocalState = STATE_ANIM
-
- #else:
- #print 'fin preguntas'
+ if not(self.mAlphaSet):
+
+ 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)
+
+ if self.mButtonBack.clicked():
+ hs = HallState.CHallState()
+ CGame().setState(hs)
+ hs.setCurrentGame(3)
+ return
+
+ 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.mLocalState == STATE_ANSWER:
+ answer = -1
+ for i in range(6):
+ b = self.mButtonList[i]
+ if b.clicked():
+ answer = i
+ break
+
+ if not(answer == -1):
+ n = -1
+ if self.mCurrentQuestion < 6:
+ n = self.mQuestionsL[self.mCurrentQuestion]
+ if (answer == n):
+ b = self.mButtonList[answer]
+ b.mclicked = False
+ CGame().removeChild(b)
+ self.mGood = self.mGood + 1
+ self.mPoints.set_goods(self.mGood)
+ CGame().addChild(self.mGoodSprite)
+ else:
+ self.mBad = self.mBad + 1
+ self.mPoints.set_bads(self.mBad)
+ CGame().addChild(self.mBadSprite)
+ self.mLocalState = STATE_ANIM
+
+ elif self.mLocalState == STATE_ANIM:
+ self.mAnimCounter = self.mAnimCounter + 1
+ if self.mAnimCounter > TIME_ANIM:
+ self.mAnimCounter = 0
+ CGame().removeChild(self.mGoodSprite)
+ CGame().removeChild(self.mBadSprite)
+ self.mLocalState = STATE_ANSWER
+ self.mCurrentQuestion = self.mCurrentQuestion + 1
+ #print 'estado de preguntas', self.mCurrentQuestion
+ if not(self.mCurrentQuestion == 6):
+ self.mLabelQuestion.set_text(self.mQuestions[self.mQuestionsL[self.mCurrentQuestion]][0])
+
+ if (self.mCurrentQuestion == 6) or (self.mGood == GOODS) or (self.mBad > BADS):
+ CGame().removeChild(self.mBook)
+ CGame().removeChild(self.mLabelQuestion)
+
+ self.mAlphaSet = True
+ CGame().addChild(self.mAlpha)
+ msg = _('Has terminado con %s respuestas bien') % self.mGood
+ self.mDialog = Globe((450, 100), text=unicode(msg, 'UTF-8'), pico=None)
+ self.mDialog.set_center((600, 300))
+ CGame().addChild(self.mDialog)
+ CGame().addChild(self.mButtonAccept)
+
else:
- self.mAnimCounter = self.mAnimCounter + 1
- if self.mAnimCounter > TIME_ANIM:
- self.mAnimCounter = 0
- CGame().removeChild(self.mGoodSprite)
- CGame().removeChild(self.mBadSprite)
- self.mLocalState = STATE_ANSWER
- self.mCurrentQuestion = self.mCurrentQuestion + 1
- #print 'estado de preguntas', self.mCurrentQuestion
- if not(self.mCurrentQuestion == 6):
- self.mLabelQuestion.set_text(self.mQuestions[self.mQuestionsL[self.mCurrentQuestion]][0])
+ 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:
- CGame().addChild(self.mLabelEnd)
- CGame().removeChild(self.mBook)
- CGame().removeChild(self.mLabelQuestion)
- #print 'ultima'
+ hs = HallState.CHallState()
+ CGame().setState(hs)
+ hs.setCurrentGame(3)
+ return
def destroy(self):
CGameState.destroy(self)
-
+ CGame().removeChild(self.mButtonHelp)
CGame().removeChild(self.mButtonBack)
CGame().removeChild(self.mLabelQuestion)
CGame().removeChild(self.mPoints)
CGame().removeChild(self.mBook)
CGame().removeChild(self.mGoodSprite)
CGame().removeChild(self.mBadSprite)
- CGame().removeChild(self.mLabelEnd)
+ CGame().removeChild(self.mAlpha)
+ CGame().removeChild(self.mInstructions)
+ CGame().removeChild(self.mButtonAccept)
+ CGame().removeChild(self.mDialog)
self.mButtonBackA1G4 = None
self.mBackground = None
self.mLabelDefinition = None