<commit_before>require 'gosu'
require_relative 'tile'
require_relative 'player'

class Level
  def initialize(window, player, level_data)
    @window = window
    @tiles = []
    @player = player
    @level_data = level_data
    @total_rows = 0
    @total_columns = 0
    @exit_reached = false
    if @level_data
      @total_rows = @level_data.length
      if @total_rows > 0
        @total_columns = @level_data.first.length
      end
      setup_level
    end
  end

  def setup_level
  end

  def button_down(id)
  end

  def update
  end

  def draw
  end

end
<commit_msg>Add code for button down function<commit_after>require 'gosu'
require_relative 'tile'
require_relative 'player'

class Level
  def initialize(window, player, level_data)
    @window = window
    @tiles = []
    @player = player
    @level_data = level_data
    @total_rows = 0
    @total_columns = 0
    @exit_reached = false
    if @level_data
      @total_rows = @level_data.length
      if @total_rows > 0
        @total_columns = @level_data.first.length
      end
      setup_level
    end
  end

  def setup_level
    @level_data.each_with_index do |row_data, row|
      column = 0
      row_data.each_char do |cell_type|
        tile = Tile.new(@window, column, row, cell_type)
        # change behavior depending on cell_type
        if tile.is_start?
          @player.move_to(column, row)
        end
        @tiles.push(tile)
        column += 1
      end
    end
  end

  def button_down(id)
    if level_over?
      return
    end
    column_delta = 0
    row_delta = 0
    if id == Gosu::KbLeft
      column_delta = -1
    elsif id == Gosu::KbRight
      column_delta = 1
    end
    if id == Gosu::KbUp
      row_delta = -1
    elsif id == Gosu::KbDown
      row_delta = 1
    end
    if move_valid?(@player, column_delta, row_delta)
      @player.move_by(column_delta, row_delta)
      tile = get_tile(@player.column, @player.row)
      if tile.is_exit?
        @exit_reached = true
        tile.hide!
      else
        @player.pick_up(tile)
      end
    end
  end

  def update
  end

  def draw
  end

end

{'fraction_non_alphanumeric': 0.08127376425855513, 'fraction_numerical': 0.006653992395437262, 'mean_word_length': 2.2534775888717156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4780535', 'n_tokens_mistral': 740, 'n_tokens_neox': 715, 'n_words': 184}