<commit_before>Pool = require './pool.coffee'

class GameObject
  constructor: (x, y) ->
    @position =
        'x': x || 0
        'y': y || 0

    @active = true
    @fixed = false     # static positioning for UI elements
    @scale = 1
    @rotation = 0
    @glow = 0
    @colors =
        'red': 255
        'green': 255
        'blue': 255
        'alpha': 1
    @children = new Pool
    @i = 0

  ###
   * @description Draw child objects
   * @param {CanvasRenderingContext2D} context
  ###
  draw: (context, offsetX, offsetY) ->
    return if not @active

    offsetX = offsetX || 0
    offsetY = offsetY || 0

    @i = @children.length
    while @i--
      @children.at(@i).draw context, offsetX, offsetY

  ###
   * @description Update all child objects
   * @param {Number} delta Time since last update (in seconds)
  ###
  update: (delta) ->
    return if not @active

    @i = @children.length
    while @i--
      @children.at(@i).update delta

  ###
   * @description Add an object to the draw/update loop
   * @param {Shape} object
  ###
  add: (object) ->
    @children.add object
    object.parent = this

  ###
   * @description Clean up child objects
  ###
  destroy: ->
    @i = @children.length
    while @i--
      if typeof @children.at(@i).destroy == "function"
        @children.at(@i).destroy()

  ###
   * @description Getter/setter for color value
  ###
  @property 'color',
    get: ->
      return "rgba(#{@colors.red}, #{@colors.green}, #{@colors.blue}, #{@colors.alpha})"
    set: (color) -><commit_msg>Lazy instantiation of GameObj child container<commit_after>Pool = require './pool.coffee'

class GameObject
  constructor: (x = 0, y = 0) ->
    @position =
        'x': x
        'y': y

    @fixed = false     # static positioning for UI elements
    @scale = 1
    @rotation = 0
    @glow = 0
    @colors =
        'red': 255
        'green': 255
        'blue': 255
        'alpha': 1
    @i = 0

  ###
   * @description Draw child objects
   * @param {CanvasRenderingContext2D} context
  ###
  draw: (context, offsetX = 0, offsetY = 0) ->
    return if @children is undefined

    @i = @children.length
    while @i--
      @children.at(@i).draw context, offsetX, offsetY

  ###
   * @description Update all child objects
   * @param {Number} delta Time since last update (in seconds)
  ###
  update: (delta) ->
    return if @children is undefined

    @i = @children.length
    while @i--
      @children.at(@i).update delta

  ###
   * @description Add an object to the draw/update loop
   * @param {Shape} object
  ###
  add: (object) ->
    @children = new Pool() if @children is undefined # be lazy

    @children.add object
    object.parent = this

  ###
   @description Clean up child objects
  ###
  destroy: ->
    return if @children is undefined

    @i = @children.length
    while @i--
      @children.at(@i).destroy() if typeof @children.at(@i).destroy is 'function'

  ###
   @description Getter/setter for color value
  ###
  @property 'color',
    get: ->
      return "rgba(#{@colors.red}, #{@colors.green}, #{@colors.blue}, #{@colors.alpha})"
    set: (color) ->
{'fraction_non_alphanumeric': 0.148895292987512, 'fraction_numerical': 0.012167787383925712, 'mean_word_length': 2.351931330472103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4081689', 'n_tokens_mistral': 1039, 'n_tokens_neox': 981, 'n_words': 305}