Implemented event system, Implemented initial bit of scripting system, Stubbed component system. Entities can now use the scripting system to place their 'decorations'

This commit is contained in:
2019-09-26 12:13:08 -05:00
parent e41a2b6524
commit b6d7a6ebdb
24 changed files with 293 additions and 80 deletions

View File

@@ -4,6 +4,7 @@ class IMICFPS
# A game object is any renderable thing
class Entity
include CommonMethods
include Scripting
attr_accessor :scale, :visible, :renderable, :backface_culling
attr_accessor :position, :orientation, :velocity
@@ -38,6 +39,8 @@ class IMICFPS
@delta_time = Gosu.milliseconds
@last_position = Vector.new(@position.x, @position.y, @position.z)
load_scripts
setup
if @bound_model
@@ -52,6 +55,20 @@ class IMICFPS
return self
end
def load_scripts
@manifest.scripts.each do |script|
instance_eval(script.source)
end
end
def method_missing(method, *args, &block)
unless component = Component.get(method)
raise NoMemoryError, "undefined method '#{method}' for #<#{self.class}:#{self.object_id}>"
else
return component
end
end
def collidable?
@collidable.include?(@collision)
end