<commit_before># A moveable has a shape, speed etc.
#
# TODO moveable should only have active components, like accelerate etc. Positioning etc. should go to Thing.
#
module Moveable extend Trait
  
  Accelerate = :accelerate; def self.accelerate strength = 1.0; [Accelerate, strength] end
  Left       = :move_left;  def self.left       strength = 1.0; [Left,       strength] end
  Right      = :move_right; def self.right      strength = 1.0; [Right,      strength] end
  Up         = :move_up;    def self.up         strength = 1.0; [Up,         strength] end
  Down       = :move_down;  def self.down       strength = 1.0; [Down,       strength] end
  Backwards  = :backwards;  def self.backwards  strength = 1.0; [Backwards,  strength] end
  # TODO Jump       = :jump
  
  def self.included klass
    if klass <= Thing
      klass.extend ClassMethods
    else
      # extend with Sprite Moveable
    end
  end
  
  module ClassMethods
    
    # Initial setting.
    #
    def friction amount = nil, &block
      to_execute = block_given? ? block : lambda { amount }
      InitializerHooks.register self do
        self.friction = to_execute[]
      end
    end
    def velocity amount = nil, &block
      to_execute = block_given? ? block : lambda { amount }
      InitializerHooks.register self do
        self.velocity = to_execute[]
      end
    end<commit_msg>+ slight rewrite<commit_after># A moveable has a shape, speed etc.
#
# TODO moveable should only have active components, like accelerate etc. Positioning etc. should go to Thing.
#
module Moveable extend Trait
  
  Accelerate = :accelerate; def self.accelerate strength = 1.0; [Accelerate, strength] end
  Left       = :move_left;  def self.left       strength = 1.0; [Left,       strength] end
  Right      = :move_right; def self.right      strength = 1.0; [Right,      strength] end
  Up         = :move_up;    def self.up         strength = 1.0; [Up,         strength] end
  Down       = :move_down;  def self.down       strength = 1.0; [Down,       strength] end
  Backwards  = :backwards;  def self.backwards  strength = 1.0; [Backwards,  strength] end
  # TODO Jump       = :jump
  
  def self.included klass
    klass.extend klass <= Thing ? ThingClassMethods : SpriteClassMethods
  end
  
  module SpriteClassMethods
    
  end
  
  module ThingClassMethods
    
    # Initial setting.
    #
    def friction amount = nil, &block
      to_execute = block_given? ? block : lambda { amount }
      InitializerHooks.register self do
        self.friction = to_execute[]
      end
    end
    def velocity amount = nil, &block
      to_execute = block_given? ? block : lambda { amount }
      InitializerHooks.register self do
        self.velocity = to_execute[]
      end
    end
{'fraction_non_alphanumeric': 0.08200290275761973, 'fraction_numerical': 0.008708272859216255, 'mean_word_length': 2.3176895306859207, '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': '6407151', 'n_tokens_mistral': 860, 'n_tokens_neox': 826, 'n_words': 274}