Back to index

freevial  1.2
Public Member Functions | Public Attributes
endscreen.Visca Class Reference

List of all members.

Public Member Functions

def __init__
def juguem

Public Attributes

 fons
 fons_2
 nau_sfc
 sfc_llum
 frate
 naus

Detailed Description

Definition at line 77 of file endscreen.py.


Constructor & Destructor Documentation

def endscreen.Visca.__init__ (   self,
  joc 
)

Definition at line 79 of file endscreen.py.

00079 
00080        def __init__( self, joc ):
00081 
00082               Global.game = joc
00083        
00084               self.fons = loadImage('score_fons.png')
00085               self.fons_2 = pygame.Surface( ( 1024, 768), pygame.SRCALPHA, 32 )
00086 
00087               self.nau_sfc = []
00088               for num in range( 0, 72 ): 
00089                      self.nau_sfc.append( loadImage('ovnis/freevial_tot' + str( num ).zfill(2) + '.png') )
00090 
00091               self.sfc_llum = loadImage( 'llum.png' )


Member Function Documentation

def endscreen.Visca.juguem (   self,
  game,
  nomguanya 
)

Definition at line 92 of file endscreen.py.

00092 
00093        def juguem( self, game, nomguanya ):
00094               
00095               Global.game = game
00096               self.frate = frameRate( Global.fps_limit )
00097               inici = time.time()
00098 
00099               self.naus = []
00100 
00101               loadSound( 'wonfv.ogg', volume = 0.8, music = 1).play( 1 )
00102               
00103               mou_fons = ypos = xpos = 0
00104 
00105               sfc_guanyadors = render_text( nomguanya, (255,255,255), 300, 1 )      
00106               text_pos = 1024 + 50
00107 
00108               sfc_freevial = render_text( "freevial", (255,0,0), 200, 0 )    
00109               sfc_freevial.set_alpha( 64 )
00110 
00111               surten = 0
00112 
00113               cues = []
00114               
00115               llums = 0
00116        
00117               while 1:
00118 
00119                      segons = time.time() - inici
00120 
00121                      for cua in cues:
00122                             if time.time() - cua.time > .4 and cua.cau == 0: 
00123                                    cues.remove( cua )
00124 
00125                             if cua.cau:
00126                                    cua.pos[1] += cua.cau
00127                                    if cua.pos[1] > 768:
00128                                           cues.remove( cua )
00129 
00130 
00131                      fes_llums = False
00132                      if (llums == 0 and segons > 45) or (llums == 1 and segons > 55) or (llums == 2 and segons > 64) or (llums == 3 and segons > 65) or (llums == 4 and segons > 66):
00133                             llums += 1
00134                             fes_llums = True
00135  
00136                      if fes_llums:
00137                             pos = 0
00138                             while pos < 1024:
00139                                    pos += random.randint(1, 10)
00140                                    cua = Cua( (pos, random.randint(0,5)) )
00141                                    cua.cau = random.randint( 5, 25 ) 
00142                                    cues.append ( cua ) 
00143 
00144                      if segons < 5.5 and int(segons) > surten:
00145                             surten = int( segons)
00146                             for compta in range( 0, 360, 10):
00147                                    nova_nau = Nau( compta )
00148                                    nova_nau.vel = surten * 2
00149                                    self.naus.append( nova_nau )
00150 
00151                      if segons > 5.5:
00152                             if segons >= 35 and segons <= 48:
00153                                    nova_nau = Nau( segons *5 )
00154                                    nova_nau.velociat = segons - 30
00155                                    self.naus.append( nova_nau )
00156                             elif not random.randint(0, 1):
00157                                           nova_nau = Nau()
00158                                           self.naus.append( nova_nau )
00159                      
00160                      for compta in range( len(self.naus) - 1, -1, -1):
00161                             nau = self.naus[compta]
00162                             if nau.esFora() :
00163                                    self.naus.remove( nau )
00164                             else:
00165                                    nau.img += nau.spin
00166                                    nau.img %= 72
00167 
00168                                    dist = math.sqrt( abs(nau.x - 1024/2) * abs(nau.x - 1024/2) + abs(nau.y - 768/2) * abs(nau.y - 768/2))
00169                                    dist /= 150
00170               
00171                                    if( segons < 48 ):                               
00172                                           nau.x += math.cos( nau.dir ) * nau.vel
00173                                           nau.y += math.sin( nau.dir ) * nau.vel
00174                                    elif (segons < 58):
00175                                           nau.x += math.cos( nau.dir + dist) * nau.vel
00176                                           nau.y += math.sin( nau.dir + dist) * nau.vel
00177                                    else :
00178                                           nau.x += math.cos( nau.dir - dist) * nau.vel
00179                                           nau.y += math.sin( nau.dir - dist) * nau.vel
00180 
00181                      for event in pygame.event.get():
00182                             
00183                             eventhandle = EventHandle(event)
00184                             if eventhandle.handled: continue
00185                             
00186                             if eventhandle.keyUp('q', 'ESCAPE') and not Global.LOCKED_MODE:
00187                                    if not Global.MUSIC_MUTE:
00188                                           pygame.mixer.music.fadeout( 1500 )
00189                                    return
00190                      
00191                      if segons >= 68: return
00192 
00193                      ypos += 1
00194                      ypos %= Global.screen_y
00195                      xpos += 1
00196                      xpos %= Global.screen_x
00197 
00198                      mou_fons += 10
00199 
00200                      if segons > 5.5:
00201 
00202                             Global.game.screen.blit( self.fons, (0,0))
00203 
00204                             for num in range(0, 768):
00205                                    Global.game.screen.blit( self.fons, (math.cos((float(mou_fons +num)) / 100.0) * 20, num), (0, (ypos + num) % 768, 1024, 1) )
00206        
00207                             llista_freevial = [ [8.7, 12], [12.7, 17], [20, 23.5], [27.5, 31], [33, 35.5], [49.5, 52.5], [55.5, 57.5], [60.9, 63.5] ]
00208 
00209                             if ensegments( llista_freevial, segons ):
00210                                    for compta in range( 0, 5):
00211                                           Global.game.screen.blit( sfc_freevial, (random.randint( -sfc_freevial.get_width(), 1024), random.randint(-sfc_freevial.get_height(), 768 )) )      
00212 
00213                                    if segons >= 20 and segons <=34:
00214                                           for nau in self.naus:
00215                                                  cues.append ( Cua( (nau.x + 32 - 8, nau.y + 32 - 4) ) )
00216 
00217                      else:
00218                             Global.game.screen.fill( (0,0,0) )
00219 
00220                      for cua in cues:
00221                             dist = int((time.time() - cua.time) * 40) if cua.cau == 0 else 0
00222                             Global.game.screen.blit( self.sfc_llum, ( cua.pos[0] + random.randint(-dist,dist), cua.pos[1] + random.randint(-dist,dist)) )
00223 
00224                      for nau in self.naus:
00225                             Global.game.screen.blit( self.nau_sfc[nau.img], (nau.x, nau.y ) )
00226                      
00227                      if segons > 5.5:
00228                             text_pos -= 20
00229                             if text_pos < -(sfc_guanyadors.get_width() + 50):
00230                                    text_pos = 1024 + 50
00231 
00232                             Global.game.screen.blit( sfc_guanyadors, (text_pos, 150 + math.cos((float(mou_fons +num)) / 100.0) * 200) )
00233                      
00234                      self.frate.next( Global.game.screen )
00235 
00236                      pygame.display.flip()

Member Data Documentation

Definition at line 83 of file endscreen.py.

Definition at line 84 of file endscreen.py.

Definition at line 95 of file endscreen.py.

Definition at line 86 of file endscreen.py.

Definition at line 98 of file endscreen.py.

Definition at line 90 of file endscreen.py.


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