Ruby, gtk and maybe cairo

hello,

i’m begginer in ruby gtk

i put images in gtk::fixed / ScrolledWindow / Fixed / Window

like this :

topWindow = Gtk::Window.new
scrollbars = Gtk::ScrolledWindow.new.set_size_request xWidth, yWidth
fixed = Gtk::Fixed.new
imgBg = Gtk::Image.new file: “background.jpg”
img1 = Gtk::Image.new file: “img1.png”
img2 = Gtk::Image.new file: “img2.png”
fixed.put imgFond, 0, 0
fixed.put img1, x1, y1
fixed.put img2, x2, y2
scrollbars.add fixed
topWindow.add scrollbars
topWindow.show_all

my goal is to move these images (img1, img2, etc…) but I want to know
if they overlap (and how they overlap) to manage the collisions. I tried
with cairo, I thought I could use paths and intersections but it’s very
complicated … :frowning:

Would anyone have a solution? maybe samples? or docs?
The doc gtk is mainly with c and it’s not easy to learn ruby/gtk.

µgeek.

Arno Root wrote in post #1185416:

i’m begginer in ruby gtk

my goal is to move these images (img1, img2, etc…) but I want to know
if they overlap (and how they overlap) to manage the collisions.

You need a widget wich manage vector drawing. So he can manage
ressources as
gouping vector / bounding box / collisions (overlapp) detection
/ multiple layer…

Gtk have not this kind of widget.

I tried with cairo, I thought I could use paths and intersections but it’s
very complicated … :frowning:
Would anyone have a solution? maybe samples? or docs?
in ruby-gtk and ruby-gdk , there are samples which are very useful:

Ruby/lib/ruby/gems/x.y.z/gems/gtkx-y/sample/gtk-demo/main.rb
use
> gem env
to see where the gems data : INSTALLATION DIRECTORY/gems/gtk…

Gtk is hard to use directly. You can begin with DSL : Shoes (green shoes
and/or shoes4 with jruby).

I have done my own DSL, Ruiby, with some games as samples :
GitHub - glurp/dsl-gtk: DSL for make a simple ruby GUI application
GitHub - glurp/gtk-rrobots: rrobots
Ruiby | RubyGems.org | your community gem host

The doc gtk is mainly with c and it’s not easy to learn ruby/gtk.

Python-gtk ( and perl-gtl) doc can be use :
Gtk2Hs Tutorial: Appendix

In green-shoes source (and in Ruiby, dsl/canvas.rb and dsl/plot.rb) you
can see many ruby/gtk/cairo stuff.

For game development, Gosu is a must :

  • It use Opengl for drawing 2D, so drawing performances are good,
  • It manage image/sprite, scale/rotation, sound, mouse …

ang | RubyGems.org | your community gem host

thanks a lot for your answer,

Gtk does not have this kind of widget.
Outch! Yes, i understand … a lot of work for nothing :frowning:

Thank you also for the examples, I will study them closely, but as you
advised me, I will surely try Gosu.
… or maybe rubygame or sdl

Thank you again,

µgeek.