Class: AGL::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/minigl/global.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, w, h) ⇒ Rectangle

Returns a new instance of Rectangle.



9
10
11
# File 'lib/minigl/global.rb', line 9

def initialize x, y, w, h
	@x = x; @y = y; @w = w; @h = h
end

Instance Attribute Details

#hObject

Returns the value of attribute h.



7
8
9
# File 'lib/minigl/global.rb', line 7

def h
  @h
end

#wObject

Returns the value of attribute w.



7
8
9
# File 'lib/minigl/global.rb', line 7

def w
  @w
end

#xObject

Returns the value of attribute x.



7
8
9
# File 'lib/minigl/global.rb', line 7

def x
  @x
end

#yObject

Returns the value of attribute y.



7
8
9
# File 'lib/minigl/global.rb', line 7

def y
  @y
end

Instance Method Details

#intersects(r) ⇒ Object



13
14
15
# File 'lib/minigl/global.rb', line 13

def intersects r
	@x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y
end