Guest User

Lights script

a guest
Apr 25th, 2010
301
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Map
  2.     def draw
  3.         if @rooms[room]['dark']
  4.             darkness=Image.new($screen,'gfx/system/darkness.png') #black image fitting the window
  5.             @lights[room].each{|l| l.glow(sx,sy,darkness)} #make all lights glow
  6.             darkness.draw(0,0,5) #draw the effect
  7.         end
  8.     end
  9. end
  10.  
  11. class Light
  12.     attr_accessor :x, :y
  13.     def initialize(x,y,radius,qswitch,map,room)
  14.         @x,@y,@radius,@room=x,y,radius,room
  15.         map.lights[room] << self
  16.     end
  17.  
  18.     def glow(sx,sy,darkness)
  19.         if @x+16-@radius*32<sx+640 and @x+16+@radius*32>sx and @y+16-@radius*32<sy+480 and @y+16+@radius*32>sy
  20.             darkness.circle(@x-sx+16,@y-sy+16,16+@radius*32,:color=>[0,0,0,0], :fill => true)
  21.         end
  22.     end
  23.  
  24.     def remove
  25.         $game.map.lights[@room].delete(self)
  26.     end
  27. end
RAW Paste Data