<commit_before>module PlanetDefense
  class PlayState < Chingu::GameState
    attr_reader :player, :asteroids, :score, :timer
    attr_accessor :pause

    def initialize( options = {})
      super
      @player = Player.new(self)
      @@asteroids = 5.times.map { Asteroid.new(self) }
      @background_image = Gosu::Image.new($window, "media/gfx/space-with-earth.jpg", true)
      @music = Gosu::Song.new($window, "media/sounds/background.wav")
      @font = Gosu::Font.new($window, "media/fonts/MuseoSans_300.otf", 43)
      @count = 0  
      @pause = false
      @running = true
      @@score = 0
      @lives = 3
      @planet_health = 1000
      @music.volume = 0.3
      @music.play(looping = true) unless @pause == true || defined? RSpec
      $window.caption = "Planet Defense #{PlanetDefense::VERSION} Game Objects: #{game_objects}"
      cursor = Gosu::Image.new($window, 'media/gfx/cursor.png', true)
      icons  = Gosu::Image.load_tiles($window, 'media/gfx/icons.png', 16, 16, false)
      @menu = RingMenu.new :radius => 400, :opaque => false, :modal => true, :icon_rotation => 2, 
        :x_radius => 200, :y_radius => 100 do |m|
        m.cursor cursor, :scale => 2.5
        m.font 'Helvetica', 20
        
        m.item('QUIT TO MENU',   icons[1], :scale => 2) { end_game }
        m.item('RETURN TO GAME',  icons[3], :scale => 2) { return_to_game }
        m.item('OPTIONS',   icons[2], :scale => 2) { push_game_state( OptionsState ) }
        m.item('HIGH SCORES',  icons[0], :scale => 2) { push_game_state( HighScoresState ) }
      end

    end

    def return_to_game
      PlanetDefense::RingMenu::Icon.destroy_all
      @pause = false
      pop_game_state()
    end
   
    def confirm_exit
      @pause = true
      push_game_state @menu
    end

    def end_game
      @running = false
      pop_game_state()
      push_game_state( MenuState )
    end

    def button_down(id)
      if id == Gosu::Button::KbP
        if @pause == false
          @pause = true
          @music.pause()
        else
          @pause = false
          @music.play()
        end
      end
      if id == Gosu::Button::KbQ
        @running = false
        close
      end
      if $window.button_down? Gosu::Button::KbR
        refresh_game
      end
      if id == Gosu::Button::KbEscape
        confirm_exit
      end
    end
  
    def update
      super
      if @running == true and @pause == false

        # Win game at 1000 points
        if @@score > 500
          pop_game_state()
          push_game_state( GameWon )
          @running = false
          @music.pause()
          stop_game
        end
<commit_msg>Increasing winning score<commit_after>module PlanetDefense
  class PlayState < Chingu::GameState
    attr_reader :player, :asteroids, :score, :timer
    attr_accessor :pause

    def initialize( options = {})
      super
      @player = Player.new(self)
      @@asteroids = 5.times.map { Asteroid.new(self) }
      @background_image = Gosu::Image.new($window, "media/gfx/space-with-earth.jpg", true)
      @music = Gosu::Song.new($window, "media/sounds/background.wav")
      @font = Gosu::Font.new($window, "media/fonts/MuseoSans_300.otf", 43)
      @count = 0  
      @pause = false
      @running = true
      @@score = 0
      @lives = 3
      @planet_health = 1000
      @music.volume = 0.3
      @music.play(looping = true) unless @pause == true || defined? RSpec
      $window.caption = "Planet Defense #{PlanetDefense::VERSION} Game Objects: #{game_objects}"
      cursor = Gosu::Image.new($window, 'media/gfx/cursor.png', true)
      icons  = Gosu::Image.load_tiles($window, 'media/gfx/icons.png', 16, 16, false)
      @menu = RingMenu.new :radius => 400, :opaque => false, :modal => true, :icon_rotation => 2, 
        :x_radius => 200, :y_radius => 100 do |m|
        m.cursor cursor, :scale => 2.5
        m.font 'Helvetica', 20
        
        m.item('QUIT TO MENU',   icons[1], :scale => 2) { end_game }
        m.item('RETURN TO GAME',  icons[3], :scale => 2) { return_to_game }
        m.item('OPTIONS',   icons[2], :scale => 2) { push_game_state( OptionsState ) }
        m.item('HIGH SCORES',  icons[0], :scale => 2) { push_game_state( HighScoresState ) }
      end

    end

    def return_to_game
      PlanetDefense::RingMenu::Icon.destroy_all
      @pause = false
      pop_game_state()
    end
   
    def confirm_exit
      @pause = true
      push_game_state @menu
    end

    def end_game
      @running = false
      pop_game_state()
      push_game_state( MenuState )
    end

    def button_down(id)
      if id == Gosu::Button::KbP
        if @pause == false
          @pause = true
          @music.pause()
        else
          @pause = false
          @music.play()
        end
      end
      if id == Gosu::Button::KbQ
        @running = false
        close
      end
      if $window.button_down? Gosu::Button::KbR
        refresh_game
      end
      if id == Gosu::Button::KbEscape
        confirm_exit
      end
    end
  
    def update
      super
      if @running == true and @pause == false

        # Win game at 1000 points
        if @@score > 1000
          pop_game_state()
          push_game_state( GameWon )
          @running = false
          @music.pause()
          stop_game
        end

{'fraction_non_alphanumeric': 0.1257099583491102, 'fraction_numerical': 0.01836425596365013, 'mean_word_length': 2.127886323268206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1057414', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1721, 'n_words': 410}