Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/game
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2013-09-14 07:32:14 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2013-09-14 07:32:14 (GMT)
commitb4b5eb6a8b20b471b94f05f34deffe7b80c4379c (patch)
treecd76a3cb90b01e007c5c25c84500de2205da9316 /src/game
parent73110ef433590face714dc37cc07d37f6a1c7675 (diff)
add basic a1g5
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Area1Game5.py256
-rw-r--r--src/game/MenuState.py22
2 files changed, 275 insertions, 3 deletions
diff --git a/src/game/Area1Game5.py b/src/game/Area1Game5.py
new file mode 100644
index 0000000..241ef8b
--- /dev/null
+++ b/src/game/Area1Game5.py
@@ -0,0 +1,256 @@
+# -*- coding: utf-8 -*-
+
+import pygame
+import random
+import MenuState
+import api.Image as Image
+from api.Game import CGame
+from api.GameState import CGameState
+from api.Button import CButton
+from api.Sprite2 import CSprite
+from api.Points import CPoints
+from api.Globe import Globe
+from gettext import gettext as _
+
+from assets.data import area1game5_data
+
+
+class CArea1Game5(CGameState):
+
+ def __init__(self):
+ CGameState.__init__(self)
+
+ self.mBackground = None
+ self.mInstructions = None
+ self.mButtonBackA1G3 = None
+ self.mLabelQuestion = None
+ self.mButtonTrue = None
+ self.mButtonFalse = None
+ self.mBoy = None
+ self.mGirl = None
+ self.mDialogBoy1 = None
+ self.mDialogGirl1 = None
+ self.mDialogBoy2 = None
+ self.mDialogGood = None
+ self.mDialogBad = None
+ self.mActualQuestionN = None
+ self.mTupleQuestion = None
+ self.mQuestionAnswered = False
+ self.mQuestionShowed = False
+ self.mQuestionCorrect = False
+ self.mActiveDialog = None
+ self.mboy_list = []
+ self.mgirl_list = []
+ self.mCurrentState = 0
+ self.time = 0
+ self.mBad = 0
+ self.mGood = 0
+
+ self.mBackground = Image.loadImage('assets/images/a1g3/a1game3.png', False)
+ CGame().setBackground(self.mBackground)
+
+ # get a list of the keys of dict BOY and GIRL
+ self.mboy_list = area1game5_data.BOY.keys()
+ self.mBoyDict = {}
+ for i in self.mboy_list:
+ t = area1game5_data.BOY[i]
+ q = (unicode(t[0], 'UTF-8'), t[1])
+ self.mBoyDict[i] = q
+
+ self.mDialog = []
+ for e in area1game5_data.DIALOG:
+ self.mDialog.append(unicode(e, 'UTF-8'))
+
+ self.mGoodA = unicode(area1game5_data.GOOD, 'UTF-8')
+ self.mBadA = unicode(area1game5_data.BAD, 'UTF-8')
+
+ # randomize it
+ random.shuffle(self.mboy_list)
+
+ self.mButtonBackA1G5 = CButton()
+ self.mButtonBackA1G5.set_bgColor((0x99, 0x99, 0x66))
+ self.mButtonBackA1G5.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
+ self.mButtonBackA1G5.set_center((110, 650))
+ self.mButtonBackA1G5.set_size((200, 40))
+ self.mButtonBackA1G5.set_text(_('Volver'))
+ CGame().addChild(self.mButtonBackA1G5)
+
+ self.mLabelQuestion = Globe((500, 150), pico='None', text=' ')
+ self.mLabelQuestion.set_center((600, 250))
+
+ self.mButtonTrue = CButton()
+ self.mButtonTrue.set_bgColor((125, 255, 125))
+ self.mButtonTrue.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
+ self.mButtonTrue.set_center((460, 400))
+ self.mButtonTrue.set_size((200, 40))
+ self.mButtonTrue.set_text(_('Verdadero'))
+
+ self.mButtonFalse = CButton()
+ self.mButtonFalse.set_bgColor((125, 255, 125))
+ self.mButtonFalse.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 28)
+ self.mButtonFalse.set_center((740, 400))
+ self.mButtonFalse.set_size((200, 40))
+ self.mButtonFalse.set_text(_('Falso'))
+
+ self.mBoy = CSprite()
+ self.mBoy.loadImage('assets/images/a1g3/Juan-chico-costado-parado.png')
+ self.mBoy.setXY(100, 400)
+ CGame().addChild(self.mBoy)
+
+ elisa = Image.loadImage('assets/images/a1g3/Elisa-chica-costado-parada.png')
+ elisa_rotated = pygame.transform.flip(elisa, True, False)
+ self.mGirl = CSprite()
+ self.mGirl.setImage(elisa_rotated)
+ self.mGirl.setXY(900, 400)
+ CGame().addChild(self.mGirl)
+
+ # que es..
+ self.mDialogBoy1 = Globe((300, 70), text=self.mDialog[0])
+ self.mDialogBoy1.set_center((300, 300))
+ CGame().addChild(self.mDialogBoy1)
+
+ # mmm.. no...
+ self.mDialogGirl1 = Globe((300, 70), pico='right', text=self.mDialog[1])
+ self.mDialogGirl1.set_center((900, 300))
+
+ self.mDialogGood = Globe((200, 75), pico='left', text=self.mGoodA)
+ self.mDialogGood.set_center((300, 300))
+
+ self.mDialogBad = Globe((200, 75), pico='left', text=self.mBadA)
+ self.mDialogBad.set_center((300, 300))
+
+ self.mPoints = CPoints()
+ self.mPoints.setXY(250, 10)
+ CGame().addChild(self.mPoints)
+
+ #self.mTime = self.mDialogBoy1.getTimeState()
+ self.mCurrentState = 0
+ self.time = 0
+
+ def update(self):
+ CGameState.update(self)
+
+
+ self.time = self.time + 1
+
+ if self.mButtonBackA1G5.clicked():
+ print "clicked back of a1g5"
+ #cs = CHelpState()
+ ms = MenuState.CMenuState()
+ CGame().setState(ms)
+ return
+
+ if self.mCurrentState == 0:
+ #self.time = self.mListDialogs[0].getTimeState()
+ if self.time > 4*30:
+ CGame().removeChild(self.mDialogBoy1)
+ CGame().addChild(self.mDialogGirl1)
+ self.mCurrentState = 1
+ self.time = 0
+ #self.mListDialogs[1].setTimeState(0)
+
+ elif self.mCurrentState == 1:
+ #self.time = self.mListDialogs[1].getTimeState()
+ if self.time > 3*30:
+ CGame().removeChild(self.mDialogGirl1)
+
+ self.mCurrentState = 2
+ self.time = 0
+ #self.mListDialogs[2].setTimeState(0)
+
+
+ # Pregunta
+ elif self.mCurrentState == 2:
+ 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 = 3
+
+ elif (self.mQuestionAnswered == False):
+ if self.mButtonTrue.clicked():
+ CGame().removeChild(self.mLabelQuestion)
+ CGame().removeChild(self.mButtonTrue)
+ CGame().removeChild(self.mButtonFalse)
+ 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)
+ 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:
+ #self.time = self.mActiveDialog.getTimeState()
+ if self.time > 3*30:
+ CGame().removeChild(self.mDialogGood)
+ CGame().removeChild(self.mDialogBad)
+ self.mQuestionShowed = False
+ self.mQuestionAnswered = False
+ self.mActiveDialog = None
+
+
+ def next_questionB(self):
+ if not(self.mboy_list == []):
+ self.mActualQuestionN = self.mboy_list.pop()
+ self.mTupleQuestion = self.mBoyDict[self.mActualQuestionN]
+ text = self.mTupleQuestion[0]
+ self.mLabelQuestion.set_text(text)
+ return True
+ else:
+ return False
+
+
+ def destroy(self):
+ print 'destroy a1g5'
+ CGameState.destroy(self)
+ #self.mInstructions.destroy()
+ self.mInstructions = None
+
+ CGame().removeChild(self.mButtonBackA1G5)
+ CGame().removeChild(self.mLabelQuestion)
+ CGame().removeChild(self.mButtonTrue)
+ CGame().removeChild(self.mButtonFalse)
+ CGame().removeChild(self.mBoy)
+ CGame().removeChild(self.mGirl)
+ CGame().removeChild(self.mDialogBoy1)
+ CGame().removeChild(self.mDialogGirl1)
+ CGame().removeChild(self.mDialogBoy2)
+ CGame().removeChild(self.mDialogGood)
+ CGame().removeChild(self.mDialogBad)
+ CGame().removeChild(self.mPoints)
+
+ self.mButtonBackA1G5 = None
+ self.mLabelQuestion = None
+ self.mButtonTrue = None
+ self.mButtonFalse = None
+ self.mBoy = None
+ self.mGirl = None
+ self.mDialogBoy1 = None
+ self.mDialogGirl1 = None
+ self.mDialogBoy2 = None
+ self.mDialogGood = None
+ self.mDialogBad = None
+ self.mPoints = None
+
diff --git a/src/game/MenuState.py b/src/game/MenuState.py
index c4b4e7c..ca13590 100644
--- a/src/game/MenuState.py
+++ b/src/game/MenuState.py
@@ -12,6 +12,7 @@ from game.SelectPartidaState import CSelectPartidaState
from game.Area1Game1 import CArea1Game1
from game.Area1Game3 import CArea1Game3
from game.Area1Game4 import CArea1Game4
+from game.Area1Game5 import CArea1Game5
from game.Area1Game6 import CArea1Game6
from game.Area2Game2 import CArea2Game2
@@ -90,7 +91,7 @@ class CMenuState(CGameState):
self.mButtonA1G1 = CButton()
self.mButtonA1G1.bgColor = (0x99, 0x99, 0x66)
self.mButtonA1G1.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
- self.mButtonA1G1.set_center((110, 420))
+ self.mButtonA1G1.set_center((110, 370))
self.mButtonA1G1.set_size((200, 40))
self.mButtonA1G1.set_text('A1 - Juego 1')
CGame().addChild(self.mButtonA1G1)
@@ -98,7 +99,7 @@ class CMenuState(CGameState):
self.mButtonA1G3 = CButton()
self.mButtonA1G3.bgColor = (0x99, 0x99, 0x66)
self.mButtonA1G3.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
- self.mButtonA1G3.set_center((110, 470))
+ self.mButtonA1G3.set_center((110, 420))
self.mButtonA1G3.set_size((200, 40))
self.mButtonA1G3.set_text('A1 - Juego 3')
CGame().addChild(self.mButtonA1G3)
@@ -106,11 +107,19 @@ class CMenuState(CGameState):
self.mButtonA1G4 = CButton()
self.mButtonA1G4.bgColor = (0x99, 0x99, 0x66)
self.mButtonA1G4.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
- self.mButtonA1G4.set_center((110, 520))
+ self.mButtonA1G4.set_center((110, 470))
self.mButtonA1G4.set_size((200, 40))
self.mButtonA1G4.set_text('A1 - Juego 4')
CGame().addChild(self.mButtonA1G4)
+ self.mButtonA1G5 = CButton()
+ self.mButtonA1G5.bgColor = (0x99, 0x99, 0x66)
+ self.mButtonA1G5.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
+ self.mButtonA1G5.set_center((110, 520))
+ self.mButtonA1G5.set_size((200, 40))
+ self.mButtonA1G5.set_text('A1 - Juego 5')
+ CGame().addChild(self.mButtonA1G5)
+
self.mButtonA1G6 = CButton()
self.mButtonA1G6.bgColor = (0x99, 0x99, 0x66)
self.mButtonA1G6.font = pygame.font.Font('assets/fonts/DejaVuSans.ttf', 20)
@@ -191,6 +200,13 @@ class CMenuState(CGameState):
a1g4 = CArea1Game4()
CGame().setState(a1g4)
return
+
+ elif self.mButtonA1G5.clicked():
+ print "clicked A1G5"
+ #cs = CHelpState()
+ a1g5 = CArea1Game5()
+ CGame().setState(a1g5)
+ return
elif self.mButtonA1G6.clicked():
print "clicked A1G6"