<commit_before>class Ball
  SIZE = 16

  attr_reader :x, :y, :angle, :speed
  def initialize
    @x = Pong::WIDTH/2
    @y = Pong::HEIGHT/2

    @angle = 45
    @speed = 6
  end

  def move!
    dx = Gosu.offset_x(angle, speed)
    dy = Gosu.offset_y(angle, speed)

    @x += dx
    @y += dy
  end

  def x1; @x - SIZE/2; end
  def x2; @x + SIZE/2; end
  def y1; @y - SIZE/2; end
  def y2; @y + SIZE/2; end

  def draw(window)
    color = Gosu::Color::RED

    window.draw_quad(
      x1, y1, color,
      x1, y2, color,
      x2, y2, color,
      x2, y1, color,
    )
  end
end<commit_msg>Bounce off edges<commit_after>class Ball
  SIZE = 16

  attr_reader :x, :y, :angle, :speed
  def initialize
    @x = Pong::WIDTH/2
    @y = Pong::HEIGHT/2

    @angle = 135
    @speed = 6
  end

  def move!
    dx = Gosu.offset_x(angle, speed)
    dy = Gosu.offset_y(angle, speed)

    @x += dx
    @y += dy

    if @y < 0
      @y = 0
      @angle = Gosu.angle(0, 0, dx, -dy)
    end

    if @y > Pong::HEIGHT
      @y = Pong::HEIGHT
      @angle = Gosu.angle(0, 0, dx, -dy)
    end
  end

  def x1; @x - SIZE/2; end
  def x2; @x + SIZE/2; end
  def y1; @y - SIZE/2; end
  def y2; @y + SIZE/2; end

  def draw(window)
    color = Gosu::Color::RED

    window.draw_quad(
      x1, y1, color,
      x1, y2, color,
      x2, y2, color,
      x2, y1, color,
    )
  end
end
{'fraction_non_alphanumeric': 0.14558823529411766, 'fraction_numerical': 0.03897058823529412, 'mean_word_length': 1.9019189765458422, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2412206', 'n_tokens_mistral': 635, 'n_tokens_neox': 585, 'n_words': 167}