Description
I am trying to update the game "garden hero" right now.
I get lots of deprecation warnings such as:
#Called from ["gui/gosu/garden_hero/core/player/player.rb:24:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:25:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:26:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:27:in `new'"].
DEPRECATION WARNING: Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:28:in `new'"].
DEPRECATION WARNING: Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:29:in `new'"].
DEPRECATION WARNING: Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:30:in `new'"].
DEPRECATION WARNING: Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:31:in `new'"].
DEPRECATION WARNING: Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.,
#Called from ["gui/gosu/garden_hero/core/player/player.rb:32:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/player/apple_player.rb:14:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/star.rb:16:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/apple.rb:16:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/enemy.rb:36:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/enemy.rb:37:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/enemy.rb:38:in `new'"].
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
#Called from ["gui/gosu/garden_hero/core/level/enemy.rb:39:in `new'"].
gui/gosu/garden_hero/core/menu/menu.rb:95: warning: constant Gosu::KbSpace is deprecated
gui/gosu/garden_hero/core/menu/menu.rb:86: warning: constant Gosu::MsLeft is deprecated
Right now I have no idea what to do about them. I am also not sure if there is any documentation.
Would it be possible to add some kind of deprecation helper module? One that is tasked to try
to give additional helpful information for developers.
For instance, you can report that warning, which you do via combat.rb already I think:
https://github.com/gosu/gosu/blob/03a71f89b64c3f63ab28ce8f2ce95586b5272f49/lib/gosu/compat.rb
But perhaps an additional module that gives information what to do. For instance:
gui/gosu/garden_hero/core/menu/menu.rb:86: warning: constant Gosu::MsLeft is deprecated
# add
gui/gosu/garden_hero/core/menu/menu.rb:86: ^^^ use Gosu::Keyboard::LEFT instead
Or something like that.
For the other message:
DEPRECATION WARNING: Passing a Window to Image#initialize has been deprecated in Gosu 0.9 and this method now uses an options hash, see https://www.libgosu.org/rdoc/Gosu/Image.html ,
I find rdoc hard to understand.
For instance, the code (written by someone else, not me), goes like this:
@img = Gosu::Image.new(window, 'images/player/apple.png', true)
I understand that I have to use a Hash instead, but I have no idea how to change it based on rdoc.
@img = Gosu::Image.new(window: window, image: 'images/player/apple.png', whatever: true)
I don't mind to adjust old code, but it would be easier if gosu itself could provide more information
here. And/or perhaps also provide up-to-date examples. I checked under examples/ but this is
super-sparse. I grepped for "Image" but could not find a single gosu-image example from ruby
there. You may assume I can understand rdoc, but this is a general problem for me: rdoc is next
to useless. Usually people just autogenerate stuff and are happy with whatever rdoc generates,
even if it is of bad quality.
I then found gosu examples but a search also didn't show how to do so:
https://github.com/search?q=repo%3Agosu%2Fgosu-examples%20Image&type=code
Documentation for Image can be seen here:
https://www.rubydoc.info/gems/gosu/Gosu/Image
After reading that page I still have absolutely no idea what to do. It would be easier if it was
my code, but the code quality of that other dev is also annoyingly poor, so at that point I
gave up and resumed to do something else.
If you ever have the time, perhaps you could consider improving not only the deprecation
warnings per se, but to also tell people specifically HOW to change it. Or where to read up
on it, because the API documentation is confusing. A single example .rb file may be enough
for me, but even finding that seems to be difficult.
Thank you for reading nonetheless.