Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Lighting with several light sources

Hello.

I was wondering if some here have done something similar to what I want to make in a project.
I want to create some rooms that are pitch black with the exception of the light from the windows or other stationary lightsources and from a flashlight held by the player.
I can make either one work but not at the same time by a simple black image over the screen with the light part being transparent. I was wondering if someone had found a solution for a similar problem or if I might be on the wrong track with using images for this.
 
Yes I'm using RM XP. Forgot to mention it.
http://i115.photobucket.com/albums/n306/PregnantOrc/Haunt%203/Result.png[/img]

I'll search for Krafts and dynamic fog tutorials tonight.

Thank you for the help so far
 
For the window light, a fog will do as others mentioned. But for the flashlight, I'm not sure. Angelman released a nice tutorial for that, the only problem is that it's only a circle around the character. To have it go all the way to the wall would most definitely need a script, and a complicated one at that.

Unless I'm misunderstanding what you're saying, which I get the strange feeling that I am.
 
Dadevster":27fo5hwp said:
For the window light, a fog will do as others mentioned. But for the flashlight, I'm not sure. Angelman released a nice tutorial for that, the only problem is that it's only a circle around the character.

I was thinking about a flashlight system because of the current game I am working. It will most likely be an event system. Once I have something I'll post what I have on this thread and make a new one but it would probably be a month or two because I am currently busy with school and work.
 
SephirothSpawn made one a while back, I don't know if you'll be able to find it, however.

EDIT: Found it in a old demo I had!
Code:
#==============================================================================
# Circle Of Light (Adds Circle Around your character
#--------------------------------------------------------------------------
#   Created By SephirothSpawn (12.08.05)
#     Thanks to Nick for Coordinates Help
#   Last Updated: 12.05.05
#==============================================================================

#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :cover_on, :col_on, :col_level, :col_flashlight
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias col_int initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    col_int
    @cover_on, @col_on, @col_level, @col_flashlight = false, false, 1, false
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias col_main main
  alias col_update update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Cover
    @cover = Sprite.new
      @cover.bitmap = RPG::Cache.fog("Cover", 0)
      @cover.z, @cover.opacity = 9999, 200
      @cover.visible = $game_temp.cover_on ? true : false
    # Creates Circle Of Light Sprite
    @circle_of_light = Sprite.new
      if $game_temp.col_flashlight
        file = "Flash Light_"
        file += "D" if $game_player.direction == 2
        file += "L" if $game_player.direction == 4
        file += "R" if $game_player.direction == 6
        file += "U" if $game_player.direction == 8
      else
        file = "Circle of Light_#{$game_temp.col_level}"
      end
      @circle_of_light.bitmap = RPG::Cache.fog(file, 0)
      @circle_of_light.x = ($game_player.real_x / 4) - 624 - $game_map.display_x / 4
      @circle_of_light.y = ($game_player.real_y / 4) + 32 - 480 - $game_map.display_y / 4
      @circle_of_light.z, @circle_of_light.opacity = 9999, 200
      @circle_of_light.visible = $game_temp.col_on ? true : false
    # Orignal Scene_Map Main
    col_main
    # Disposes Circle Of Light Sprite
    @circle_of_light.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Updates Cover Visiblity
    @cover.visible = $game_temp.cover_on ? true : false
    # Updates Circle of Light Visibility
    @circle_of_light.visible = $game_temp.col_on ? true : false
    # Updates Circle Of Light Bitmap
    if $game_temp.col_flashlight
      file = "Flash Light_"
      file += "D" if $game_player.direction == 2
      file += "L" if $game_player.direction == 4
      file += "R" if $game_player.direction == 6
      file += "U" if $game_player.direction == 8
    else
      file = "Circle of Light_#{$game_temp.col_level}"
    end
    @circle_of_light.bitmap = RPG::Cache.fog(file, 0)
    # Moves Sprite X
    desired_x = ($game_player.real_x / 4) - 624 - $game_map.display_x / 4
    if desired_x > @circle_of_light.x
      @circle_of_light.x += 4
    elsif desired_x < @circle_of_light.x
      @circle_of_light.x -= 4
    end
    # Moves Sprite Y
    desired_y = ($game_player.real_y / 4) - 472 - $game_map.display_y / 4
    if desired_y > @circle_of_light.y
      @circle_of_light.y += 4
    elsif desired_y < @circle_of_light.y
      @circle_of_light.y -= 4
    end
    # Orginal Scene_Map Update
    col_update
  end
end
And you'll need to put these files in your Fogs folder:
Click me!

Hope that helps for your flashlight.
 
I'm glad for all the responses and thank you all for them yet it doesn't work for what I have in mind.

Having a image as light works nicely to indicate light but it works in the opposite way to what I'm trying to do.
I want areas that are so dark that you can't or barely can make out what is on the screen unless there is a light there. When using a image as light it becomes a yellow or while area on the almost black background. It doesn't improve the visability for the player, it acctualy makes it worse since it adds some contrast.

Is it possible to make a colour always transparent for images using a script? Asking since it whould be a great solution.
 
Assuming I understand correctly, you could make your own fog?
I make my own fogs to create nighttime ambience on my maps.
Do you mean something like this?

http://i156.photobucket.com/albums/t30/neurotix_photos/lights.jpg[/img]

Of course with a darker sweep of the area you can make the room darker around the lights to 0 visibility.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top