-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Not sure if you're still actively developing, but if you are, then you might consider sub-classing Console and get the root_console as a separate class. It'll allow you to get rid of having that third parameter in the constructor while still being able to pass rootconsoles everywhere you pass regular consoles. It seems more rubyesque to do it that way.
Here's an example from my port:
module Rogue
class RootConsole < Console
def initialze(width, height)
if width < 0
fail ArgumentError, "width must be non-negative, was #{width}"
elsif height < 0
fail ArgumentError, "width must be non-negative, was #{width}"
end
@width = width
@height = height
@clear_cell = Console.clear_cell
@out_of_bounds_cell = Console.out_of_bounds_cell
@ptr = nil
ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
end
def self.instance
@instance ||= create_instance
end
def self.create_instance
unless Rogue::System.initialized?
error_message = "Rogue::System.initialize has not been called yet."
fail error_message
end
RootConsole.new(System.SCREEN_WIDTH, System.SCREEN_HEIGHT)
end
private_class_method :create_instance
end
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels