Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2012-03-19 03:31:32 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2012-03-19 03:31:32 (GMT)
commit26db84a0bbd700a0007782cfd3f4cd059e480417 (patch)
tree76d0d67cc00a6d3f61e9d115e23d6c75b7eb6bc7
parent37af9a7c9cf93221eaa37ca7acc786ac5d1b7bb4 (diff)
make generator of new questions
-rwxr-xr-xsrc/states/Area1Game3.py121
1 files changed, 117 insertions, 4 deletions
diff --git a/src/states/Area1Game3.py b/src/states/Area1Game3.py
index 4e63984..3471e4b 100755
--- a/src/states/Area1Game3.py
+++ b/src/states/Area1Game3.py
@@ -1,5 +1,7 @@
+# -*- coding: utf-8 -*-
import pygame
+import random
import api.Game
from api.Game import CGame
@@ -13,6 +15,9 @@ from api.Button import CButton
import MenuState
from MenuState import *
+import api.Label
+from api.Label import CLabel
+
import sys
sys.path.insert(0, 'assets/data')
@@ -24,19 +29,74 @@ class CArea1Game3(CGameState):
mInstructions = None
mButtonBack = None
+ mLabelTitle = None
+ mLabelQuestion = None
+ mButtonTrue = None
+ mButtonFalse = None
+
+ mActualQuestionN = None
+ mTupleQuestion = None
+
+ mboy_list = []
+ mgirl_list = []
def init(self):
CGameState.init(self)
+ # get a list of the keys of dict BOY and GIRL
+ self.mboy_list = area1game3_data.BOY.keys()
+ self.mgirl_list = area1game3_data.GIRL.keys()
+
+ # randomize it
+ random.shuffle(self.mboy_list)
+ random.shuffle(self.mgirl_list)
+
+ self.mActualQuestionN = self.mboy_list.pop()
+
self.mButtonBack = CButton()
- #TODO: Create a function to create image.
self.mButtonBack.set_bgColor((0x99, 0x99, 0x66))
self.mButtonBack.font = pygame.font.Font('assets/fonts/fipps.ttf', 20)
- self.mButtonBack.setCenter((110, 650))
+ self.mButtonBack.set_center((110, 650))
self.mButtonBack.set_size((200, 40))
self.mButtonBack.set_text('Volver')
CGame().addChild(self.mButtonBack)
+ self.mLabelTitle = CLabel()
+ self.mLabelTitle.set_bgColor((0x99, 0x50, 0x50))
+ self.mLabelTitle.font = pygame.font.Font('assets/fonts/fipps.ttf', 15)
+ self.mLabelTitle.set_center((600, 100))
+ self.mLabelTitle.set_size((800, 40))
+ self.mLabelTitle.set_text('Cuando un niño se desarrolla pasan las siguientes cosas:')
+ CGame().addChild(self.mLabelTitle)
+
+ self.mTupleQuestion = area1game3_data.BOY[self.mActualQuestionN]
+
+ self.mLabelQuestion = CLabel()
+ self.mLabelQuestion.set_bgColor((0x99, 0x50, 0x99))
+ self.mLabelQuestion.font = pygame.font.Font('assets/fonts/fipps.ttf', 13)
+ self.mLabelQuestion.set_center((600, 200))
+ self.mLabelQuestion.set_size((800, 40))
+ self.mLabelQuestion.set_text(self.mTupleQuestion[0])
+ CGame().addChild(self.mLabelQuestion)
+
+ self.mButtonTrue = CButton()
+ self.mButtonTrue.set_bgColor((0x99, 0x99, 0x66))
+ self.mButtonTrue.font = pygame.font.Font('assets/fonts/fipps.ttf', 20)
+ self.mButtonTrue.set_center((460, 300))
+ self.mButtonTrue.set_size((200, 40))
+ self.mButtonTrue.set_text('Verdadero')
+ CGame().addChild(self.mButtonTrue)
+
+ self.mButtonFalse = CButton()
+ self.mButtonFalse.set_bgColor((0x99, 0x99, 0x66))
+ self.mButtonFalse.font = pygame.font.Font('assets/fonts/fipps.ttf', 20)
+ self.mButtonFalse.set_center((740, 300))
+ self.mButtonFalse.set_size((200, 40))
+ self.mButtonFalse.set_text('Falso')
+ CGame().addChild(self.mButtonFalse)
+
+
+
def update(self):
CGameState.update(self)
@@ -45,11 +105,64 @@ class CArea1Game3(CGameState):
#cs = CHelpState()
ms = MenuState.CMenuState()
CGame().setState(ms)
-
+ elif self.mButtonTrue.clicked():
+ print 'button true'
+ #self.mActualQuestionN
+ #self.mTupleQuestion = area1game3_data.BOY[self.mActualQuestionN]
+ if self.mTupleQuestion[1] == True:
+ print 'correct answer'
+ res = self.next_question()
+ if not res:
+ print 'finalizado'
+ else:
+ print 'incorrect answer'
+
+ elif self.mButtonFalse.clicked():
+ print 'button false'
+ #self.mActualQuestionN
+ #self.mTupleQuestion = area1game3_data.BOY[self.mActualQuestionN]
+ if self.mTupleQuestion[1] == False:
+ print 'correct answer'
+ res = self.next_question()
+ if not res:
+ print 'finalizado'
+ else:
+ print 'incorrect answer'
+
+ def next_question(self):
+ if not(self.mboy_list == []):
+ self.mActualQuestionN = self.mboy_list.pop()
+ self.mTupleQuestion = area1game3_data.BOY[self.mActualQuestionN]
+ self.update_question()
+ return True
+ else:
+ self.update_title()
+ if not(self.mgirl_list == []):
+ self.mActualQuestionN = self.mgirl_list.pop()
+ self.mTupleQuestion = area1game3_data.BOY[self.mActualQuestionN]
+ self.update_question()
+ return True
+ else:
+ return False
+
+ def update_question(self):
+ self.mLabelQuestion.set_text(self.mTupleQuestion[0])
+
+ def update_title(self):
+ self.mLabelTitle.set_text('Cuando un niña se desarrolla pasan las siguientes cosas:')
def destroy(self):
CGameState.destroy(self)
#self.mInstructions.destroy()
self.mInstructions = None
CGame().removeChild(self.mButtonBack)
- self.mButtonBack = None \ No newline at end of file
+ CGame().removeChild(self.mLabelTitle)
+ CGame().removeChild(self.mLabelQuestion)
+ CGame().removeChild(self.mButtonTrue)
+ CGame().removeChild(self.mButtonFalse)
+ self.mLabelQuestion = None
+ self.mLabelTitle = None
+ self.mButtonTrue = None
+ self.mButtonFalse = None
+ self.mButtonBack = None
+ \ No newline at end of file