Does anybody know an easy way to have a variable loop through a range between a negative number and a positive number.
For example, for my screen test script, to keep the allowable range for the screen tone I have to use this:
case @window_screen.index
when 0 # Red Tone
if Input.trigger?(Input::RIGHT)
$game_screen.tone.red += 1
$game_screen.tone.red = 255 if $game_screen.tone.red >= 255
elsif Input.trigger?(Input::LEFT)
$game_screen.tone.red -= 1
$game_screen.tone.red = -255 if $game_screen.tone.red <= -255
elsif Input.repeat?(Input::RIGHT)
$game_screen.tone.red += 5
$game_screen.tone.red = 255 if $game_screen.tone.red >= 255
elsif Input.repeat?(Input::LEFT)
$game_screen.tone.red -= 5
$game_screen.tone.red = -255 if $game_screen.tone.red <= -255
end
I want to use something that works more like this:
when 4 # Weather Type
if Input.trigger?(Input::RIGHT)
$game_screen.weather_type = ($game_screen.weather_type += 1) % Z::Weather_Types
elsif Input.trigger?(Input::LEFT)
$game_screen.weather_type = ($game_screen.weather_type -= 1) % Z::Weather_Types
end
This is much shorter and easier, but I want it to work with a range between -255 and 255.
Any suggestions would be greatly appreciated. Thanks!