Sha256: 582deeedd0696d920897d8dda66e657fc14e2ea0ea657daaa8ffc218fb2a0565

Contents?: true

Size: 931 Bytes

Versions: 10

Compression:

Stored size: 931 Bytes

Contents

#
#
class RemoveShapes
  
  attr_reader :shapes
  delegate :clear, :empty?, :to => :@shapes
  
  def initialize
    @shapes = []
  end
  
  #
  #
  def add shape
    shapes << shape
  end
  
  #
  #
  def remove_from environment, moveables
    # This iterator makes an assumption of one Shape per Star making it safe to remove
    # each Shape's Body as it comes up
    # If our Stars had multiple Shapes, as would be required if we were to meticulously
    # define their true boundaries, we couldn't do this as we would remove the Body
    # multiple times
    # We would probably solve this by creating a separate @remove_bodies array to remove the Bodies
    # of the Stars that were gathered by the Player
    #
    return if empty?
    shapes.each do |shape|
      environment.remove shape
      moveables.remove shape # TODO Should the environment be the owner of the moveables? Probably, yes.
    end
    clear
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gosu_extensions-0.2.9 lib/core/remove_shapes.rb
gosu_extensions-0.2.8 lib/core/remove_shapes.rb
gosu_extensions-0.2.7 lib/core/remove_shapes.rb
gosu_extensions-0.2.6 lib/core/remove_shapes.rb
gosu_extensions-0.2.5 lib/core/remove_shapes.rb
gosu_extensions-0.2.4 lib/core/remove_shapes.rb
gosu_extensions-0.2.3 lib/core/remove_shapes.rb
gosu_extensions-0.2.2 lib/core/remove_shapes.rb
gosu_extensions-0.2.1 lib/core/remove_shapes.rb
gosu_extensions-0.2.0 lib/core/remove_shapes.rb