Sha256: 3a8a8a4d7b91c851cdc43f553c2dc82f902550c7076918361aefea123f033082
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
module Game class Window class << self def fps end def delta end end class Window include MetaTools attr_reader :started_at # Initialize the game window. # # @abstract Override and call `super` after you've setup the width, height, and title. def initialize(options={}) # Complain if @title isn't set? # Complain if @width isn't set? # Complain if height isn't set? init_window @started_at = Time.now end attr_writer :title def title(value=nil) @title = value unless value.nil? @title end attr_writer :width def width(value=nil) @width = value unless value.nil? @width end attr_writer :height def height(value=nil) @height = value unless value.nil? @height end attr_writer :fullscreen def fullscreen(value=nil) @fullscreen = value unless value.nil? @fullscreen end def entities @entities ||= [] end def add_entity(entity, *args, &blk) entity_name, entity = entity, args.shift if entity.is_a?(Symbol) entity_name ||= entity.to_s.split('::').last.gsub(/[A-Z]/, '_\0').gsub(/^_/, '').downcase meta_def(entity_name) { entity } entities << entity_instance = entity.new(@window, *args) yield(entity_instance) if block_given? entity end # Initialize the underlying adapter window. # # @abstract Must be overridden by an adapter. def init_window raise NotImplementedError end end def milliseconds_since_start end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
game-0.0.1 | lib/game/window.rb |