module

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 rendering
  • visible - Whether the object should be drawn

Example

class MyObject
  include Drawable

  def draw
    return unless visible
    # Custom drawing code here
  end
end

Instance methods

after_yaml_deserialize(ctx : YAML::ParseContext)
Source
bounds

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

Source
contains_point?(point : Raylib::Vector2) : Bool

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
Source
draw

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.

Source
draw_at_screen_pos(screen_pos : Raylib::Vector2)
Source
hide
Source
position

World position of the object (x, y coordinates)

Source
position=(position : Raylib::Vector2)

World position of the object (x, y coordinates)

Source
scale

Scaling factor applied during rendering (1.0 = normal size)

Source
scale=(scale : Float32)

Scaling factor applied during rendering (1.0 = normal size)

Source
show
Source
size

Size of the object (width, height)

Source
size=(size : Raylib::Vector2)

Size of the object (width, height)

Source
toggle_visibility
Source
visible

Whether this object should be rendered

Source
visible=(visible : Bool)

Whether this object should be rendered

Source