08-05-2019, 07:29 AM
Lately I was customizing Gosu the Ruby gem because I felt there is a feature that shouldn't exist. At least it doesn't seem to make sense in its current state. For those unaware of it, here's the explanation! (It might be a bit technical for those interested only in battle systems and voice acting )
You remember that HiddenChest offers stuff like fullscreen and now even block_fullscreen? Well, Gosu already had its own method to show a game in fullscreen mode or not, but there's nothing like block_fullscreen because... well, that was my crazy idea. So I messed with its source code and quickly added such a thing plus all keys I could think off that didn't have a default Constant assigned to them, even if you could already make use of their numeric value directly. Then I suddenly asked the gosu fans to tell me what was the default method to show the mouse cursor. Yeah, by default it vanishes in thin air. Nope, there's no configuration text file to change that mainly because you only need to deal with Ruby and its rubygem Gosu and perhaps some OpenGL stuff as well. So if you ever need to configure something, go and change that in a Ruby script and that's pretty much all!
Err, not quite this time... I found out that you need to call a specific method, namely
To make it work, but you can easily change the cursor appearance as if it were just another sprite in your game. O_O Anyway that method tells a game developer like me that Gosu will call that very same method many times a second!!
In a game engine that lets you use flags like Window#fullscreen = true, what the hell is a needs_cursor? method doing there? O_o? So I edited the source code by writing stuff in C++ and CRuby code and manage to reimplement it myself as just another flag called Window#show_cursor = true. Stylish, don't you think? Later on I told Gosu developers about it just in case they ever wanted to change that.
Surprisingly, the current maintainer disregarded this suggestion and even called it a source of probable instability! Say what? How could it get unstable if it's just another variable? You'd only call it about twice in a single game or probably never ever.
There's another detail you might need to know to judge this situation. If you don't add that method to any scene alias state, well, you won't ever know where the heck is your mouse cursor pointing at!! Perhaps you can still click like always but it wouldn't make sense to do that as if you were blindfolded from the very beginning. So this means that a game needing it like in 3 or 4 scenes, it would need to add that method to all of them! I know, if you encapsulated stuff on a daily basis you could just add it to the base scene or something like that, but then you'd end up creating copies of it only to tell your game its value should be false whenever you don't need it!
Tell me, how's that method more trustworthy than just using a flag like show_cursor = true or false? O_o? On a single scene you could easily activate or deactivate the cursor if you don't need it anywhere else! Every tick or frame you'd make your game leave the drawing stage written primarily in C++ to check Ruby's needs_cursor? method if it ever existed for that specific scene class. What for!? The game could just go update the usual stuff instead like Audio (called Song there) or Input and so on.
Honestly, I really find the needs_cursor? method a real burden for game developers because an internal flag could solve the issue in no time without causing you any troubles, plus it'd get an appropriate name this time. It'd already be false by default so what's the need to fear your games could get unstable!? I have proven that the show_cursor flag is no longer just a theoretical delusion but a reality so why would anybody speak against it!?
You remember that HiddenChest offers stuff like fullscreen and now even block_fullscreen? Well, Gosu already had its own method to show a game in fullscreen mode or not, but there's nothing like block_fullscreen because... well, that was my crazy idea. So I messed with its source code and quickly added such a thing plus all keys I could think off that didn't have a default Constant assigned to them, even if you could already make use of their numeric value directly. Then I suddenly asked the gosu fans to tell me what was the default method to show the mouse cursor. Yeah, by default it vanishes in thin air. Nope, there's no configuration text file to change that mainly because you only need to deal with Ruby and its rubygem Gosu and perhaps some OpenGL stuff as well. So if you ever need to configure something, go and change that in a Ruby script and that's pretty much all!
Err, not quite this time... I found out that you need to call a specific method, namely
Code:
def needs_cursor?
true
end
To make it work, but you can easily change the cursor appearance as if it were just another sprite in your game. O_O Anyway that method tells a game developer like me that Gosu will call that very same method many times a second!!
In a game engine that lets you use flags like Window#fullscreen = true, what the hell is a needs_cursor? method doing there? O_o? So I edited the source code by writing stuff in C++ and CRuby code and manage to reimplement it myself as just another flag called Window#show_cursor = true. Stylish, don't you think? Later on I told Gosu developers about it just in case they ever wanted to change that.
Surprisingly, the current maintainer disregarded this suggestion and even called it a source of probable instability! Say what? How could it get unstable if it's just another variable? You'd only call it about twice in a single game or probably never ever.
There's another detail you might need to know to judge this situation. If you don't add that method to any scene alias state, well, you won't ever know where the heck is your mouse cursor pointing at!! Perhaps you can still click like always but it wouldn't make sense to do that as if you were blindfolded from the very beginning. So this means that a game needing it like in 3 or 4 scenes, it would need to add that method to all of them! I know, if you encapsulated stuff on a daily basis you could just add it to the base scene or something like that, but then you'd end up creating copies of it only to tell your game its value should be false whenever you don't need it!
Tell me, how's that method more trustworthy than just using a flag like show_cursor = true or false? O_o? On a single scene you could easily activate or deactivate the cursor if you don't need it anywhere else! Every tick or frame you'd make your game leave the drawing stage written primarily in C++ to check Ruby's needs_cursor? method if it ever existed for that specific scene class. What for!? The game could just go update the usual stuff instead like Audio (called Song there) or Input and so on.
Honestly, I really find the needs_cursor? method a real burden for game developers because an internal flag could solve the issue in no time without causing you any troubles, plus it'd get an appropriate name this time. It'd already be false by default so what's the need to fear your games could get unstable!? I have proven that the show_cursor flag is no longer just a theoretical delusion but a reality so why would anybody speak against it!?
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE