Re-implemented ambient light and bulb glow

This commit is contained in:
Mathew Velasquez 2015-11-22 18:44:06 -05:00
parent c0bf423bbf
commit 4c1dda76f6
5 changed files with 38 additions and 23 deletions

View File

@ -28,6 +28,7 @@ class Game_Map
attr_accessor :particles_type # particles name attr_accessor :particles_type # particles name
attr_accessor :clamped_panorama # panorama is clamped? attr_accessor :clamped_panorama # panorama is clamped?
attr_accessor :wrapping # map is wrapping? attr_accessor :wrapping # map is wrapping?
attr_accessor :ambient # ambient light
attr_reader :passages # passage table attr_reader :passages # passage table
attr_reader :priorities # prioroty table attr_reader :priorities # prioroty table
attr_reader :terrain_tags # terrain tag table attr_reader :terrain_tags # terrain tag table
@ -109,6 +110,8 @@ class Game_Map
@clamped_panorama = false @clamped_panorama = false
# Unwrap map # Unwrap map
@wrapping = false @wrapping = false
# Full bright ambient light
@ambient = Tone.new(0, 0, 0, 0)
# Construct map name path # Construct map name path
mapinfo = load_data("Data/MapInfos.rxdata") mapinfo = load_data("Data/MapInfos.rxdata")

View File

@ -16,3 +16,13 @@ module RPG
end end
end end
end end
class Tone
def +(o)
Tone.new(self.red + o.red, self.green + o.green, self.blue + o.blue, self.gray + o.gray)
end
def *(s)
Tone.new(self.red * s, self.green * s, self.blue * s, self.gray * s)
end
end

View File

@ -341,12 +341,6 @@ class Scene_Map
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# * Lighting operations # * Lighting operations
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def ambient
@spriteset.ambient
end
def ambient=(val)
@spriteset.ambient = val
end
def add_light(id, filename, intensity, x, y) def add_light(id, filename, intensity, x, y)
@spriteset.add_light(id, filename, intensity, x, y) @spriteset.add_light(id, filename, intensity, x, y)
end end
@ -356,9 +350,6 @@ class Scene_Map
def clear_lights def clear_lights
@spriteset.clear_lights @spriteset.clear_lights
end end
def fade_in_bulb
@spriteset.fade_in_bulb
end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# * Particle operations # * Particle operations
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------

View File

@ -46,6 +46,10 @@ module Script
end end
end end
def has_lightbulb?
$game_party.item_number(1) > 0
end
def enter_name def enter_name
$game_temp.name_calling = true $game_temp.name_calling = true
end end
@ -76,14 +80,12 @@ def particles(type)
$game_map.particles_type = type $game_map.particles_type = type
end end
def ambient(r, g = -1, b = -1) def ambient(r, g, b, gray = 0)
g = r if g < 0 $game_map.ambient.set(r, g, b, gray)
b = r if b < 0
#$scene.ambient = Color.new(r, g, b)
end end
def clear_ambient def clear_ambient
#$scene.ambient = Color.new(255, 255, 255) $game_map.ambient.set(0, 0, 0, 0)
end end
def add_light(id, file, intensity, x, y) def add_light(id, file, intensity, x, y)
@ -98,10 +100,6 @@ def clear_lights
#$scene.clear_lights #$scene.clear_lights
end end
def fade_in_bulb
#$scene.fade_in_bulb
end
def clamp_panorama def clamp_panorama
$game_map.clamped_panorama = true $game_map.clamped_panorama = true
end end
@ -109,3 +107,8 @@ end
def wrap_map def wrap_map
$game_map.wrapping = true $game_map.wrapping = true
end end
# Map specific settings
def green_ambient
ambient -50, -50, -50
end

View File

@ -62,6 +62,10 @@ class Spriteset_Map
end end
# Make timer sprite # Make timer sprite
@timer_sprite = Sprite_Timer.new @timer_sprite = Sprite_Timer.new
# Make lightbulb sprite
@bulb = Sprite.new(@viewport_lights)
@bulb.bitmap = RPG::Cache.light('bulb')
@bulb.opacity = has_lightbulb? ? 255 : 0
# Frame update # Frame update
update update
end end
@ -223,10 +227,14 @@ class Spriteset_Map
sprite.update sprite.update
end end
# Update bulb if fading in # Update bulb if fading in
if @bulb && @bulb.intensity < @bulb_intensity @bulb.tone = $game_map.ambient
@bulb.intensity += 0.005 if has_lightbulb?
if @bulb.intensity > @bulb_intensity if @bulb.opacity < 255
@bulb.intensity = @bulb_intensity @bulb.opacity += 2.125
end
else
if @bulb.opacity > 0
@bulb.opacity -= 2.125
end end
end end
# Update particles # Update particles
@ -234,7 +242,7 @@ class Spriteset_Map
# Update timer sprite # Update timer sprite
@timer_sprite.update @timer_sprite.update
# Set screen color tone and shake position # Set screen color tone and shake position
@viewport.tone = $game_screen.tone @viewport.tone = $game_screen.tone + $game_map.ambient * (1.0 - @bulb.opacity / 255.0)
@viewport.ox = $game_screen.shake @viewport.ox = $game_screen.shake
# Set screen flash color # Set screen flash color
@viewport_flash.color = $game_screen.flash_color @viewport_flash.color = $game_screen.flash_color