PointClickEngine::Core::Drawable
Module for objects that can be rendered on screen
The Drawable module provides common properties and methods for all visual game objects. Any class that includes this module can be positioned, scaled, and rendered on screen.
Properties
position- World coordinates (x, y)size- Dimensions (width, height)scale- Scaling factor for renderingvisible- Whether the object should be drawn
Example
class MyObject
include Drawable
def draw
return unless visible
# Custom drawing code here
end
end
Instance methods
Returns the bounding rectangle of this object
The bounding rectangle defines the rectangular area occupied by this object in world coordinates. This is commonly used for collision detection and spatial queries.
Returns a Rectangle with the object's position and size
Checks if a point is inside this object's bounds
Performs a point-in-rectangle test to determine if the given point falls within this object's bounding area. Useful for click detection and spatial queries.
point - The point to test (world coordinates)
Returns true if the point is inside the bounds, false otherwise
if my_object.contains_point?(mouse_position)
puts "Object clicked!"
end
Abstract method that must be implemented by including classes
This method should contain the actual rendering logic for the object. It will be called automatically during the rendering phase if the object is visible.