Rain Candy
Version: 1.0
Author: Marc of Fall From Eden
Date: March 17, 2012
Version History
- <Version 1.0> 2012.03.17 - Original Release
Description
This script creates a more aesthetically-pleasing rain effect than the one provided by RMVX. In other words, it's pure eye candy.
Features
- Use weather effects the same way you normally would (no script calls or fogs).
- The opacity and speed of the rain will be affected by the "power" of the weather effect.
- Many of the default aesthetics are easily user-modifiable.
- It's eye candy!
Screenshots Instructions
This script makes use of the default way RMVX handles weather. As such, all you need to do is set weather effects the way you normally would, and the intensity of the rain effect will adjust accordingly. If you want to change any of the default values used, simply modify their related constants in the Marc::Weather module of the script.
Script
This script requires an image to display for the rain effect. The
image included in the demo is one we created for the effect, but
this image created by ak47lol for their "realistic rain" tutorial works just as well (if not better).
If you use ak47lol's rain image, please be sure to credit them!# ============================================================================ #
# Rain Candy v1.0 by Marc (of Fall From Eden) #
# This script is licensed under the Creative Commons BY-SA 3.0 license. #
# ============================================================================ #
# DESCRIPTION #
# ---------------------------------------------------------------------------- #
# This script creates a more aesthetically-pleasing rain effect than the one #
# provided by RMVX. In other words, it's pure eye candy. ;) #
# ============================================================================ #
# USAGE INSTRUCTIONS #
# ---------------------------------------------------------------------------- #
# This script makes use of the default way RMVX handles weather. As such, all #
# you need to do is set weather effects the way you normally would, and the #
# intensity of the rain effect will adjust accordingly. If you want to change #
# any of the default values used, simply modify their related constants in the #
# Marc::Weather module below. #
# ============================================================================ #
module Marc
module Weather
# Set RAIN_FILE to the picture you want to use for the rain effect.
RAIN_FILE = "rain"
# RAIN2_FILE is the file to display underneath RAIN_FILE; this creates a
# more visually pleasing effect, as RAIN2_FILE subtracts from RAIN_FILE.
RAIN2_FILE = RAIN_FILE
# The tone you want rain to be. Set as Tone.new(red, green, blue, gray).
RAIN_TONE = Tone.new(0, 0, 128, 75)
# Determine the zoom levels of RAIN_FILE and RAIN2_FILE here. 1.0 is 100%,
# 2.0 is 200%, and so on.
RAIN_ZOOM = 1.0
RAIN2_ZOOM = 1.5
end
end # module Marc::Weather
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# ! DO NOT EDIT BEYOND THIS POINT. ! #
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# ============================================================================ #
# Spriteset_Weather #
# ---------------------------------------------------------------------------- #
# Aliased methods: initialize, update, dispose, type= #
# New methods: dispose_weather_planes #
# ============================================================================ #
class Spriteset_Weather
alias marc_rain_spriteset_weather_initialize initialize
def initialize(viewport = nil)
@type, @max, @ox, @oy = 0
@rain_bitmap, @storm_bitmap = nil
@weather_plane = Plane.new(viewport)
@weather_plane2 = Plane.new(viewport)
@weather_plane2.blend_type = 2
@weather_plane.zoom_x = Marc::Weather::RAIN_ZOOM
@weather_plane.zoom_y = Marc::Weather::RAIN_ZOOM
@weather_plane2.zoom_x = Marc::Weather::RAIN2_ZOOM
@weather_plane2.zoom_y = Marc::Weather::RAIN2_ZOOM
marc_rain_spriteset_weather_initialize
end # initialize
alias marc_rain_spriteset_weather_update update
def update
return if @type == 0
case @type
when 1
@weather_plane.opacity = (@max * 4)
@weather_plane2.opacity = (@max * 3)
@weather_plane.ox += (@max / 9).to_i
@weather_plane.oy -= 8
@weather_plane2.ox += (@max / 6).to_i
@weather_plane2.oy -= 6
when 2
@weather_plane.opacity = (@max * 5)
@weather_plane2.opacity = (@max * 4)
@weather_plane.ox += (@max / 6).to_i
@weather_plane.oy -= 16
@weather_plane2.ox += (@max / 4).to_i
@weather_plane2.oy -= 12
else
dispose_weather_planes
end
marc_rain_spriteset_weather_update
end # update
alias marc_rain_spriteset_weather_dispose dispose
def dispose
dispose_weather_planes
marc_rain_spriteset_weather_dispose
end # dispose
def dispose_weather_planes
unless @weather_plane.bitmap.nil? or @weather_plane2.bitmap.nil?
@weather_plane.bitmap.dispose
@weather_plane2.bitmap.dispose
end
end # dispose_weather_planes
alias marc_rain_spriteset_weather_type type=
def type=(type)
return if @type == type
if type == 1 or type == 2
@type = type
for sprite in @sprites
sprite.bitmap = nil
end
@weather_plane.bitmap = Cache.picture(Marc::Weather::RAIN_FILE)
@weather_plane2.bitmap = Cache.picture(Marc::Weather::RAIN2_FILE)
@weather_plane.tone = Marc::Weather::RAIN_TONE
else
dispose_weather_planes
marc_rain_spriteset_weather_type(type)
end
end # type=
end # class Spriteset_Weather
Credit
- Marc of Fall From Eden
- ak47lol (if you use their rain image)
Thanks
Support
You may receive support for this script in this topic or by sending us a personal message on these forums.
Known Compatibility Issues
This script only modifies Spriteset_Weather, so it should be compatible with just about anything except another script which affects how weather is drawn or handled.
Demo
Rain Candy DemoThere's nothing to demonstrate, but if you want to see the effect....
Author's Notes
This script was inspired by a topic we recently viewed about creating "realistic rain" on VX.net written by ak47lol. Marc then decided to script in a similar effect that makes use of RMVX's
default weather effects (and how they are set) to keep things as simple as possible for the end-user.
(We might also be using this in our own game, but that's beside the point on this one.)
Restrictions
This script is licensed under a Creative Commons BY-SA 3.0 license. Essentially, you may use it for commercial games, but proper attribution is required; as well, you may modify the script any way you like as long as the modified version retains attribution to the original author and is released under an
identical license.