Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu News / Gosu 0.7.21 released
- By jlnr (dev) Date 2010-06-13 15:08
Hey folks,

Gosu 0.7.21 is out in all common flavors, and has some interesting new features:

2010-05-13: Ruby: Updated CptnRuby to use translate() for scrolling
2010-05-13: All: In light of transformations, Font#drawRot is deprecated now
2010-05-13: C++: Fixed alpha support in Gosu::saveToPNG
2010-05-13: All: Added Image.getData().toBitmap() (C++)/Image#to_blob (Ruby)
2010-05-13: All: Added support for custom entities as registerEntity(name, bitmap) (C++)/register_entity(name, image) (Ruby) that can be placed in text as &name;
2010-05-13: All: Added HTML-like text markup for Font and Image#from_text (and C++ equivalents): <b>, <u>, <i> and <c=aarrggbb>/<c=rrggbb>
2010-05-10: All: Added four matrix transformations that affect all contained drawing: scale(), translate(), rotate() and a free-form transform()
2010-05-31: Linux: made gem Rubinius-compatible

Especially the matrix transformations and text formatting open up lots of creative possibilities, and can remove lots of ugly scrolling code. Please toy around and write beautiful games :)
Reply
- By ippa Date 2010-06-13 16:34
great stuff Julian!
Reply
- By erisdiscord Date 2010-06-13 19:34
Excellent; now I can use these lovely transformations for composite sprites and such. Thanks for the credit in the source file. :)
Reply
- By Maverick Date 2010-06-13 19:38
I LOVE the markup ability for text. Gosu <3
Reply
- By Basic Date 2010-06-13 20:58
custom entities? what's that?
is this a prefab game object?
Reply
- By erisdiscord Date 2010-06-13 21:47
It looks like it's something like HTML entities, to go with the HTML-like formatting. For instance: font.register_entity('smile', smile_image) might draw a smiley face (one assumes) wherever it sees &smile; in your string.
Reply
- By kyonides Date 2010-06-13 22:35
Those are some great news especially if they're not coming from the World Cup 2010!

Mmm... I guess I was using draw_rot somewhere in my code but I can't remember where exactly...
Reply
- By jlnr (dev) Date 2010-06-14 04:09
erisdiscord, it's actually Gosu::register_entity. Other than that, just right. :)

Sorry everybody for the current lack of documentation and especially example games.
Reply
- By jlnr (dev) Date 2010-06-14 05:39
erisdiscord, let me know if the behavior of nested transforms is what works for you. I just got the feeling that the order of their application should be the other way around for composite stuff. :/
Reply
- By erisdiscord Date 2010-06-14 06:32
In fact, it appears that the behavior is precisely the opposite of what I am expecting. Take this hypothetical but totally pointless window class:

class Window < Gosu::Window
  def initialize
    super 320, 240, false
   
    @x, @y = 0.0, 0.0
    @theta = 0.0
   
    @vx, @vy = 0.0, 0.0
    @omega   = 0.0
   
  end
 
  def button_down id
    case id
    when Gosu::KbLeft     then @vx    -= 1
    when Gosu::KbRight    then @vx    += 1
    when Gosu::KbUp       then @vy    -= 1
    when Gosu::KbDown     then @vy    += 1
    when Gosu::KbPageUp   then @omega -= 1
    when Gosu::KbPageDown then @omega += 1
    end
  end
 
  def button_up id
    case id
    when Gosu::KbLeft     then @vx    += 1
    when Gosu::KbRight    then @vx    -= 1
    when Gosu::KbUp       then @vy    += 1
    when Gosu::KbDown     then @vy    -= 1
    when Gosu::KbPageUp   then @omega += 1
    when Gosu::KbPageDown then @omega -= 1
    end
  end
 
  def update
    @x     += @vx
    @y     += @vy
    @theta += @omega
  end
 
  def draw
    translate @x, @y do
      rotate @theta do
        draw_quad \
          -8, -8, Gosu::Color::WHITE,
          +8, -8, Gosu::Color::WHITE,
          +8, +8, Gosu::Color::WHITE,
          -8, +8, Gosu::Color::WHITE, 0
      end # rotate
    end # translate
  end
end


To me, coming from OpenGL, pressing page up and page down should cause the square to rotate in place; what happens is that it rotates about the origin. I assume the transformations are being applied in reverse order? It's kind of weird.
Reply
- By benko Date 2010-06-14 12:07
I find the order of transformations pretty coherent: inner transforms are applied before outer transforms -> first, you rotate and then you translate the result. At least this is what I would expect from reading the posted code :)
Reply
- By jlnr (dev) Date 2010-06-14 13:12
I didn't think much about it with a all-in-one-place example like that. Now I face the situation that a game object cannot change the most outermost transform (for scrolling) but only wants to do an innermost rotation (around its origin), and I suspect the order is really not handy the way it is. :/

If I change this, I better be fast with 0.7.22 *cough* :)
Reply
- By erisdiscord Date 2010-06-14 19:00
Yeah, it's kind of backwards from OpenGL's way of doing it; I was imagining rotate and translate to be something akin to this:

glPushMatrix();
  glTranslate(x, y);
  glPushMatrix();
    glRotate(theta);
    /* draw code here */
  glPopMatrix();
glPopMatrix();


Except with drawing order handled automagically, of course. You're right that the nested transformations aren't terribly useful the way they are, at least not for any use case I can contrive. Nested translations or rotations should still be fine, but mixing the two will only end in tears.

No worries for now; translation was the most important thing to me, because there's a lot more of that in the kind of game I want to make. If you change the order for 0.7.22 I'll consider it a bonus. Maybe I can make big bosses. :)
Reply
- By jlnr (dev) Date 2010-06-15 16:40
Reversed the order of matrices now. It's a bit weird to have to read them from the inside out, but that's of course the only way to nest it into functions. Duh, what a stupid oversight—fixing it made my composite objects so pretty. (I need to rotate them so had a 2x2 matrix system built in just for the rotation) :)
Reply
- By kyonides Date 2010-06-15 20:56
Is this valid for 2D and 3D? Or is it just for 2D like before?
Reply
- By jlnr (dev) Date 2010-06-16 05:39
You can pass a 4x4 matrix to Window#transform, so you can do 3D-transformations. The results will still be ordered by Gosu's Z-order though.
Reply
- By ickylevel Date 2010-06-16 14:24 Edited 2010-06-16 16:36
OK I upgrade to this one !

But I can't get rubygems to work. Anyone ever got this error : ordinal 277 SSLEAY32.DLL
Reply
Up Topic Gosu / Gosu News / Gosu 0.7.21 released

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill