<commit_before># This module is not considered part of the 'core' Kona library.
# Instead, consider it an extension providing boilerplate that may be of use.
# You may choose to use some, all, or none of it in the interest of
# implementing specific functionality yourself

class Kona.Projectile extends Kona.Entity
  constructor: (opts={}) ->
    super(opts)
    @speed = opts.speed || 10

  update: ->
    super()
    @position.x += @speed * @direction.dx
    if @hasLeftCollisions() || @hasRightCollisions()
      for name, list of @neighborEntities()
        for ent in list
          if (@leftCollision(ent) || @rightCollision(ent)) && ent.solid
            ent.destroy() if _.contains(@destructibles, name)
            @destroy()

    @destroy() if @position.x < 0 || @position.x > Kona.Canvas.width
<commit_msg>On projectile contact, check for entity#hit() else assume destroy()<commit_after># This module is not considered part of the 'core' Kona library.
# Instead, consider it an extension providing boilerplate that may be of use.
# You may choose to use some, all, or none of it in the interest of
# implementing specific functionality yourself

class Kona.Projectile extends Kona.Entity
  constructor: (opts={}) ->
    super(opts)
    @speed = opts.speed || 10

  update: ->
    super()
    @position.x += @speed * @direction.dx
    if @hasLeftCollisions() || @hasRightCollisions()
      for name, list of @neighborEntities()
        for ent in list
          if (@leftCollision(ent) || @rightCollision(ent)) && ent.solid
            if _.contains(@destructibles, name)
              if ent.hit? then ent.hit() else ent.destroy()
            @destroy()

    @destroy() if @position.x < 0 || @position.x > Kona.Canvas.width

{'fraction_non_alphanumeric': 0.11347926267281105, 'fraction_numerical': 0.0034562211981566822, 'mean_word_length': 3.1357142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1965992', 'n_tokens_mistral': 500, 'n_tokens_neox': 485, 'n_words': 183}