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

View File

@ -16,3 +16,13 @@ module RPG
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
#--------------------------------------------------------------------------
def ambient
@spriteset.ambient
end
def ambient=(val)
@spriteset.ambient = val
end
def add_light(id, filename, intensity, x, y)
@spriteset.add_light(id, filename, intensity, x, y)
end
@ -356,9 +350,6 @@ class Scene_Map
def clear_lights
@spriteset.clear_lights
end
def fade_in_bulb
@spriteset.fade_in_bulb
end
#--------------------------------------------------------------------------
# * Particle operations
#--------------------------------------------------------------------------

View File

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

View File

@ -62,6 +62,10 @@ class Spriteset_Map
end
# Make timer sprite
@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
update
end
@ -223,10 +227,14 @@ class Spriteset_Map
sprite.update
end
# Update bulb if fading in
if @bulb && @bulb.intensity < @bulb_intensity
@bulb.intensity += 0.005
if @bulb.intensity > @bulb_intensity
@bulb.intensity = @bulb_intensity
@bulb.tone = $game_map.ambient
if has_lightbulb?
if @bulb.opacity < 255
@bulb.opacity += 2.125
end
else
if @bulb.opacity > 0
@bulb.opacity -= 2.125
end
end
# Update particles
@ -234,7 +242,7 @@ class Spriteset_Map
# Update timer sprite
@timer_sprite.update
# 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
# Set screen flash color
@viewport_flash.color = $game_screen.flash_color