class GameObject
class GameObject
Attributes
collider[R]
x[R]
y[R]
Public Class Methods
new(x, y, width, heigth, solid = true)
click to toggle source
# File lib/entities/gameobject.rb, line 9 def initialize(x, y, width, heigth, solid = true) @x = x @y = y @collider = nil @collider = Collider.new(x, y, width, heigth) if solid @done = false end
Public Instance Methods
collide?(other)
click to toggle source
# File lib/entities/gameobject.rb, line 34 def collide?(other) return false if @collider.nil? || other.collider.nil? || other == self @collider.collides?(other.collider) end
collision_detect(_objects)
click to toggle source
# File lib/entities/gameobject.rb, line 39 def collision_detect(_objects) nil end
done?()
click to toggle source
# File lib/entities/gameobject.rb, line 26 def done? @done end
draw()
click to toggle source
# File lib/entities/gameobject.rb, line 21 def draw @sprite.draw(@x, @y, 1) if solid? @sprite.draw(@x, @y, 3) unless solid? end
hitted(_by)
click to toggle source
# File lib/entities/gameobject.rb, line 43 def hitted(_by) # puts "#{self} hitted by #{by}" end
solid?()
click to toggle source
# File lib/entities/gameobject.rb, line 17 def solid? !@collider.nil? end
update()
click to toggle source
# File lib/entities/gameobject.rb, line 30 def update fail NotImplementedError, 'Abstract method, IMPLEMENT update (call @sprite.update!)' end