<commit_before>require 'gosu'
require_relative 'level.rb'
require_relative 'player.rb'

##
# The main game engine

class Game < Gosu::Window
  ##
  # How much to scale the window by
  SCALE = 3
  ##
  # Width of the window in pixels before scaling
  WIDTH = 32 * 10
  ##
  # Width of the window in pixels before scaling
  HEIGHT = 25 * 10
  ##
  # Light green color
  LIGHT_GREEN = 0xff00ff22
  ##
  # Dark green color
  DARK_GREEN = 0xff00660E
  ##
  # Create the game, setting up the level and the player
  def initialize
    super WIDTH * SCALE, HEIGHT * SCALE, false
    self.caption = "Commander Keen in Revenge of the Shikadi!"

    @level = Level.new(self)
    @player = Player.new(self)

    @menu_options = [
      :Play,
      :Instructions,
      :"Save/Load",
      :Quit
    ]

    @menu_selection = 0

    @in_menu = true
    @paused = false
  end

  ##
  # Update the logic of the game by updating the player
  # and each component of the level
  def update
    unless @in_menu
      @player.update @level
      @level.update
    end
  end

  ##
  # draw the components of the game, the player and each element of the level
  def draw
   if @in_menu
     i = 0
     for option in @menu_options
       color = option == @menu_options[@menu_selection] ? LIGHT_GREEN : DARK_GREEN
       Gosu::Image.from_text(self, option.to_s, "Times New Roman", 24 * SCALE).draw(100 * SCALE, 50 * i * SCALE + 30 * SCALE, 0, 1, 1, color)
       i += 1
     end
   else
      @level.draw SCALE, @player.x * SCALE, @player.y * SCALE
      @player.draw SCALE
    end
  end

  ##
  # Callback for a button press
  # If ESC or Q is pressed, quit the game
  # If LEFT_ALT is pressed, toggle the pogo stick
  def button_down(id)
    if id == Gosu::KbQ
      close
    elsif id == Gosu::KbEscape
      @in_menu = true
      @paused = true
    elsif id == Gosu::KbLeftAlt
      @player.toggle_pogo
    elsif id == Gosu::KbSpace  
      @player.shoot
    elsif id == Gosu::KbDown || id == Gosu::GpDown
      @menu_selection += 1
      @menu_selection %= @menu_options.size
    elsif id == Gosu::KbUp || id == Gosu::GpUp
      @menu_selection += @menu_options.size - 1
      @menu_selection %= @menu_options.size
    elsif id == Gosu::KbReturn
      if @in_menu
        if @menu_options[@menu_selection] == :Play
          @in_menu = false
          @paused = true
        elsif @menu_options[@menu_selection] == :Quit
          close
        end
      end
    end
  end

  ##
  # Run the game
  def run
    # show the window
    show
  end
end<commit_msg>change menu option play to resume after game starts<commit_after>require 'gosu'
require_relative 'level.rb'
require_relative 'player.rb'

##
# The main game engine

class Game < Gosu::Window
  ##
  # How much to scale the window by
  SCALE = 3
  ##
  # Width of the window in pixels before scaling
  WIDTH = 32 * 10
  ##
  # Width of the window in pixels before scaling
  HEIGHT = 25 * 10
  ##
  # Light green color
  LIGHT_GREEN = 0xff00ff22
  ##
  # Dark green color
  DARK_GREEN = 0xff00660E
  ##
  # Create the game, setting up the level and the player
  def initialize
    super WIDTH * SCALE, HEIGHT * SCALE, false
    self.caption = "Commander Keen in Revenge of the Shikadi!"

    @level = Level.new(self)
    @player = Player.new(self)

    @menu_options = [
      :Play,
      :Instructions,
      :"Save/Load",
      :Quit
    ]

    @menu_selection = 0

    @in_menu = true
    @paused = false
  end

  ##
  # Update the logic of the game by updating the player
  # and each component of the level
  def update
    unless @in_menu
      @player.update @level
      @level.update
    end
  end

  ##
  # draw the components of the game, the player and each element of the level
  def draw
   if @in_menu
     i = 0
     for option in @menu_options
       color = option == @menu_options[@menu_selection] ? LIGHT_GREEN : DARK_GREEN
       Gosu::Image.from_text(self, option.to_s, "Times New Roman", 24 * SCALE).draw(100 * SCALE, 50 * i * SCALE + 30 * SCALE, 0, 1, 1, color)
       i += 1
     end
   else
      @level.draw SCALE, @player.x * SCALE, @player.y * SCALE
      @player.draw SCALE
    end
  end

  ##
  # Callback for a button press
  # If ESC or Q is pressed, quit the game
  # If LEFT_ALT is pressed, toggle the pogo stick
  def button_down(id)
    if id == Gosu::KbQ
      close
    elsif id == Gosu::KbEscape
      @in_menu = true
      @paused = true
    elsif id == Gosu::KbLeftAlt
      @player.toggle_pogo
    elsif id == Gosu::KbSpace  
      @player.shoot
    elsif id == Gosu::KbDown || id == Gosu::GpDown
      @menu_selection += 1
      @menu_selection %= @menu_options.size
    elsif id == Gosu::KbUp || id == Gosu::GpUp
      @menu_selection += @menu_options.size - 1
      @menu_selection %= @menu_options.size
    elsif id == Gosu::KbReturn
      if @in_menu
        if @menu_options[@menu_selection] == :Play || @menu_options[@menu_selection] == :Resume
          @menu_options[@menu_selection] = :Resume
          @in_menu = false
          @paused = true
        elsif @menu_options[@menu_selection] == :Quit
          close
        end
      end
    end
  end

  ##
  # Run the game
  def run
    # show the window
    show
  end
end
{'fraction_non_alphanumeric': 0.09720092024539877, 'fraction_numerical': 0.014187116564417178, 'mean_word_length': 2.37015503875969, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4755228', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1761, 'n_words': 559}