A Happy New Year!
> Hello it's me again. Now that I've solved the last problem, I'm trying
> to rewrite my puzzle game that I wrote with gosu to use StarRuby
> instead :D
That's good!
> However, I've found one problem though. I wish we should change the
> attribute of the color class. This would make playing text effect
> become much easier. Like, a fade in text you can just write
> @color.alpha = [@color.alpha + 1, 255].min instead of having to
> create a new instance from Color class every update.
>
> Is this already possible or is there a way to work around this? Thank
> you in advance :)
Since a color object is immutable (not changeable), you can not do so.
Moreover, it's very difficult to reimplement Color objects to be changeable.
We have developed Star Ruby library on the basis that the color class is
immutable.
Whether a object is immutable or not is a tread-off between briefness
and performance.
Why we decided Color should be immutable is that we think we do not have to care
about allocation a new color object very much.
Do you have a performance probrem about new color object-allocation?
--
Hajime Hoshi <hajim...@gmail.com>
As you suggest, Star Ruby's rendering performance is not good.
Since most part of a execution is rendering, I can often find some improvements
in drawing processes.
In your souce code:
* Texture#clear is faster than Texture#render_rect(0, 0, 640, 480,
Color.new(0, 0, 0, 255)).
(To be exact, Texture#clear is as same as
Texture#fill_rect(0, 0, 640, 480, Color.new(0,0,0,0)).)
For example, I found it in draw method of SceneKurickZum class.
* In 'draw' method of NumberBlock class, some render_text methods are used.
If you use a texture object as a buffer where the texts are rendered,
you need only one render_texture method with this buffer.
Above all, Texture#render_text method is one of the heaviest methods.
It is recommended to use a texture object as a buffer or a cache.
--
Hajime Hoshi <hajim...@gmail.com>