def __init__(self):
      BaseState.__init__(self)

      self.play_music = True
      self.count = 0
      self.next_transition = VALID_STATES['STAY']

      self.screen_vertical_half = pygame.display.Info().current_h / 3

      image = imloader.cached_image_loader.get_image_to_screen_percent('gfx/burbuja.png')
      image2 = imloader.cached_image_loader.get_image_to_screen_percent('gfx/submarino1.png')
      image4 = imloader.cached_image_loader.get_image_to_screen_percent('gfx/submarino2.png')
      image3 = imloader.cached_image_loader.get_image_to_screen_percent('gfx/oneoop.png')

      self.sine_movement = actor.BulletActor(0, image, "SineMovement", False, True, False)
      self.sine_movement.set_position([-(image2.get_width() / 2 + 10), pygame.display.Info().current_h / 4])
      # The next line calculates the horizontal velocity of sine_movement.
      # We want it to cover the width of the screen plus the width of the submarine sprite
      # in 20 seconds. We divide by 60 to obtain the speed in pixels per frame.
      x_velocity = (float(pygame.display.Info().current_w + image2.get_width()) / 26.0) / 60.0 
      self.sine_movement.set_velocity([x_velocity, 0])
      self.sine_movement.move()
      self.w_extra = int((305.0 * pygame.display.Info().current_w) / 1024.0)

      self.submarine = actor.BaseActor(1, image2, "Submarine", True, True, False)
      self.submarine.set_image_point_xy(int(float(image2.get_width()) * 0.195), int(float(image2.get_height()) * 0.835))
      self.submarine.set_fps(10)
      self.submarine.add_frame(image4)

      self.particle_system = particle.ParticleSystem(0, "Bubbles", 'gfx/burbuja.png', 1000, 1000, 3, -130.0)
      self.particle_system.set_friction(1.0)
      self.particle_system.set_gravity([0.0, -60.0])
      self.particle_system.set_max_velocity(5.0)
      self.particle_system.start()

      self.oneoop_logo = actor.BaseActor(2, image3, "1-Oop logo", False, True, False)
      self.oneoop_logo.set_position([10 + (image3.get_width() / 2),
                                     pygame.display.Info().current_h - 10 - (image3.get_height() / 2)])

      screen_prop = (25.0 / 768.0)
      screen_fract = (float(pygame.display.Info().current_h) * screen_prop) / 768.0
      scale_factor = screen_fract / screen_prop

      font = pygame.font.Font('font/PressStart2P/PressStart2P.ttf', int(25.0 * scale_factor))
      text_surf = font.render("1-OOP Presenta", True, (0, 0, 0))
      self.text = actor.BaseActor(2, text_surf, "Text", False, True, False)
      self.text.set_position([self.oneoop_logo.get_position()[0] + image3.get_width() + (text_surf.get_width() // 2) + 10,
                                     pygame.display.Info().current_h - 10 - (image3.get_height() / 2)])
      
      if game.DEBUG:
         print "Velocity: " + str(self.sine_movement.get_velocity())
         print "Position: " + str(self.sine_movement.get_position())
         print self.sine_movement.is_moving()
    def __init__(self):
       BaseState.__init__(self)

       self.next_transition = VALID_STATES['INTRO']
       self.current_menu = MENUS['MAIN']
       self.story_time = 0
       self.story_timeout = 7000 # 7 seconds.
       self.then = 0
       
       self.cursor_x = 0
       self.cursor_y = 0
       
       self.background_color = (125, 158, 192)

       # Load main menu buttons.
       image = cached_image_loader.get_image_to_screen_percent('gfx/logo.png')
       self.logo = BaseActor(0, image, "SHR98 logo", False, True, False)
       self.logo.set_position([pygame.display.Info().current_w // 2, (image.get_height() // 2) + 20])

       image2 = cached_image_loader.get_image_to_screen_percent('gfx/boton_socre.png')
       self.scr_button = BaseActor(1, image2, "Score Button", False, True, False)
       self.scr_button.set_position([pygame.display.Info().current_w // 2,
                                     self.logo.get_position()[1] + (image.get_height()) + 20])

       image = cached_image_loader.get_image_to_screen_percent('gfx/boton_new.png')
       self.new_button = BaseActor(2, image, "New button", False, True, False)
       self.new_button.set_position([pygame.display.Info().current_w // 2 - 10 -image2.get_width(),
                                     self.scr_button.get_position()[1]])

       image = cached_image_loader.get_image_to_screen_percent('gfx/boton_salir.png')
       self.quit_button = BaseActor(3, image, "Quit button", False, True, False)
       self.quit_button.set_position([pygame.display.Info().current_w // 2 + 10 +image2.get_width(),
                                     self.scr_button.get_position()[1]])

       # Load score menu buttons.
       image = cached_image_loader.get_image_to_screen_percent('gfx/MenosMalos.png')
       self.scoreboard = BaseActor(4, image, "Scoreboard", False, True, False)
       self.scoreboard.set_position([(image.get_width() // 2) + 20, pygame.display.Info().current_h // 2])

       image2 = cached_image_loader.get_image_to_screen_percent('gfx/boton_back.png')
       self.back_button = BaseActor(5, image2, "Back button", False, True, False)
       self.back_button.set_position([self.scoreboard.get_position()[0] + image.get_width() - (image.get_width() // 10),
                                      pygame.display.Info().current_h // 2])
       
       font_size = 42
       screen_prop = (float(font_size) / 768.0)
       screen_fract = (float(pygame.display.Info().current_h) * screen_prop) / 768.0
       scale_factor = screen_fract / screen_prop
       self.font = pygame.font.Font('font/ProfaisalEliteRiqa/Profaisal-EliteRiqaV1.0.ttf', int(font_size * scale_factor))

       # Score labels.
       self.score_1 = None
       self.score_2 = None
       self.score_3 = None
       self.score_4 = None
       self.score_5 = None

       # Story labels.
       font_size = 22
       screen_prop = (float(font_size) / 768.0)
       screen_fract = (float(pygame.display.Info().current_h) * screen_prop) / 768.0
       scale_factor = screen_fract / screen_prop
       font_small = pygame.font.Font('font/ProfaisalEliteRiqa/Profaisal-EliteRiqaV1.0.ttf', int(font_size * scale_factor))

       self.story_1 = font_small.render("Este es Moncho, nuestro heroe...", True, (0, 0, 0))
       self.story_2 = font_small.render("Moncho ama a toda la gente, gente como esta...", True, (0, 0, 0))
       self.story_3 = font_small.render("Ama tanto a la gente que solo quiere abrazarlos...", True, (0, 0, 0))
       self.story_5 = font_small.render("Aunque, tal vez Moncho no ame a TODA la gente...", True, (0, 0, 0))

       font_size = 35
       screen_prop = (float(font_size) / 768.0)
       screen_fract = (float(pygame.display.Info().current_h) * screen_prop) / 768.0
       scale_factor = screen_fract / screen_prop
       font_big = pygame.font.Font('font/ProfaisalEliteRiqa/Profaisal-EliteRiqaV1.0.ttf', int(font_size * scale_factor))

       self.story_4 = font_big.render("¡¡¡ABRAZARLOS HASTA QUE EXPLOTEN!!!", True, (255, 0, 0))
       
       self.interrogation = font_big.render("?", True, (0, 0, 0))

       self.player_label_1 = cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_front.png')
       self.player_label_2 = cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_front_HUG.png')

       self.he_huggable_1 = cached_image_loader.get_image_to_screen_percent('gfx/HeHuggable/Idle_front.png')
       self.he_huggable_2 = cached_image_loader.get_image_to_screen_percent('gfx/HeHuggable/Walking_front_1_scared.png')

       self.she_huggable_1 = cached_image_loader.get_image_to_screen_percent('gfx/SheHuggable/Idle_front.png')
       self.she_huggable_2 = cached_image_loader.get_image_to_screen_percent('gfx/SheHuggable/Walking_front_2_scared.png')

       self.explosion = cached_image_loader.get_image_to_screen_percent('gfx/Explosion2.png')
       self.mystery_guy = cached_image_loader.get_image_to_screen_percent('gfx/ForeverAlone/Idle_Front_face_hidden.png')
       
       self.score_text_x = int(float(image.get_width()) * 0.183) + self.scoreboard.rect.left   # image holds the scoreboard graphic.
       self.score_text_1_y = int(float(image.get_height()) * 0.300) + self.scoreboard.rect.top
       self.score_text_inc = int(float(image.get_height()) * 0.112)

       self.story_1_x = int((float(pygame.display.Info().current_w) * 177.0 ) / 1024.0)
       self.story_1_y = int((float(pygame.display.Info().current_h) * 109.0 ) / 768.0)
       self.story_2_x = int((float(pygame.display.Info().current_w) * 211.0 ) / 1024.0)
       self.story_2_y = int((float(pygame.display.Info().current_h) * 223.0 ) / 768.0)
       self.story_3_x = int((float(pygame.display.Info().current_w) * 240.0 ) / 1024.0)
       self.story_3_y = int((float(pygame.display.Info().current_h) * 346.0 ) / 768.0)
       self.story_4_x = int((float(pygame.display.Info().current_w) * 38.0 ) / 1024.0)
       self.story_4_y = int((float(pygame.display.Info().current_h) * 517.0 ) / 768.0)
       self.story_5_x = int((float(pygame.display.Info().current_w) * 244.0 ) / 1024.0)
       self.story_5_y = int((float(pygame.display.Info().current_h) * 710.0 ) / 768.0)
       self.interr_x = int((float(pygame.display.Info().current_w) * 173.0 ) / 1024.0)
       self.interr_y = int((float(pygame.display.Info().current_h) * 650.0 ) / 768.0)

       self.moncho_1_x = int((float(pygame.display.Info().current_w) * 49.0 ) / 1024.0)
       self.moncho_1_y = int((float(pygame.display.Info().current_h) * 49.0 ) / 768.0)
       self.moncho_2_x = int((float(pygame.display.Info().current_w) * 98.0 ) / 1024.0)
       self.moncho_2_y = int((float(pygame.display.Info().current_h) * 293.0 ) / 768.0)
       self.hug_male_1_x = int((float(pygame.display.Info().current_w) * 834.0 ) / 1024.0)
       self.hug_male_1_y = int((float(pygame.display.Info().current_h) * 193.0 ) / 768.0)
       self.hug_male_2_x = int((float(pygame.display.Info().current_w) * 702.0 ) / 1024.0)
       self.hug_male_2_y = int((float(pygame.display.Info().current_h) * 495.0 ) / 768.0)
       self.hug_female_1_x = int((float(pygame.display.Info().current_w) * 738.0 ) / 1024.0)
       self.hug_female_1_y = int((float(pygame.display.Info().current_h) * 184.0 ) / 768.0)
       self.hug_female_2_x = int((float(pygame.display.Info().current_w) * 797.0 ) / 1024.0)
       self.hug_female_2_y = int((float(pygame.display.Info().current_h) * 457.0 ) / 768.0)
       self.explosion_x = int((float(pygame.display.Info().current_w) * 705.0 ) / 1024.0)
       self.explosion_y = int((float(pygame.display.Info().current_h) * 428.0 ) / 768.0)
       self.mystery_x = int((float(pygame.display.Info().current_w) * 117.0 ) / 1024.0)
       self.mystery_y = int((float(pygame.display.Info().current_h) * 706.0 ) / 768.0)

       self.user_click = False
    def __init__(self):
       BaseState.__init__(self)

       self.background_color = (125, 158, 192)
       self.next_transition = VALID_STATES['MENU']
       self.cursor_x = 0
       self.cursor_y = 0

       self.letter_index = 0 # Tells how many letters the user has clicked.
       self.player_init = [] # Holds the player initials.

       image = cached_image_loader.get_image_to_screen_percent('gfx/iniciales.png')
       self.banner = BaseActor(0, image, "Banner", False, True, False)
       self.banner.set_position([pygame.display.Info().current_w // 2, (image.get_height() // 2) + 20])

       image2 = cached_image_loader.get_image_to_screen_percent('gfx/Fuente/_.png')
       self.underscore_c = BaseActor(1, image2, "Underscore center", False, True, False)
       self.underscore_c.set_position([pygame.display.Info().current_w // 2,
                                       self.banner.get_position()[1] + image.get_height() + 25])
       self.underscore_l = BaseActor(2, image2, "Underscore left", False, True, False)
       self.underscore_l.set_position([self.underscore_c.get_position()[0] - image2.get_width(),
                                       self.underscore_c.get_position()[1]])
       self.underscore_r = BaseActor(3, image2, "Underscore right", False, True, False)
       self.underscore_r.set_position([self.underscore_c.get_position()[0] + image2.get_width(),
                                       self.underscore_c.get_position()[1]])

       image = cached_image_loader.get_image_to_screen_percent('gfx/del.png')
       self.del_button = BaseActor(4, image, "Delete button", False, True, False)
       self.del_button.set_position([self.underscore_c.get_position()[0] + (2 * image2.get_width()),
                                     self.underscore_c.get_position()[1]])

       image = cached_image_loader.get_image_to_screen_percent('gfx/listo.png')
       self.done_button = BaseActor(5, image, "Done button", False, False, False)
       self.done_button.set_position([self.underscore_c.get_position()[0] + (3 * image2.get_width()),
                                     self.underscore_c.get_position()[1]])

       self.letters = {}

       letter_list = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h',
                      'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']

       image = cached_image_loader.get_image_to_screen_percent('gfx/Fuente/a.png')
       q_x_position = self.banner.rect.left + (image.get_width() // 2)
       q_y_position = int((float(pygame.display.Info().current_h) * 438.0 ) / 768.0)
       letter_sep = int((float(pygame.display.Info().current_w) * 10.0 ) / 1024.0)

       for l in letter_list:
          image = cached_image_loader.get_image_to_screen_percent('gfx/Fuente/' + l + '.png')
          letter_actor = BaseActor(89, image, string.upper(l), False, True, False)
          if l == 'a':
             q_x_position = self.banner.rect.left + image.get_width()
             q_y_position = int((float(pygame.display.Info().current_h) * 543.0) / 768.0)
          elif l == 'z':
             q_x_position = self.banner.rect.left + int(1.5 * image.get_width())
             q_y_position = int((float(pygame.display.Info().current_h) * 649.0) / 768.0)
          letter_actor.set_position([q_x_position, q_y_position])
          self.letters[l] = letter_actor
          if l == 'i':
             q_x_position += image.get_width() + (2 * letter_sep)
          else:
             q_x_position += image.get_width() + letter_sep

       self.letter_y = int((float(pygame.display.Info().current_h) * 265.0 ) / 768.0)
    def __init__(self):
       BaseState.__init__(self)

       random.seed(None)

       self.background_color = (125, 158, 192)

       self.next_transition = VALID_STATES['SCORE']
       self.cursor_x = 0
       self.cursor_y = 0
       self.user_click = False
       self.cancel = False

       self.time_left = 160
       self.then = pygame.time.get_ticks()
       self.wave = 0
       self.done = False
       self.max_npc = 15
       self.create_huggable = False
       self.change_angle = False
       self.create_enemy = False

       self.bckg_x = 0
       self.bckg_y = 0

       self.explosions = set()
       self.npcs = set()
       self.enemies = set()

       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_front.png')
       self.player = actor.OmnidirectionalActor(0, play_img, "Player", True)
       self.player.set_fps(5)
       self.player.set_angle(math_utils.PI / 2.0)
       self.player.set_velocity([0, 0])

       self.spawners = set()
       for i in range(8):
          spawner = actor.BaseActor(40 + i + 1, None, "Spawner " + str(i))
          self.spawners.add(spawner)

       # Add idle frames to the player:
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_side.png')
       self.player.add_idle_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_front.png')
       self.player.add_idle_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_side2.png')
       self.player.add_idle_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_idle_back.png')
       self.player.add_idle_frame(play_img)

       # Add moving frames to the player.
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_side_HUG_1.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_side_HUG_2.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_HUG_front_1.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_HUG_front_2.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_side_HUG_1_flipped.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_side_HUG_2_flipped.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_back_HUG_1.png')
       self.player.add_moving_frame(play_img)
       play_img = imloader.cached_image_loader.get_image_to_screen_percent('gfx/Player/player_walk_back_HUG_2.png')
       self.player.add_moving_frame(play_img)

       # Create a surface for the background.
       bg_w = int(float(pygame.display.Info().current_w * 1315) / 1024.0)
       bg_h = int(float(pygame.display.Info().current_h * 1280) / 768.0)
       self.background = pygame.Surface((bg_w, bg_h))
       self.game_area = pygame.Surface((bg_w, bg_h))

       self.game_area_center = [bg_w // 2, bg_h // 2]

       # Center the player.
       self.player.set_position(self.game_area_center)
       self.constraints = [int((95.0 * float(pygame.display.Info().current_w)) / 1024.0),
                           bg_w - int((95.0 * float(pygame.display.Info().current_w)) / 1024.0),
                           int((155.0 * float(pygame.display.Info().current_h)) / 768.0),
                           bg_h - int((155.0 * float(pygame.display.Info().current_h)) / 768.0)]

       # Place the spawners in position.
       positions = [(180, 200), (660, 200), (1140, 200), (1140, 662), (1140, 1055), (660, 1055), (180, 1055), (180, 662)]
       i = 0
       for spawner in self.spawners:
          spawner.set_position([(positions[i][0] * bg_w) / 1315, (positions[i][1] * bg_h) / 1280])
          i += 1
       
       # Create the floor.
       floor = background.TiledBackground(bg_w, bg_h, 'gfx/piso.png')

       # Create the walls for the top and the bottom (the same for both).
       bg_h = int((80.0 * float(pygame.display.Info().current_h)) / 768.0)
       walls_top = background.TiledBackground(bg_w, bg_h, 'gfx/Pared.png')
       bg_y = self.background.get_height() - int((80.0 * float(pygame.display.Info().current_h)) / 768.0)

       # Create the left walls.
       bg_h = int(float(pygame.display.Info().current_h * 1280) / 768.0)
       walls_left = background.TiledBackground(-1, bg_h, 'gfx/Pared2.png')
       _y = int((80.0 * float(pygame.display.Info().current_h)) / 768.0)
       walls_left.set_position((0, _y))

       # Create the right walls.
       walls_right = background.TiledBackground(-1, bg_h, 'gfx/Pared3.png')
       _x = self.background.get_width() - int((40.0 * float(pygame.display.Info().current_w)) / 1024.0)
       walls_right.set_position((_x, _y))

       # Build the background image.
       floor.draw(self.background)
       walls_top.set_position((0, 0))
       walls_top.draw(self.background)
       walls_left.draw(self.background)
       walls_right.draw(self.background)
       walls_top.set_position((0, bg_y))
       walls_top.draw(self.background)

       # Center the view on the player
       p_pos = self.player.get_position()
       (dist_x, dist_y) = (math.fabs(self.screen_center[0] - p_pos[0]), math.fabs(self.screen_center[1] - p_pos[1]))
       self.bckg_x -= dist_x
       self.bckg_y -= dist_y
                      
       self.player.set_constraints(self.constraints)

       self.cursor_x = self.screen_center[0]
       self.cursor_y = self.screen_center[1]
       self.vec_1 = (float(pygame.display.Info().current_w) - float(self.screen_center[0]), 0.0)
       self.vec_1 = math_utils.normalize_vector_2D(self.vec_1)

       self.font = pygame.font.Font('font/ProfaisalEliteRiqa/Profaisal-EliteRiqaV1.0.ttf', 22)

       self.score_text = self.font.render("Puntos:   " + str(1000), True, (0, 0, 0))
       self.time_text = self.font.render("Tiempo:   " + str(190), True, (0, 0, 0))
       self.wave_text = self.font.render("Oleada:   " + str(999), True, (0, 0, 0))

       text_w = max(self.font.size("Puntos:   " + str(1000))[0], 
                    max(self.font.size("Tiempo:   " + str(190))[0], self.font.size("Oleada: " + str(999))[0])) + 10
       self.text_h = (3 * self.font.size("Puntos:   " + str(1000))[1]) + 20
       self.text_box = pygame.Surface((text_w, self.text_h))
       self.text_h = self.font.size("Puntos:   " + str(1000))[1]
       self.text_box.set_alpha(128 + 64 + 32)

       self.reticule = imloader.cached_image_loader.get_image_to_screen_percent('gfx/reticula.png')
       self.ret_rect = self.reticule.get_rect()
       self.ret_rect.center = self.screen_center

       self.scare_dist = (250 * pygame.display.Info().current_h) / 768