There's a neat little snippet of code that I've been working on in Ruby for a code in RPG Maker VX Ace. (If you're interested, I was coding a TimeStop script, and I needed to collect object data from a hash to update sprite tone values to make them lose color when time stops :/)
Let's say you're using RGSS3 at the moment.
(Note, because the /at/ symbol doesn't work in Wattpad, I will use the IPA voiceless dental fricative (also the Greek theta) instead: example = θexample_instance_variable)
Look at this code:
'
class Sprite_Character < Sprite
attr_accessor :character
# character: Game_Character
def initialize(character, viewport = nil)
super(viewport) unless viewport.nil?
θcharacter = character
update
enddef update
super
update_bitmap_rect # Yeah I'm not defining this here
update_tone
end
# Here's where the selection stuff happens
def update_tone
tint = $game_screen.tone # This is a coloring method that preserves the screen's tint
self.tone = tint #Sets the tint of the sprite
if $game_system.timestop? && θcharacter.timestopped?
# The below runs if the character that this sprite refers to is stopped by the time
# stop function. i.e, if the character needs to lose color.
bwtint = Tone.new(0, 0, 0, 256)
self.tone = bwtint # sets the tint of this sprite to grayscale
else
self.tone = tint # Resets the tone to the screen tone if the character isn't timestopped (or b/w)
end
end
end'
So complex
![](https://img.wattpad.com/cover/157883811-288-k619774.jpg)
YOU ARE READING
Programming Tutorials
Non-FictionHello!!! This book is more of a tutorial/How-to on computers and stuff, amd even if you wamt to get your phone, for example, to the condition mine is in (Hacked like hell). This covers everything from programming languages to ms paint to .zip file/f...