Back to index

freevial  1.2
Public Member Functions | Public Attributes
selcat.SelCat Class Reference

List of all members.

Public Member Functions

def __init__
def refa_cats
def reinicia_cats
def CanviaElements
def PosaPrimer
def juguem

Public Attributes

 game
 mascara_de_fons
 fons
 sel_quadres
 sel_reflexos
 sel_fletxap
 sel_fletxab
 sel_quadre
 sel_quadreok
 so_sub
 so_sub2
 selcat_color_text
 selcat_color_text_nosel
 help_overlay
 help_on_screen
 cp
 sfc_preguntes
 sfc_nombres
 categories_seleccionades
 darrera_info
 sfc_text_info0
 sfc_text_info1
 sfc_text_info2
 sfc_text_info3
 sfc_text_info4
 sfc_text_info5
 sfc_text_info6
 sfc_cat

Detailed Description

Definition at line 46 of file selcat.py.


Constructor & Destructor Documentation

def selcat.SelCat.__init__ (   self,
  game 
)

Definition at line 48 of file selcat.py.

00048 
00049        def __init__( self, game ):
00050               
00051               self.game = game
00052               game.skin.set_domain( 'selcat' )
00053               
00054               self.mascara_de_fons =  game.skin.LoadImage('fons_score')
00055               self.fons = game.skin.LoadImage('score_fons')
00056 
00057               self.sel_quadres = game.skin.LoadImage('sel_quadres')
00058               self.sel_reflexos = game.skin.LoadImage('sel_reflexos')
00059 
00060               self.sel_fletxap = game.skin.LoadImage('sel_fletxap')
00061               self.sel_fletxab = game.skin.LoadImage('sel_fletxab')
00062 
00063               self.sel_quadre = game.skin.LoadImage('sel_quadre')
00064               self.sel_quadreok = game.skin.LoadImage('sel_quadreok')
00065 
00066               self.so_sub = game.skin.LoadSound( 'so_sub', 'so_sub_vol' )
00067               self.so_sub2 = game.skin.LoadSound( 'so_sub2', 'so_sub_vol' )
00068 
00069               self.selcat_color_text = game.skin.configGetRGB( 'color_text' )
00070               
00071               self.selcat_color_text_nosel = game.skin.configGetRGB( 'color_text_nosel' )
00072 
00073               self.help_overlay = createHelpScreen( 'score' )
00074 
00075               self.help_on_screen = helpOnScreen( HOS_SCORE_MODE0 )
00076 
00077               self.cp = get_databases()
00078               self.sfc_preguntes = range(0, len(self.cp))
00079 
00080               self.reinicia_cats()
00081 
00082               self.sfc_nombres = range(0,6)
00083               for compta in range(0, 6):
00084                      self.sfc_nombres[compta] = render_text( str(compta+1), colorsCategories()[compta], 35, 1, '', 50 )


Member Function Documentation

def selcat.SelCat.CanviaElements (   self,
  aposar,
  atreure 
)

Definition at line 98 of file selcat.py.

00098 
00099        def CanviaElements( self, aposar, atreure):
00100 
00101               self.so_sub2.play() 
00102 
00103               if aposar == atreure:
00104                      return
00105 
00106               queda = self.cp[aposar]
00107               self.cp[aposar] = self.cp[atreure]
00108               self.cp[atreure] = queda
00109 
00110               self.darrera_info = -1
00111               self.reinicia_cats( )

Here is the caller graph for this function:

def selcat.SelCat.juguem (   self,
  estat 
)

Definition at line 124 of file selcat.py.

00124 
00125        def juguem( self, estat ):
00126               # estat 0 = edició, 1/2 = veure categories
00127               
00128               self.game.skin.set_domain( 'selcat' )
00129               frate = frameRate( Global.fps_limit )
00130               
00131               self.game.screen.fill( (0,0,0,0) )
00132               
00133               ypos = mou_fons = mostra_ajuda = mostra_credits = 0
00134 
00135               self.darrera_info = -1
00136 
00137               darrer_element_a_la_vista = 0
00138 
00139               primer_element_a_la_vista = 0
00140 
00141               self.help_on_screen.activitat()
00142                      
00143               seleccio = 0
00144 
00145               nelements = len(self.cp) if estat == 0 else 6
00146 
00147               while 1:
00148                             
00149                      # Event iterator
00150                      for event in pygame.event.get():
00151 
00152                             eventhandle = EventHandle(event)
00153                             if eventhandle.handled: continue
00154                             
00155                             if eventhandle.keyUp('q', 'ESCAPE', 'KP_ENTER', 'F3', 'F5'):
00156                                    if estat == 0: self.refa_cats();
00157                                    return
00158                             
00159                             if eventhandle.keyUp('DOWN'):
00160                                    seleccio += 1
00161                                    seleccio %=  nelements
00162                                    self.so_sub.play() 
00163                             
00164                             if eventhandle.keyUp('UP'):
00165                                    seleccio -= 1
00166                                    seleccio %=  nelements 
00167                                    self.so_sub.play() 
00168                             
00169                             if estat == 0:
00170 
00171                                    if eventhandle.keyUp('r'):
00172                                           shuffle_databases()
00173                                           self.reinicia_cats( )
00174                                           self.so_sub2.play()
00175                                           self.darrera_info = -1
00176 
00177                                    for num in range(0, 6):
00178                                           if eventhandle.keyUp(str(num + 1), 'KP' + str(num + 1)):       
00179                                                  self.CanviaElements( seleccio, num )
00180                                                  seleccio = num
00181 
00182                                    if eventhandle.keyUp('RETURN'):                                                                   
00183                                           self.PosaPrimer( seleccio )
00184 
00185                             else:
00186                                    if eventhandle.keyUp('RETURN'):                  
00187                                           if estat == 0: self.refa_cats();                                             
00188                                           return
00189               
00190                      # Animem el fons
00191                      ypos += 1
00192                      ypos %= Global.screen_y
00193 
00194                      # Pintem el fons animat
00195                      mou_fons += 8
00196                      for num in range(0, 768):
00197                             self.game.screen.blit( self.fons, (cos((float(mou_fons +num)) / 100.0) * 20, num), (0, (ypos + num) % 768, 1024, 1) )
00198 
00199                      self.game.screen.blit( self.mascara_de_fons, (0, 0) )
00200                      self.game.screen.blit( self.sel_quadres, (0, 0) )
00201 
00202 
00203                      nelements = len(self.cp) if estat == 0 else 6
00204 
00205                      posact= 220
00206                      for compta in range(primer_element_a_la_vista, nelements):     
00207                             if posact + self.sfc_preguntes[compta].get_height() > (768 -80)       :
00208                                    break
00209                      
00210                             if compta == seleccio:
00211                                    self.game.screen.fill( (64,64,64), (100, posact, 300, self.sfc_preguntes[compta].get_height() +3 ) )
00212 
00213                             if compta < 6 :
00214                                    self.game.screen.blit( self.sfc_nombres[compta], (120, posact-3) )
00215 
00216                             darrer_element_a_la_vista = compta
00217                             self.game.screen.blit( self.sfc_preguntes[compta], ( 160,posact ))    
00218 
00219                             posact += self.sfc_preguntes[compta].get_height() + 20
00220 
00221                      if primer_element_a_la_vista > 0: 
00222                             self.game.screen.blit( self.sel_fletxap, ( 386,216 + 10 + cos(time.time() * 10) * 10))
00223 
00224                      if darrer_element_a_la_vista < nelements - 1:
00225                             self.game.screen.blit( self.sel_fletxab, ( 386, 651 - 10 - cos(time.time()*10) * 10 ))
00226 
00227                      if darrer_element_a_la_vista < seleccio:  primer_element_a_la_vista += 1
00228 
00229                      if primer_element_a_la_vista > seleccio:  primer_element_a_la_vista -= 1
00230 
00231                                           
00232                      self.game.screen.blit( self.sfc_preguntes[seleccio], ( 475, 220 ))    
00233 
00234                      if seleccio != self.darrera_info:  
00235                             self.sfc_text_info0 = render_text( self.cp[seleccio].authors, self.selcat_color_text, 14, 1, '', 220 )
00236                             self.sfc_text_info1 = render_text( self.cp[seleccio].description, self.selcat_color_text, 16, 1, '', 350 )
00237                             self.sfc_text_info2 = render_text( self.cp[seleccio].players, self.selcat_color_text, 16, 1, '', 350 )
00238                             self.sfc_text_info3 = render_text( u"N. Pregutes: " + str(len(self.cp[seleccio])), self.selcat_color_text, 16, 1, '', 350 )
00239                             self.sfc_text_info4 = render_text( u"Idioma: " + self.cp[compta].language, self.selcat_color_text, 16, 1, '', 100 )
00240                             self.sfc_text_info5 = render_text( u"Data creació: " + time.strftime('%d/%m/%Y', time.gmtime(self.cp[compta].time[0])), self.selcat_color_text, 16, 1, '', 350 )
00241                             self.sfc_text_info6 = render_text( u"Data darrera modificació: " + time.strftime('%d/%m/%Y', time.gmtime(self.cp[seleccio].time[1])), self.selcat_color_text, 16, 1, '', 350 )
00242 
00243                             self.sfc_cat = loadImage( self.cp[seleccio].image )
00244                             if seleccio < 6:
00245                                    sfcmask = loadImage( 'filtre_c' + str(seleccio+1) + '.png' )
00246                                    self.sfc_cat.blit( sfcmask, (0,0))
00247                             self.sfc_cat = pygame.transform.scale(self.sfc_cat, (184, 138) )
00248 
00249                             self.darrera_info = seleccio
00250                      
00251                      self.game.screen.blit( self.sfc_text_info0, ( 475, 305 ))      
00252                      self.game.screen.blit( self.sfc_text_info1, ( 490, 380 ))      
00253                      self.game.screen.blit( self.sfc_text_info2, ( 490, 495 ))      
00254                      self.game.screen.blit( self.sfc_text_info3, ( 490, 606 ))      
00255                      self.game.screen.blit( self.sfc_text_info4, ( 765, 606 ))      
00256                      self.game.screen.blit( self.sfc_text_info5, ( 490, 635 ))      
00257                      self.game.screen.blit( self.sfc_text_info6, ( 490, 655 ))      
00258        
00259                      self.game.screen.blit( self.sfc_cat, ( 697, 221 ))      
00260                      
00261                      if mostra_ajuda: self.game.screen.blit( self.help_overlay, (0,0))
00262                      if mostra_credits: self.game.screen.blit( self.game.sfc_credits, (0,0))
00263                      
00264                      self.game.screen.blit( self.sel_reflexos, (0, 0) )
00265 
00266                      frate.next( self.game.screen )
00267                      
00268                      # Exchange self.game.screen buffers
00269                      pygame.display.flip()
00270 
00271               return 0

Here is the call graph for this function:

def selcat.SelCat.PosaPrimer (   self,
  seleccio 
)

Definition at line 112 of file selcat.py.

00112 
00113        def PosaPrimer( self, seleccio ):
00114 
00115               self.so_sub2.play() 
00116               if seleccio == 0:
00117                      return
00118 
00119               actual = self.cp[seleccio]
00120               self.cp.remove( actual )
00121               self.cp.insert( 0, actual )
00122               self.darrera_info = -1
00123               self.reinicia_cats( )

Here is the call graph for this function:

Here is the caller graph for this function:

def selcat.SelCat.refa_cats (   self)

Definition at line 85 of file selcat.py.

00085 
00086        def refa_cats( self ):
00087               for cat in range(0, 6):
00088                      self.cp[cat].num = cat+1
       

Here is the caller graph for this function:

Definition at line 89 of file selcat.py.

00089 
00090        def reinicia_cats( self ):
00091               self.categories_seleccionades = [0,1,2,3,4,5];
00092        
00093               for compta in range(0, len(self.cp)):
00094                      color = self.selcat_color_text_nosel
00095                      if compta < 6:
00096                             color = colorsCategories()[compta]
00097                      self.sfc_preguntes[compta] = render_text( self.cp[compta].name, color, 27, 1, '', 220 )

Here is the caller graph for this function:


Member Data Documentation

Definition at line 90 of file selcat.py.

Definition at line 76 of file selcat.py.

Definition at line 109 of file selcat.py.

Definition at line 54 of file selcat.py.

Definition at line 50 of file selcat.py.

Definition at line 74 of file selcat.py.

Definition at line 72 of file selcat.py.

Definition at line 53 of file selcat.py.

Definition at line 60 of file selcat.py.

Definition at line 59 of file selcat.py.

Definition at line 62 of file selcat.py.

Definition at line 63 of file selcat.py.

Definition at line 56 of file selcat.py.

Definition at line 57 of file selcat.py.

Definition at line 68 of file selcat.py.

Definition at line 70 of file selcat.py.

Definition at line 242 of file selcat.py.

Definition at line 81 of file selcat.py.

Definition at line 77 of file selcat.py.

Definition at line 234 of file selcat.py.

Definition at line 235 of file selcat.py.

Definition at line 236 of file selcat.py.

Definition at line 237 of file selcat.py.

Definition at line 238 of file selcat.py.

Definition at line 239 of file selcat.py.

Definition at line 240 of file selcat.py.

Definition at line 65 of file selcat.py.

Definition at line 66 of file selcat.py.


The documentation for this class was generated from the following file: