Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML.rb (SFML wrappe for Ruby)  (Read 1984 times)

0 Members and 1 Guest are viewing this topic.

SealtielFreak

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML.rb (SFML wrappe for Ruby)
« on: March 05, 2023, 09:33:52 pm »
Hello everyone.  :D

I've been working on a SFML wrapper for Ruby, I've been testing RubyRice and SFML in C++ for a while, but I noticed that the performance left a lot to be desired. So I decided to continue switching to CSFML and C, the project is not finished yet but it is already possible to compile the package to install in Ruby, it installs the dependencies automatically (In case of Linux and Windows with MSYS2)

The project tries to be as faithful to the Ruby syntax (snake_case and properties instead of "getters/setters") as pysdl2 does with the pysdl2.ext module, I leave a sample of the code that runs without problems:

require "sfml"

window = SFML::Window.new(SFML::VideoMode.new(640, 480, 32), "SFML in Ruby")
event = SFML::Event.new

while window.is_open?
  while window.poll_event! event
    case event.type
    when "closed"
      puts "Goodbye!"
      window.close!
    when "resized"
      puts "Resized: #{event.size}"
    when "key-pressed"
      puts "Key pressed: #{event.key}"
    end
  end

  puts window.position.to_s
 
  window.display
end

 

I reiterate, the project is not finished yet but at least it already has bases to build on, it will be in constant change  :P, Here is the project repository on Github: https://github.com/SealtielFreak/sfml.rb

Doubts or questions are welcome  ;D.